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-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
2016-12-30 16:25:27 -05:00
namespace Plasma {
class Corona ;
class Containment ;
class Types ;
}
2017-02-24 20:58:21 +02:00
class ScreenPool ;
2017-01-07 15:27:26 +02:00
namespace KActivities {
class Consumer ;
}
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-01-15 23:59:15 +02:00
int docksCount ( int screen ) const ;
2017-03-03 17:23:37 +02:00
int docksCount ( ) 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
2016-12-30 16:25:27 -05:00
void addDock ( Plasma : : Containment * containment ) ;
2017-03-08 21:00:09 +02:00
void recreateDock ( Plasma : : Containment * containment ) ;
2017-01-16 14:07:49 -05:00
2017-03-07 19:22:15 +02:00
bool autostart ( ) const ;
2017-03-07 23:26:09 +02:00
void setAutostart ( bool state ) ;
2017-03-10 22:41:13 +02:00
Dock : : SessionType currentSession ( ) ;
void setCurrentSession ( Dock : : SessionType session ) ;
void switchToSession ( Dock : : SessionType session ) ;
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 ;
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-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
signals :
2017-03-07 19:22:15 +02:00
void autostartChanged ( ) ;
2016-12-30 16:25:27 -05:00
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-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 loadConfig ( ) ;
void saveConfig ( ) ;
void qmlRegisterTypes ( ) const ;
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-03-10 22:41:13 +02:00
int noDocksForSession ( Dock : : SessionType session ) ;
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-10 22:41:13 +02:00
//! used to initialize the docks when changing sessions
bool m_waitingSessionDocksCreation { false } ;
//! used to enable/disable raise on activity/desktop changed
2017-03-07 23:26:09 +02:00
bool m_raiseDocksTemporary { false } ;
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-03-10 22:41:13 +02:00
Dock : : SessionType m_session { Dock : : DefaultSession } ;
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
ScreenPool * m_screenPool ;
2016-12-30 16:25:27 -05:00
} ;
}
2017-02-14 23:54:41 -05:00
# endif // DOCKCORONA_H