2017-01-02 17:05:30 -05: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/>.
*/
2018-12-06 14:35:34 +02:00
# ifndef LATTECORONA_H
# define LATTECORONA_H
2016-12-30 16:25:27 -05:00
2018-12-02 02:05:52 +02:00
// local
2020-04-24 14:52:16 +03:00
# include <coretypes.h>
2018-12-13 19:51:22 +02:00
# include "plasma/quick/configview.h"
2019-04-06 18:56:24 +03:00
# include "layout/storage.h"
2020-08-18 01:44:10 +03:00
# include "layouts/storage.h"
2020-01-12 23:51:46 +02:00
# include "view/panelshadows_p.h"
2016-12-30 16:25:27 -05:00
2018-12-02 02:05:52 +02:00
// Qt
2016-12-30 16:25:27 -05:00
# include <QObject>
2018-02-03 11:34:13 +02:00
# include <QTimer>
2018-12-02 02:05:52 +02:00
// Plasma
2018-02-03 11:34:13 +02:00
# include <Plasma/Corona>
2016-12-30 16:25:27 -05:00
2018-12-02 02:05:52 +02:00
// KDE
2017-01-29 00:16:28 -05:00
# include <KAboutApplicationDialog>
2018-02-03 22:19:35 +02:00
namespace KDeclarative {
2019-02-18 17:46:53 +02:00
class QmlObjectSharedEngine ;
2018-02-03 22:19:35 +02:00
}
2017-01-29 00:16:28 -05:00
2017-06-15 16:56:55 -05:00
namespace Plasma {
class Corona ;
class Containment ;
class Types ;
}
2018-02-03 22:19:35 +02:00
namespace PlasmaQuick {
class ConfigView ;
}
2018-02-03 11:34:13 +02:00
namespace KActivities {
class Consumer ;
}
2017-04-25 19:18:49 +03:00
namespace KWayland {
namespace Client {
class PlasmaShell ;
}
}
2018-02-03 11:34:13 +02:00
namespace Latte {
2020-01-04 19:21:10 +02:00
class CentralLayout ;
2018-02-03 11:34:13 +02:00
class ScreenPool ;
class GlobalShortcuts ;
class UniversalSettings ;
2019-04-12 18:55:45 +03:00
class View ;
2020-06-21 13:42:20 +03:00
class ViewSettingsFactory ;
2019-03-23 17:49:09 +02:00
namespace Indicator {
class Factory ;
}
2019-04-06 02:00:37 +03:00
namespace Layout {
2019-04-08 18:57:32 +03:00
class GenericLayout ;
2019-04-06 18:56:24 +03:00
class Storage ;
2019-04-06 02:00:37 +03:00
}
2019-05-09 17:12:57 +03:00
namespace Layouts {
2019-05-09 17:40:53 +03:00
class LaunchersSignals ;
2019-05-09 17:12:57 +03:00
class Manager ;
}
2018-12-13 20:03:14 +02:00
namespace PlasmaExtended {
2020-02-22 14:30:02 +02:00
class ScreenGeometries ;
2018-12-13 20:55:03 +02:00
class ScreenPool ;
2018-12-13 20:03:14 +02:00
class Theme ;
}
2020-08-12 12:02:46 +03:00
namespace Templates {
class Manager ;
}
2019-05-11 15:43:10 +03:00
namespace WindowSystem {
class AbstractWindowInterface ;
}
2018-02-03 11:34:13 +02:00
}
2016-12-30 16:25:27 -05:00
namespace Latte {
2018-12-06 14:35:34 +02:00
class Corona : public Plasma : : Corona
2018-07-03 22:15:45 +03:00
{
2016-12-30 16:25:27 -05:00
Q_OBJECT
2017-03-11 10:06:10 +02:00
Q_CLASSINFO ( " D-Bus Interface " , " org.kde.LatteDock " )
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
public :
2018-12-06 14:35:34 +02:00
Corona ( bool defaultLayoutOnStartup = false ,
2018-01-31 15:27:58 +02:00
QString layoutNameOnStartUp = QString ( ) ,
int userSetMemoryUsage = - 1 ,
QObject * parent = nullptr ) ;
2018-12-06 14:35:34 +02:00
virtual ~ Corona ( ) ;
2017-01-16 14:07:49 -05:00
2020-07-04 14:44:27 +03:00
bool inQuit ( ) const ;
2016-12-30 16:25:27 -05:00
int numScreens ( ) const override ;
QRect screenGeometry ( int id ) const override ;
QRegion availableScreenRegion ( int id ) const override ;
QRect availableScreenRect ( int id ) const override ;
2018-01-04 18:20:04 +02:00
//! 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
2020-03-07 18:58:05 +02:00
//! arguments mean that all choices are accepted in calculations. ignoreExternalPanels means that
//! external panels should be not considered in the calculations
2018-01-04 18:20:04 +02:00
QRect availableScreenRectWithCriteria ( int id ,
2020-01-04 19:21:10 +02:00
QString forLayout = QString ( ) ,
2020-03-07 15:36:39 +02:00
QList < Types : : Visibility > ignoreModes = QList < Types : : Visibility > ( ) ,
QList < Plasma : : Types : : Location > ignoreEdges = QList < Plasma : : Types : : Location > ( ) ,
2020-04-12 13:41:49 +03:00
bool ignoreExternalPanels = true ,
bool desktopUse = false ) const ;
2017-01-16 14:07:49 -05:00
2020-01-02 10:32:31 +02:00
QRegion availableScreenRegionWithCriteria ( int id ,
QString forLayout = QString ( ) ,
2020-03-07 15:36:39 +02:00
QList < Types : : Visibility > ignoreModes = QList < Types : : Visibility > ( ) ,
QList < Plasma : : Types : : Location > ignoreEdges = QList < Plasma : : Types : : Location > ( ) ,
2020-04-12 13:41:49 +03:00
bool ignoreExternalPanels = true ,
bool desktopUse = false ) const ;
2018-01-13 21:10:58 +02:00
2016-12-30 16:25:27 -05:00
int screenForContainment ( const Plasma : : Containment * containment ) const override ;
2017-01-16 14:07:49 -05:00
2019-04-06 02:00:37 +03:00
KWayland : : Client : : PlasmaShell * waylandCoronaInterface ( ) const ;
2018-01-13 19:27:32 +02:00
KActivities : : Consumer * activitiesConsumer ( ) const ;
2019-02-03 00:10:07 +02:00
GlobalShortcuts * globalShortcuts ( ) const ;
2017-02-24 20:58:21 +02:00
ScreenPool * screenPool ( ) const ;
2017-07-02 16:12:58 +03:00
UniversalSettings * universalSettings ( ) const ;
2020-06-21 13:42:20 +03:00
ViewSettingsFactory * viewSettingsFactory ( ) const ;
2019-05-11 15:43:10 +03:00
Layouts : : Manager * layoutsManager ( ) const ;
2020-08-12 12:02:46 +03:00
Templates : : Manager * templatesManager ( ) const ;
2018-12-13 20:55:03 +02:00
2019-03-23 17:49:09 +02:00
Indicator : : Factory * indicatorFactory ( ) const ;
2018-12-13 20:55:03 +02:00
PlasmaExtended : : ScreenPool * plasmaScreenPool ( ) const ;
2018-12-13 20:03:14 +02:00
PlasmaExtended : : Theme * themeExtended ( ) const ;
2017-02-24 20:58:21 +02:00
2019-05-11 15:43:10 +03:00
WindowSystem : : AbstractWindowInterface * wm ( ) const ;
2020-01-12 23:51:46 +02:00
PanelShadows * dialogShadows ( ) const ;
2020-03-18 13:33:28 +02:00
//! Needs to be called in order to import and load application properly after application
//! finished all its exit operations
void importFullConfiguration ( const QString & file ) ;
//! these functions are used from context menu through containmentactions
2020-03-05 20:09:22 +02:00
void quitApplication ( ) ;
2018-02-06 23:14:44 +02:00
void switchToLayout ( QString layout ) ;
void showSettingsWindow ( int page ) ;
2019-02-12 21:21:11 +02:00
void setContextMenuView ( int id ) ;
2018-02-06 23:39:45 +02:00
QStringList contextMenuData ( ) ;
2018-02-06 23:14:44 +02:00
2016-12-30 16:25:27 -05:00
public slots :
2018-01-27 01:27:48 +02:00
void aboutApplication ( ) ;
2019-04-08 18:57:32 +03:00
void addViewForLayout ( QString layoutName ) ;
2017-03-11 10:06:10 +02:00
void activateLauncherMenu ( ) ;
2016-12-30 16:25:27 -05:00
void loadDefaultLayout ( ) override ;
2019-02-18 17:46:53 +02:00
void setBackgroundFromBroadcast ( QString activity , QString screenName , QString filename ) ;
void setBroadcastedBackgroundsEnabled ( QString activity , QString screenName , bool enabled ) ;
2019-04-06 18:56:24 +03:00
void showAlternativesForApplet ( Plasma : : Applet * applet ) ;
2020-03-01 17:19:24 +02:00
void toggleHiddenState ( QString layoutName , QString screenName , int screenEdge ) ;
2019-02-18 17:46:53 +02:00
//! values are separated with a "-" character
void windowColorScheme ( QString windowIdAndScheme ) ;
2017-04-11 20:23:43 +03:00
void updateDockItemBadge ( QString identifier , QString value ) ;
2019-02-18 17:46:53 +02:00
2017-07-20 23:45:59 +03:00
void unload ( ) ;
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
signals :
void configurationShown ( PlasmaQuick : : ConfigView * configView ) ;
2018-12-06 15:57:20 +02:00
void viewLocationChanged ( ) ;
void raiseViewsTemporaryChanged ( ) ;
2019-04-12 18:55:45 +03:00
void availableScreenRectChangedFrom ( Latte : : View * origin ) ;
void availableScreenRegionChangedFrom ( Latte : : View * origin ) ;
2020-05-09 12:26:33 +03:00
void verticalUnityViewHasFocus ( ) ;
2017-01-16 14:07:49 -05:00
2017-01-07 15:27:26 +02:00
private slots :
2017-02-14 23:54:41 -05:00
void alternativesVisibilityChanged ( bool visible ) ;
2017-01-07 15:27:26 +02:00
void load ( ) ;
2017-01-16 14:07:49 -05:00
2017-02-24 20:58:21 +02:00
void addOutput ( QScreen * screen ) ;
void primaryOutputChanged ( ) ;
void screenRemoved ( QScreen * screen ) ;
2017-02-26 02:43:41 +02:00
void screenCountChanged ( ) ;
2018-12-06 12:51:15 +02:00
void syncLatteViewsToScreens ( ) ;
2017-02-24 20:58:21 +02:00
2016-12-30 16:25:27 -05:00
private :
2017-01-21 20:08:47 +02:00
void cleanConfig ( ) ;
2017-03-07 23:26:09 +02:00
void qmlRegisterTypes ( ) const ;
2017-04-25 19:18:49 +03:00
void setupWaylandIntegration ( ) ;
2017-06-26 22:16:42 +03:00
2017-03-07 23:26:09 +02:00
bool appletExists ( uint containmentId , uint appletId ) const ;
2017-02-05 20:55:41 -05:00
bool containmentExists ( uint id ) const ;
2018-01-13 12:00:47 +02:00
2016-12-30 16:25:27 -05:00
int primaryScreenId ( ) const ;
2017-12-24 20:54:45 +02:00
2017-07-25 00:01:41 +03:00
QStringList containmentsIds ( ) ;
QStringList appletsIds ( ) ;
2017-01-16 14:07:49 -05:00
2020-03-01 17:19:24 +02:00
Layout : : GenericLayout * layout ( QString name ) const ;
2020-01-04 19:21:10 +02:00
CentralLayout * centralLayout ( QString name ) const ;
private :
2017-01-24 20:32:22 +02:00
bool m_activitiesStarting { true } ;
2018-02-03 15:44:37 +02:00
bool m_defaultLayoutOnStartup { false } ; //! this is used to enforce loading the default layout on startup
2020-07-04 14:44:27 +03:00
bool m_inQuit { false } ; //! this is used in order to identify when application is in quit phase
2018-12-06 15:57:20 +02:00
bool m_quitTimedEnded { false } ; //! this is used on destructor in order to delay it and slide-out the views
2017-01-24 20:32:22 +02:00
2018-01-31 15:27:58 +02:00
//!it can be used on startup to change memory usage from command line
int m_userSetMemoryUsage { - 1 } ;
2019-02-12 21:21:11 +02:00
int m_contextMenuViewId { - 1 } ;
2017-12-17 18:34:50 +02:00
QString m_layoutNameOnStartUp ;
2020-03-18 13:33:28 +02:00
QString m_importFullConfigurationFile ;
2017-12-17 18:34:50 +02:00
2019-02-18 17:46:53 +02:00
QList < KDeclarative : : QmlObjectSharedEngine * > m_alternativesObjects ;
2018-12-06 15:57:20 +02:00
QTimer m_viewsScreenSyncTimer ;
2017-03-01 20:49:21 +02:00
2020-03-18 17:39:19 +02:00
KActivities : : Consumer * m_activitiesConsumer ;
2017-01-29 00:16:28 -05:00
QPointer < KAboutApplicationDialog > aboutDialog ;
2017-02-24 20:58:21 +02:00
2017-06-04 01:58:03 +03:00
ScreenPool * m_screenPool { nullptr } ;
2017-07-02 15:02:07 +03:00
UniversalSettings * m_universalSettings { nullptr } ;
2020-06-21 13:42:20 +03:00
ViewSettingsFactory * m_viewSettingsFactory { nullptr } ;
2019-02-10 02:39:09 +02:00
GlobalShortcuts * m_globalShortcuts { nullptr } ;
2018-12-13 20:55:03 +02:00
2019-03-23 17:49:09 +02:00
Indicator : : Factory * m_indicatorFactory { nullptr } ;
2019-05-09 17:12:57 +03:00
Layouts : : Manager * m_layoutsManager { nullptr } ;
2020-08-12 12:02:46 +03:00
Templates : : Manager * m_templatesManager { nullptr } ;
2019-03-23 17:49:09 +02:00
2020-02-22 14:30:02 +02:00
PlasmaExtended : : ScreenGeometries * m_plasmaGeometries { nullptr } ;
2018-12-13 20:55:03 +02:00
PlasmaExtended : : ScreenPool * m_plasmaScreenPool { nullptr } ;
2018-12-13 20:03:14 +02:00
PlasmaExtended : : Theme * m_themeExtended { nullptr } ;
2017-06-04 01:58:03 +03:00
2019-05-11 15:43:10 +03:00
WindowSystem : : AbstractWindowInterface * m_wm { nullptr } ;
2020-01-12 23:51:46 +02:00
PanelShadows * m_dialogShadows { nullptr } ;
2018-12-06 14:35:34 +02:00
KWayland : : Client : : PlasmaShell * m_waylandCorona { nullptr } ;
2017-04-25 19:18:49 +03:00
2017-06-04 01:58:03 +03:00
friend class GlobalShortcuts ;
2019-04-06 18:56:24 +03:00
friend class Layout : : Storage ;
2019-05-09 17:40:53 +03:00
friend class Layouts : : LaunchersSignals ;
2019-05-09 17:12:57 +03:00
friend class Layouts : : Manager ;
2020-08-18 01:44:10 +03:00
friend class Layouts : : Storage ;
2016-12-30 16:25:27 -05:00
} ;
}
2018-12-06 14:35:34 +02:00
# endif // LATTECORONA_H