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/>.
*/
2017-02-14 23:54:41 -05:00
# ifndef DOCKCORONA_H
# define DOCKCORONA_H
2016-12-30 16:25:27 -05:00
# include "dockview.h"
2017-03-18 13:21:17 +02:00
# include "globalsettings.h"
2017-06-04 01:58:03 +03:00
# include "globalshortcuts.h"
2017-07-02 15:02:07 +03:00
# include "layoutmanager.h"
# include "universalsettings.h"
2017-03-10 22:41:13 +02:00
# include "../liblattedock/dock.h"
2016-12-30 16:25:27 -05:00
# include <QObject>
2017-01-29 00:16:28 -05:00
# include <KAboutApplicationDialog>
2017-02-14 23:54:41 -05:00
# include <KDeclarative/QmlObject>
2017-01-29 00:16:28 -05:00
2017-02-24 20:58:21 +02:00
class ScreenPool ;
2017-03-18 13:21:17 +02:00
class GlobalSettings ;
2017-06-04 01:58:03 +03:00
class GlobalShortcuts ;
2017-07-02 16:12:58 +03:00
class UniversalSettings ;
class LayoutManager ;
2017-02-24 20:58:21 +02:00
2017-01-07 15:27:26 +02:00
namespace KActivities {
class Consumer ;
}
2017-06-15 16:56:55 -05:00
namespace Plasma {
class Corona ;
class Containment ;
class Types ;
}
2017-04-25 19:18:49 +03:00
namespace KWayland {
namespace Client {
class PlasmaShell ;
}
}
2016-12-30 16:25:27 -05:00
namespace Latte {
class DockCorona : public Plasma : : Corona {
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 :
2017-02-26 12:37:46 -05:00
DockCorona ( QObject * parent = nullptr ) ;
2016-12-30 16:25:27 -05:00
virtual ~ DockCorona ( ) ;
2017-01-16 14:07:49 -05:00
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 ;
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
QList < Plasma : : Types : : Location > freeEdges ( int screen ) const ;
2017-02-27 19:46:10 +02:00
QList < Plasma : : Types : : Location > freeEdges ( QScreen * screen ) const ;
2017-01-16 14:07:49 -05:00
2017-07-03 19:04:37 +03:00
void loadLatteLayout ( QString layoutPath ) ;
2017-06-26 22:16:42 +03:00
bool reloadLayout ( QString path ) ;
2017-03-03 17:23:37 +02:00
int docksCount ( ) const ;
2017-06-12 00:40:45 +03:00
int docksCount ( int screen ) const ;
int docksCount ( QScreen * screen ) const ;
2017-03-01 16:59:04 +02:00
int noDocksWithTasks ( ) const ;
2016-12-30 16:25:27 -05:00
int screenForContainment ( const Plasma : : Containment * containment ) const override ;
2017-01-16 14:07:49 -05:00
2017-06-20 20:01:18 +03:00
void addDock ( Plasma : : Containment * containment , int expDockScreen = - 1 ) ;
2017-03-08 21:00:09 +02:00
void recreateDock ( Plasma : : Containment * containment ) ;
2017-06-05 23:52:49 +03:00
void copyDock ( Plasma : : Containment * containment ) ;
2017-01-16 14:07:49 -05:00
2017-01-29 00:16:28 -05:00
void aboutApplication ( ) ;
2017-01-05 00:28:25 +02:00
void closeApplication ( ) ;
2017-01-16 14:07:49 -05:00
2017-02-24 20:58:21 +02:00
ScreenPool * screenPool ( ) const ;
2017-03-18 13:21:17 +02:00
GlobalSettings * globalSettings ( ) const ;
2017-07-02 16:12:58 +03:00
UniversalSettings * universalSettings ( ) const ;
LayoutManager * layoutManager ( ) const ;
2017-02-24 20:58:21 +02:00
2017-04-25 19:18:49 +03:00
KWayland : : Client : : PlasmaShell * waylandDockCoronaInterface ( ) const ;
2016-12-30 16:25:27 -05:00
public slots :
2017-03-11 10:06:10 +02:00
void activateLauncherMenu ( ) ;
2016-12-30 16:25:27 -05:00
void loadDefaultLayout ( ) override ;
2017-01-05 00:28:25 +02:00
void dockContainmentDestroyed ( QObject * cont ) ;
2017-04-11 20:23:43 +03:00
void updateDockItemBadge ( QString identifier , QString value ) ;
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
signals :
void configurationShown ( PlasmaQuick : : ConfigView * configView ) ;
2017-01-16 13:24:46 -05:00
void docksCountChanged ( ) ;
2017-01-22 13:29:40 +02:00
void dockLocationChanged ( ) ;
2017-03-07 23:26:09 +02:00
void raiseDocksTemporaryChanged ( ) ;
2017-01-16 14:07:49 -05:00
2017-01-07 15:27:26 +02:00
private slots :
2017-01-15 23:59:15 +02:00
void destroyedChanged ( bool destroyed ) ;
2017-02-14 23:54:41 -05:00
void showAlternativesForApplet ( Plasma : : Applet * applet ) ;
void alternativesVisibilityChanged ( bool visible ) ;
2017-01-07 15:27:26 +02:00
void load ( ) ;
2017-06-26 23:43:25 +03:00
void updateConfigs ( ) ;
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 ( ) ;
2017-02-27 22:52:22 +02:00
void syncDockViews ( ) ;
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
void unload ( ) ;
2017-03-07 23:26:09 +02:00
bool appletExists ( uint containmentId , uint appletId ) const ;
2017-03-01 16:59:04 +02:00
bool containmentContainsTasks ( Plasma : : Containment * cont ) ;
2017-02-05 20:55:41 -05:00
bool containmentExists ( uint id ) const ;
2017-03-01 16:59:04 +02:00
bool heuresticForLoadingDockWithTasks ( ) ;
2017-07-03 10:55:52 +03:00
int noOfDocks ( ) ;
2016-12-30 16:25:27 -05:00
int primaryScreenId ( ) const ;
2017-01-16 14:07:49 -05:00
2017-01-24 20:32:22 +02:00
bool m_activitiesStarting { true } ;
2017-03-02 18:07:29 +02:00
//! this is used to check if a dock with tasks in it will be loaded on startup
2017-03-01 16:59:04 +02:00
bool m_tasksWillBeLoaded { false } ;
2017-03-02 18:07:29 +02:00
//! this is used to record the first dock having tasks in it. It is used
//! to specify which dock will be loaded on startup if a case that no "dock
//! with tasks" will be loaded otherwise. Currently the older one dock wins
int m_firstContainmentWithTasks { - 1 } ;
2017-01-24 20:32:22 +02:00
2017-06-26 22:16:42 +03:00
QString m_layoutDir ;
2017-03-10 22:41:13 +02:00
2017-01-05 00:28:25 +02:00
QHash < const Plasma : : Containment * , DockView * > m_dockViews ;
2017-01-15 23:59:15 +02:00
QHash < const Plasma : : Containment * , DockView * > m_waitingDockViews ;
2017-02-14 23:54:41 -05:00
QList < KDeclarative : : QmlObject * > m_alternativesObjects ;
2017-01-16 14:07:49 -05:00
2017-03-01 20:49:21 +02:00
QTimer m_docksScreenSyncTimer ;
2017-01-07 15:27:26 +02:00
KActivities : : Consumer * m_activityConsumer ;
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 } ;
GlobalSettings * m_globalSettings { 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-15 16:56:55 -05: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 ;
2017-07-18 21:18:33 +03:00
friend class LayoutManager ;
2016-12-30 16:25:27 -05:00
} ;
}
2017-02-14 23:54:41 -05:00
# endif // DOCKCORONA_H