1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 09:33:51 +03:00
latte-dock/app/lattecorona.h

250 lines
7.5 KiB
C
Raw Normal View History

2017-01-03 01:05:30 +03:00
/*
* Copyright 2016 Smith AR <audoban@openmailbox.org>
* Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LATTECORONA_H
#define LATTECORONA_H
2016-12-31 00:25:27 +03:00
2018-12-02 03:05:52 +03:00
// local
#include "plasma/quick/configview.h"
#include "layout/storage.h"
#include "view/panelshadows_p.h"
#include "../liblatte2/types.h"
2016-12-31 00:25:27 +03:00
2018-12-02 03:05:52 +03:00
// Qt
2016-12-31 00:25:27 +03:00
#include <QObject>
#include <QTimer>
2018-12-02 03:05:52 +03:00
// Plasma
#include <Plasma/Corona>
2016-12-31 00:25:27 +03:00
2018-12-02 03:05:52 +03:00
// KDE
2017-01-29 08:16:28 +03:00
#include <KAboutApplicationDialog>
namespace KDeclarative {
2019-02-18 18:46:53 +03:00
class QmlObjectSharedEngine;
}
2017-01-29 08:16:28 +03:00
namespace Plasma {
class Corona;
class Containment;
class Types;
}
namespace PlasmaQuick {
class ConfigView;
}
namespace KActivities {
class Consumer;
}
namespace KWayland {
namespace Client {
class PlasmaShell;
}
}
namespace Latte {
class CentralLayout;
class ScreenPool;
class GlobalShortcuts;
class UniversalSettings;
2019-04-12 18:55:45 +03:00
class View;
namespace Indicator{
class Factory;
}
namespace Layout{
class GenericLayout;
class Storage;
}
namespace Layouts{
class LaunchersSignals;
class Manager;
}
namespace PlasmaExtended{
class ScreenGeometries;
class ScreenPool;
class Theme;
}
2019-05-11 15:43:10 +03:00
namespace WindowSystem{
class AbstractWindowInterface;
}
}
2016-12-31 00:25:27 +03:00
namespace Latte {
class Corona : public Plasma::Corona
2018-07-03 22:15:45 +03:00
{
2016-12-31 00:25:27 +03:00
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.LatteDock")
2017-01-16 22:07:49 +03:00
2016-12-31 00:25:27 +03:00
public:
Corona(bool defaultLayoutOnStartup = false,
QString layoutNameOnStartUp = QString(),
int userSetMemoryUsage = -1,
QObject *parent = nullptr);
virtual ~Corona();
2017-01-16 22:07:49 +03:00
2016-12-31 00:25:27 +03:00
int numScreens() const override;
QRect screenGeometry(int id) const override;
QRegion availableScreenRegion(int id) const override;
QRect availableScreenRect(int id) const override;
//! This is a very generic function in order to return the availableScreenRect of specific screen
//! by calculating only the user specified visibility modes and edges. Empty QLists for both
//! arguments mean that all choices are accepted in calculations. ignoreExternalPanels means that
//! external panels should be not considered in the calculations
QRect availableScreenRectWithCriteria(int id,
QString forLayout = QString(),
QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(),
QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(),
bool ignoreExternalPanels = true) const;
2017-01-16 22:07:49 +03:00
QRegion availableScreenRegionWithCriteria(int id,
QString forLayout = QString(),
QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(),
QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(),
bool ignoreExternalPanels = true) const;
2016-12-31 00:25:27 +03:00
int screenForContainment(const Plasma::Containment *containment) const override;
2017-01-16 22:07:49 +03:00
KActivities::Consumer *activityConsumer() const;
KWayland::Client::PlasmaShell *waylandCoronaInterface() const;
KActivities::Consumer *activitiesConsumer() const;
GlobalShortcuts *globalShortcuts() const;
2017-02-24 21:58:21 +03:00
ScreenPool *screenPool() const;
UniversalSettings *universalSettings() const;
2019-05-11 15:43:10 +03:00
Layouts::Manager *layoutsManager() const;
Indicator::Factory *indicatorFactory() const;
PlasmaExtended::ScreenPool *plasmaScreenPool() const;
PlasmaExtended::Theme *themeExtended() const;
2017-02-24 21:58:21 +03:00
2019-05-11 15:43:10 +03:00
WindowSystem::AbstractWindowInterface *wm() const;
PanelShadows *dialogShadows() const;
2018-02-07 00:39:45 +03:00
//! these functions are used from context menu through containmentactions
void quitApplication();
void switchToLayout(QString layout);
void showSettingsWindow(int page);
void setContextMenuView(int id);
2018-02-07 00:39:45 +03:00
QStringList contextMenuData();
2016-12-31 00:25:27 +03:00
public slots:
2018-01-27 02:27:48 +03:00
void aboutApplication();
void addViewForLayout(QString layoutName);
void activateLauncherMenu();
2016-12-31 00:25:27 +03:00
void loadDefaultLayout() override;
2019-02-18 18:46:53 +03:00
void setBackgroundFromBroadcast(QString activity, QString screenName, QString filename);
void setBroadcastedBackgroundsEnabled(QString activity, QString screenName, bool enabled);
void showAlternativesForApplet(Plasma::Applet *applet);
void toggleHiddenState(QString layoutName, QString screenName, int screenEdge);
2019-02-18 18:46:53 +03:00
//! values are separated with a "-" character
void windowColorScheme(QString windowIdAndScheme);
void updateDockItemBadge(QString identifier, QString value);
2019-02-18 18:46:53 +03:00
2017-07-20 23:45:59 +03:00
void unload();
2017-01-16 22:07:49 +03:00
2016-12-31 00:25:27 +03:00
signals:
void configurationShown(PlasmaQuick::ConfigView *configView);
void viewLocationChanged();
void raiseViewsTemporaryChanged();
2019-04-12 18:55:45 +03:00
void availableScreenRectChangedFrom(Latte::View *origin);
void availableScreenRegionChangedFrom(Latte::View *origin);
2017-01-16 22:07:49 +03:00
private slots:
void alternativesVisibilityChanged(bool visible);
void load();
2017-01-16 22:07:49 +03:00
2017-02-24 21:58:21 +03:00
void addOutput(QScreen *screen);
void primaryOutputChanged();
void screenRemoved(QScreen *screen);
void screenCountChanged();
void syncLatteViewsToScreens();
2017-02-24 21:58:21 +03:00
2016-12-31 00:25:27 +03:00
private:
void cleanConfig();
void qmlRegisterTypes() const;
void setupWaylandIntegration();
2017-06-26 22:16:42 +03:00
bool appletExists(uint containmentId, uint appletId) const;
2017-02-06 04:55:41 +03:00
bool containmentExists(uint id) const;
2016-12-31 00:25:27 +03:00
int primaryScreenId() const;
QStringList containmentsIds();
QStringList appletsIds();
2017-01-16 22:07:49 +03:00
Layout::GenericLayout *layout(QString name) const;
CentralLayout *centralLayout(QString name) const;
private:
bool m_activitiesStarting{true};
2018-02-03 16:44:37 +03:00
bool m_defaultLayoutOnStartup{false}; //! this is used to enforce loading the default layout on startup
bool m_quitTimedEnded{false}; //! this is used on destructor in order to delay it and slide-out the views
//!it can be used on startup to change memory usage from command line
int m_userSetMemoryUsage{ -1};
int m_contextMenuViewId{-1};
QString m_layoutNameOnStartUp;
2019-02-18 18:46:53 +03:00
QList<KDeclarative::QmlObjectSharedEngine *> m_alternativesObjects;
KDeclarative::QmlObjectSharedEngine *m_backgroundTracer;
2017-01-16 22:07:49 +03:00
QTimer m_viewsScreenSyncTimer;
KActivities::Consumer *m_activityConsumer;
2017-01-29 08:16:28 +03:00
QPointer<KAboutApplicationDialog> aboutDialog;
2017-02-24 21:58:21 +03:00
ScreenPool *m_screenPool{nullptr};
UniversalSettings *m_universalSettings{nullptr};
GlobalShortcuts *m_globalShortcuts{nullptr};
Indicator::Factory *m_indicatorFactory{nullptr};
Layouts::Manager *m_layoutsManager{nullptr};
PlasmaExtended::ScreenGeometries *m_plasmaGeometries{nullptr};
PlasmaExtended::ScreenPool *m_plasmaScreenPool{nullptr};
PlasmaExtended::Theme *m_themeExtended{nullptr};
2019-05-11 15:43:10 +03:00
WindowSystem::AbstractWindowInterface *m_wm{nullptr};
PanelShadows *m_dialogShadows{nullptr};
KWayland::Client::PlasmaShell *m_waylandCorona{nullptr};
friend class GlobalShortcuts;
friend class Layout::Storage;
friend class Layouts::LaunchersSignals;
friend class Layouts::Manager;
2016-12-31 00:25:27 +03:00
};
}
#endif // LATTECORONA_H