File indexing completed on 2024-10-06 10:56:01
0001 /* 0002 SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org> 0003 SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef LATTECORONA_H 0009 #define LATTECORONA_H 0010 0011 // local 0012 #include <coretypes.h> 0013 #include "plasma/quick/configview.h" 0014 #include "layouts/storage.h" 0015 #include "view/panelshadows_p.h" 0016 0017 // Qt 0018 #include <QObject> 0019 #include <QTimer> 0020 0021 // Plasma 0022 #include <Plasma/Corona> 0023 0024 // KDE 0025 #include <KAboutApplicationDialog> 0026 0027 namespace KDeclarative { 0028 class QmlObjectSharedEngine; 0029 } 0030 0031 namespace Plasma { 0032 class Corona; 0033 class Containment; 0034 class Types; 0035 } 0036 0037 namespace PlasmaQuick { 0038 class ConfigView; 0039 } 0040 0041 namespace KActivities { 0042 class Consumer; 0043 } 0044 0045 namespace KWayland { 0046 namespace Client { 0047 class PlasmaShell; 0048 } 0049 } 0050 0051 namespace Latte { 0052 class CentralLayout; 0053 class ScreenPool; 0054 class GlobalShortcuts; 0055 class UniversalSettings; 0056 class View; 0057 class ViewSettingsFactory; 0058 namespace Indicator{ 0059 class Factory; 0060 } 0061 namespace Layout{ 0062 class GenericLayout; 0063 } 0064 namespace Layouts{ 0065 class Manager; 0066 } 0067 namespace PlasmaExtended{ 0068 class ScreenGeometries; 0069 class ScreenPool; 0070 class Theme; 0071 } 0072 namespace Templates { 0073 class Manager; 0074 } 0075 namespace WindowSystem{ 0076 class AbstractWindowInterface; 0077 } 0078 } 0079 0080 namespace Latte { 0081 0082 class Corona : public Plasma::Corona 0083 { 0084 Q_OBJECT 0085 Q_CLASSINFO("D-Bus Interface", "org.kde.LatteDock") 0086 0087 public: 0088 Corona(bool defaultLayoutOnStartup = false, 0089 QString layoutNameOnStartUp = QString(), 0090 QString addViewTemplateName = QString(), 0091 int userSetMemoryUsage = -1, 0092 QObject *parent = nullptr); 0093 virtual ~Corona(); 0094 0095 bool inQuit() const; 0096 0097 int numScreens() const override; 0098 QRect screenGeometry(int id) const override; 0099 QRegion availableScreenRegion(int id) const override; 0100 QRect availableScreenRect(int id) const override; 0101 0102 //! This is a very generic function in order to return the availableScreenRect of specific screen 0103 //! by calculating only the user specified visibility modes and edges. Empty QLists for both 0104 //! arguments mean that all choices are accepted in calculations. ignoreExternalPanels means that 0105 //! external panels should be not considered in the calculations 0106 QRect availableScreenRectWithCriteria(int id, 0107 QString activityid = QString(), 0108 QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(), 0109 QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(), 0110 bool ignoreExternalPanels = true, 0111 bool desktopUse = false) const; 0112 0113 QRegion availableScreenRegionWithCriteria(int id, 0114 QString activityid = QString(), 0115 QList<Types::Visibility> ignoreModes = QList<Types::Visibility>(), 0116 QList<Plasma::Types::Location> ignoreEdges = QList<Plasma::Types::Location>(), 0117 bool ignoreExternalPanels = true, 0118 bool desktopUse = false) const; 0119 0120 int screenForContainment(const Plasma::Containment *containment) const override; 0121 0122 KWayland::Client::PlasmaShell *waylandCoronaInterface() const; 0123 0124 KActivities::Consumer *activitiesConsumer() const; 0125 GlobalShortcuts *globalShortcuts() const; 0126 ScreenPool *screenPool() const; 0127 UniversalSettings *universalSettings() const; 0128 ViewSettingsFactory *viewSettingsFactory() const; 0129 Layouts::Manager *layoutsManager() const; 0130 Templates::Manager *templatesManager() const; 0131 0132 Indicator::Factory *indicatorFactory() const; 0133 0134 PlasmaExtended::ScreenPool *plasmaScreenPool() const; 0135 PlasmaExtended::Theme *themeExtended() const; 0136 0137 WindowSystem::AbstractWindowInterface *wm() const; 0138 0139 PanelShadows *dialogShadows() const; 0140 0141 //! Needs to be called in order to import and load application properly after application 0142 //! finished all its exit operations 0143 void importFullConfiguration(const QString &file); 0144 0145 //! these functions are used from context menu through containmentactions 0146 void quitApplication(); 0147 void switchToLayout(QString layout); 0148 void importLayoutFile(const QString &filepath, const QString &suggestedLayoutName = QString()); 0149 void showSettingsWindow(int page); 0150 0151 QStringList contextMenuData(const uint &containmentId); 0152 QStringList viewTemplatesData(); 0153 0154 public slots: 0155 void aboutApplication(); 0156 void activateLauncherMenu(); 0157 void loadDefaultLayout() override; 0158 0159 void setAutostart(const bool &enabled); 0160 0161 void addView(const uint &containmentId, const QString &templateId); 0162 void duplicateView(const uint &containmentId); 0163 void exportViewTemplate(const uint &containmentId); 0164 void moveViewToLayout(const uint &containmentId, const QString &layoutName); 0165 void removeView(const uint &containmentId); 0166 0167 void setBackgroundFromBroadcast(QString activity, QString screenName, QString filename); 0168 void setBroadcastedBackgroundsEnabled(QString activity, QString screenName, bool enabled); 0169 void showAlternativesForApplet(Plasma::Applet *applet); 0170 void toggleHiddenState(QString layoutName, QString viewName, QString screenName, int screenEdge); 0171 0172 //! values are separated with a "-" character 0173 void windowColorScheme(QString windowIdAndScheme); 0174 void updateDockItemBadge(QString identifier, QString value); 0175 0176 void unload(); 0177 0178 signals: 0179 void configurationShown(PlasmaQuick::ConfigView *configView); 0180 void viewLocationChanged(); 0181 void raiseViewsTemporaryChanged(); 0182 void availableScreenRectChangedFrom(Latte::View *origin); 0183 void availableScreenRegionChangedFrom(Latte::View *origin); 0184 void verticalUnityViewHasFocus(); 0185 0186 private slots: 0187 void alternativesVisibilityChanged(bool visible); 0188 void load(); 0189 0190 void onAboutToQuit(); 0191 0192 void onScreenAdded(QScreen *screen); 0193 void onScreenRemoved(QScreen *screen); 0194 void onScreenCountChanged(); 0195 void onScreenGeometryChanged(const QRect &geometry); 0196 void syncLatteViewsToScreens(); 0197 0198 private: 0199 void cleanConfig(); 0200 void qmlRegisterTypes() const; 0201 void setupWaylandIntegration(); 0202 0203 bool appletExists(uint containmentId, uint appletId) const; 0204 bool containmentExists(uint id) const; 0205 0206 int primaryScreenId() const; 0207 0208 QStringList containmentsIds(); 0209 QStringList appletsIds(); 0210 0211 Layout::GenericLayout *layout(QString name) const; 0212 CentralLayout *centralLayout(QString name) const; 0213 0214 private: 0215 0216 bool m_activitiesStarting{true}; 0217 bool m_defaultLayoutOnStartup{false}; //! this is used to enforce loading the default layout on startup 0218 bool m_inStartup{true}; //! this is used in order to identify when application is still in startup phase 0219 bool m_inQuit{false}; //! this is used in order to identify when application is in quit phase 0220 bool m_quitTimedEnded{false}; //! this is used on destructor in order to delay it and slide-out the views 0221 0222 //!it can be used on startup to change memory usage from command line 0223 int m_userSetMemoryUsage{ -1}; 0224 0225 QString m_layoutNameOnStartUp; 0226 QString m_startupAddViewTemplateName; 0227 QString m_importFullConfigurationFile; 0228 0229 QList<KDeclarative::QmlObjectSharedEngine *> m_alternativesObjects; 0230 0231 QTimer m_viewsScreenSyncTimer; 0232 0233 KActivities::Consumer *m_activitiesConsumer; 0234 QPointer<KAboutApplicationDialog> aboutDialog; 0235 0236 ScreenPool *m_screenPool{nullptr}; 0237 UniversalSettings *m_universalSettings{nullptr}; 0238 ViewSettingsFactory *m_viewSettingsFactory{nullptr}; 0239 GlobalShortcuts *m_globalShortcuts{nullptr}; 0240 0241 Indicator::Factory *m_indicatorFactory{nullptr}; 0242 Layouts::Manager *m_layoutsManager{nullptr}; 0243 Templates::Manager *m_templatesManager{nullptr}; 0244 0245 PlasmaExtended::ScreenGeometries *m_plasmaGeometries{nullptr}; 0246 PlasmaExtended::ScreenPool *m_plasmaScreenPool{nullptr}; 0247 PlasmaExtended::Theme *m_themeExtended{nullptr}; 0248 0249 WindowSystem::AbstractWindowInterface *m_wm{nullptr}; 0250 0251 PanelShadows *m_dialogShadows{nullptr}; 0252 0253 KWayland::Client::PlasmaShell *m_waylandCorona{nullptr}; 0254 0255 friend class GlobalShortcuts; 0256 friend class Layouts::Manager; 0257 friend class Layouts::Storage; 0258 }; 0259 0260 } 0261 0262 #endif // LATTECORONA_H