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/>.
*/
2018-12-06 15:35:34 +03:00
# ifndef LATTECORONA_H
# define LATTECORONA_H
2016-12-31 00:25:27 +03:00
2018-12-02 03:05:52 +03:00
// local
2020-04-24 14:52:16 +03:00
# include <coretypes.h>
2018-12-13 20:51:22 +03:00
# include "plasma/quick/configview.h"
2019-04-06 18:56:24 +03:00
# include "layout/storage.h"
2020-01-13 00:51:46 +03:00
# include "view/panelshadows_p.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>
2018-02-03 12:34:13 +03:00
# include <QTimer>
2018-12-02 03:05:52 +03:00
// Plasma
2018-02-03 12:34:13 +03:00
# 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>
2018-02-03 23:19:35 +03:00
namespace KDeclarative {
2019-02-18 18:46:53 +03:00
class QmlObjectSharedEngine ;
2018-02-03 23:19:35 +03:00
}
2017-01-29 08:16:28 +03:00
2017-06-16 00:56:55 +03:00
namespace Plasma {
class Corona ;
class Containment ;
class Types ;
}
2018-02-03 23:19:35 +03:00
namespace PlasmaQuick {
class ConfigView ;
}
2018-02-03 12:34:13 +03:00
namespace KActivities {
class Consumer ;
}
2017-04-25 19:18:49 +03:00
namespace KWayland {
namespace Client {
class PlasmaShell ;
}
}
2018-02-03 12:34:13 +03:00
namespace Latte {
2020-01-04 20:21:10 +03:00
class CentralLayout ;
2018-02-03 12:34:13 +03: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 18:49:09 +03: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 21:03:14 +03:00
namespace PlasmaExtended {
2020-02-22 15:30:02 +03:00
class ScreenGeometries ;
2018-12-13 21:55:03 +03:00
class ScreenPool ;
2018-12-13 21:03:14 +03:00
class Theme ;
}
2019-05-11 15:43:10 +03:00
namespace WindowSystem {
class AbstractWindowInterface ;
}
2018-02-03 12:34:13 +03:00
}
2016-12-31 00:25:27 +03:00
namespace Latte {
2018-12-06 15:35:34 +03:00
class Corona : public Plasma : : Corona
2018-07-03 22:15:45 +03:00
{
2016-12-31 00:25:27 +03:00
Q_OBJECT
2017-03-11 11:06:10 +03:00
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 :
2018-12-06 15:35:34 +03:00
Corona ( bool defaultLayoutOnStartup = false ,
2018-01-31 16:27:58 +03:00
QString layoutNameOnStartUp = QString ( ) ,
int userSetMemoryUsage = - 1 ,
QObject * parent = nullptr ) ;
2018-12-06 15:35:34 +03:00
virtual ~ Corona ( ) ;
2017-01-16 22:07:49 +03:00
2020-07-04 14:44:27 +03:00
bool inQuit ( ) const ;
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 ;
2018-01-04 19:20:04 +03: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 19:58:05 +03: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 19:20:04 +03:00
QRect availableScreenRectWithCriteria ( int id ,
2020-01-04 20:21:10 +03:00
QString forLayout = QString ( ) ,
2020-03-07 16:36:39 +03: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 22:07:49 +03:00
2020-01-02 11:32:31 +03:00
QRegion availableScreenRegionWithCriteria ( int id ,
QString forLayout = QString ( ) ,
2020-03-07 16:36:39 +03: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 22:10:58 +03:00
2016-12-31 00:25:27 +03:00
int screenForContainment ( const Plasma : : Containment * containment ) const override ;
2017-01-16 22:07:49 +03:00
2019-04-06 02:00:37 +03:00
KWayland : : Client : : PlasmaShell * waylandCoronaInterface ( ) const ;
2018-01-13 20:27:32 +03:00
KActivities : : Consumer * activitiesConsumer ( ) const ;
2019-02-03 01:10:07 +03:00
GlobalShortcuts * globalShortcuts ( ) const ;
2017-02-24 21:58:21 +03: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 ;
2018-12-13 21:55:03 +03:00
2019-03-23 18:49:09 +03:00
Indicator : : Factory * indicatorFactory ( ) const ;
2018-12-13 21:55:03 +03:00
PlasmaExtended : : ScreenPool * plasmaScreenPool ( ) const ;
2018-12-13 21:03:14 +03:00
PlasmaExtended : : Theme * themeExtended ( ) const ;
2017-02-24 21:58:21 +03:00
2019-05-11 15:43:10 +03:00
WindowSystem : : AbstractWindowInterface * wm ( ) const ;
2020-01-13 00:51:46 +03:00
PanelShadows * dialogShadows ( ) const ;
2020-03-18 14:33:28 +03: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 21:09:22 +03:00
void quitApplication ( ) ;
2018-02-07 00:14:44 +03:00
void switchToLayout ( QString layout ) ;
void showSettingsWindow ( int page ) ;
2019-02-12 22:21:11 +03:00
void setContextMenuView ( int id ) ;
2018-02-07 00:39:45 +03:00
QStringList contextMenuData ( ) ;
2018-02-07 00:14:44 +03:00
2016-12-31 00:25:27 +03:00
public slots :
2018-01-27 02:27:48 +03:00
void aboutApplication ( ) ;
2019-04-08 18:57:32 +03:00
void addViewForLayout ( QString layoutName ) ;
2017-03-11 11:06:10 +03:00
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 ) ;
2019-04-06 18:56:24 +03:00
void showAlternativesForApplet ( Plasma : : Applet * applet ) ;
2020-03-01 18:19:24 +03:00
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 ) ;
2017-04-11 20:23:43 +03:00
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 ) ;
2018-12-06 16:57:20 +03: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 22:07:49 +03:00
2017-01-07 16:27:26 +03:00
private slots :
2017-02-15 07:54:41 +03:00
void alternativesVisibilityChanged ( bool visible ) ;
2017-01-07 16:27:26 +03:00
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 ) ;
2017-02-26 03:43:41 +03:00
void screenCountChanged ( ) ;
2018-12-06 13:51:15 +03:00
void syncLatteViewsToScreens ( ) ;
2017-02-24 21:58:21 +03:00
2016-12-31 00:25:27 +03:00
private :
2017-01-21 21:08:47 +03:00
void cleanConfig ( ) ;
2017-03-08 00:26:09 +03:00
void qmlRegisterTypes ( ) const ;
2017-04-25 19:18:49 +03:00
void setupWaylandIntegration ( ) ;
2017-06-26 22:16:42 +03:00
2017-03-08 00:26:09 +03:00
bool appletExists ( uint containmentId , uint appletId ) const ;
2017-02-06 04:55:41 +03:00
bool containmentExists ( uint id ) const ;
2018-01-13 13:00:47 +03:00
2016-12-31 00:25:27 +03:00
int primaryScreenId ( ) const ;
2017-12-24 21:54:45 +03:00
2017-07-25 00:01:41 +03:00
QStringList containmentsIds ( ) ;
QStringList appletsIds ( ) ;
2017-01-16 22:07:49 +03:00
2020-03-01 18:19:24 +03:00
Layout : : GenericLayout * layout ( QString name ) const ;
2020-01-04 20:21:10 +03:00
CentralLayout * centralLayout ( QString name ) const ;
private :
2017-01-24 21:32:22 +03:00
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
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 16:57:20 +03:00
bool m_quitTimedEnded { false } ; //! this is used on destructor in order to delay it and slide-out the views
2017-01-24 21:32:22 +03:00
2018-01-31 16:27:58 +03:00
//!it can be used on startup to change memory usage from command line
int m_userSetMemoryUsage { - 1 } ;
2019-02-12 22:21:11 +03:00
int m_contextMenuViewId { - 1 } ;
2017-12-17 19:34:50 +03:00
QString m_layoutNameOnStartUp ;
2020-03-18 14:33:28 +03:00
QString m_importFullConfigurationFile ;
2017-12-17 19:34:50 +03:00
2019-02-18 18:46:53 +03:00
QList < KDeclarative : : QmlObjectSharedEngine * > m_alternativesObjects ;
2018-12-06 16:57:20 +03:00
QTimer m_viewsScreenSyncTimer ;
2017-03-01 21:49:21 +03:00
2020-03-18 18:39:19 +03:00
KActivities : : Consumer * m_activitiesConsumer ;
2017-01-29 08:16:28 +03:00
QPointer < KAboutApplicationDialog > aboutDialog ;
2017-02-24 21:58:21 +03: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 03:39:09 +03:00
GlobalShortcuts * m_globalShortcuts { nullptr } ;
2018-12-13 21:55:03 +03:00
2019-03-23 18:49:09 +03:00
Indicator : : Factory * m_indicatorFactory { nullptr } ;
2019-05-09 17:12:57 +03:00
Layouts : : Manager * m_layoutsManager { nullptr } ;
2019-03-23 18:49:09 +03:00
2020-02-22 15:30:02 +03:00
PlasmaExtended : : ScreenGeometries * m_plasmaGeometries { nullptr } ;
2018-12-13 21:55:03 +03:00
PlasmaExtended : : ScreenPool * m_plasmaScreenPool { nullptr } ;
2018-12-13 21:03:14 +03: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-13 00:51:46 +03:00
PanelShadows * m_dialogShadows { nullptr } ;
2018-12-06 15:35:34 +03: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 ;
2016-12-31 00:25:27 +03:00
} ;
}
2018-12-06 15:35:34 +03:00
# endif // LATTECORONA_H