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/>.
*/
2017-02-15 07:54:41 +03:00
# ifndef DOCKCORONA_H
# define DOCKCORONA_H
2016-12-31 00:25:27 +03:00
2017-03-10 23:41:13 +03:00
# include "../liblattedock/dock.h"
2016-12-31 00:25:27 +03:00
# include <QObject>
2018-02-03 12:34:13 +03:00
# include <QTimer>
# include <Plasma/Corona>
2018-02-03 23:19:35 +03:00
//#include <PlasmaQuick/ConfigView>
2016-12-31 00:25:27 +03:00
2017-01-29 08:16:28 +03:00
# include <KAboutApplicationDialog>
2018-02-03 23:19:35 +03:00
//#include <KDeclarative/QmlObject>
namespace KDeclarative {
class QmlObject ;
}
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 {
class ScreenPool ;
class GlobalShortcuts ;
class UniversalSettings ;
class LayoutManager ;
class LaunchersSignals ;
}
2016-12-31 00:25:27 +03:00
namespace Latte {
class DockCorona : public Plasma : : Corona {
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-01-31 16:27:58 +03:00
DockCorona ( bool defaultLayoutOnStartup = false ,
QString layoutNameOnStartUp = QString ( ) ,
int userSetMemoryUsage = - 1 ,
QObject * parent = nullptr ) ;
2016-12-31 00:25:27 +03:00
virtual ~ DockCorona ( ) ;
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 ;
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
//! arguments mean that all choices are accepted in calculations
QRect availableScreenRectWithCriteria ( int id ,
QList < Dock : : Visibility > modes = QList < Dock : : Visibility > ( ) ,
QList < Plasma : : Types : : Location > edges = QList < Plasma : : Types : : Location > ( ) ) const ;
2017-01-16 22:07:49 +03:00
2018-01-13 22:10:58 +03:00
QRegion availableScreenRegionWithCriteria ( int id , QString forLayout = QString ( ) ) 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
2017-03-08 22:00:09 +03:00
void recreateDock ( Plasma : : Containment * containment ) ;
2017-01-16 22:07:49 +03:00
2017-01-05 01:28:25 +03:00
void closeApplication ( ) ;
2017-01-16 22:07:49 +03:00
2018-01-13 20:27:32 +03:00
KActivities : : Consumer * activitiesConsumer ( ) const ;
2017-02-24 21:58:21 +03:00
ScreenPool * screenPool ( ) const ;
2017-07-02 16:12:58 +03:00
UniversalSettings * universalSettings ( ) const ;
LayoutManager * layoutManager ( ) const ;
2017-02-24 21:58:21 +03:00
2017-04-25 19:18:49 +03:00
KWayland : : Client : : PlasmaShell * waylandDockCoronaInterface ( ) const ;
2018-02-07 00:39:45 +03:00
//! these functions are used from context menu through containmentactions
2018-02-07 00:14:44 +03:00
void switchToLayout ( QString layout ) ;
void showSettingsWindow ( int page ) ;
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 ( ) ;
2017-03-11 11:06:10 +03:00
void activateLauncherMenu ( ) ;
2016-12-31 00:25:27 +03:00
void loadDefaultLayout ( ) override ;
2017-04-11 20:23:43 +03:00
void updateDockItemBadge ( QString identifier , QString value ) ;
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 ) ;
2017-01-16 21:24:46 +03:00
void docksCountChanged ( ) ;
2017-01-22 14:29:40 +03:00
void dockLocationChanged ( ) ;
2017-03-08 00:26:09 +03:00
void raiseDocksTemporaryChanged ( ) ;
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 ) ;
2018-02-03 16:44:37 +03:00
void showAlternativesForApplet ( Plasma : : Applet * applet ) ;
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-01-07 14:50:27 +03:00
void syncDockViewsToScreens ( ) ;
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
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
bool m_quitTimedEnded { false } ; //! this is used on destructor in order to delay it and slide-out the docks
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 } ;
2017-12-17 19:34:50 +03:00
QString m_layoutNameOnStartUp ;
2017-02-15 07:54:41 +03:00
QList < KDeclarative : : QmlObject * > m_alternativesObjects ;
2017-01-16 22:07:49 +03:00
2017-03-01 21:49:21 +03:00
QTimer m_docksScreenSyncTimer ;
2017-01-07 16:27:26 +03:00
KActivities : : Consumer * m_activityConsumer ;
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 } ;
GlobalShortcuts * m_globalShortcuts { nullptr } ;
2017-07-02 15:02:07 +03:00
UniversalSettings * m_universalSettings { nullptr } ;
LayoutManager * m_layoutManager { nullptr } ;
2017-06-04 01:58:03 +03:00
2017-06-16 00:56:55 +03:00
KWayland : : Client : : PlasmaShell * m_waylandDockCorona { nullptr } ;
2017-04-25 19:18:49 +03:00
2017-06-04 01:58:03 +03:00
friend class GlobalShortcuts ;
2018-01-07 20:59:18 +03:00
friend class Layout ;
2017-07-18 21:18:33 +03:00
friend class LayoutManager ;
2017-07-31 03:53:39 +03:00
friend class LaunchersSignals ;
2016-12-31 00:25:27 +03:00
} ;
}
2017-02-15 07:54:41 +03:00
# endif // DOCKCORONA_H