2019-05-11 03:11:50 +03:00
/*
* Copyright 2019 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/>.
*/
# ifndef LAYOUTSSYNCHRONIZER_H
# define LAYOUTSSYNCHRONIZER_H
// Qt
# include <QObject>
# include <QHash>
# include <QTimer>
namespace Latte {
class CentralLayout ;
class View ;
namespace Layout {
class GenericLayout ;
}
namespace Layouts {
class Manager ;
}
}
2019-06-15 21:38:07 +03:00
namespace Plasma {
class Containment ;
}
2019-05-11 03:11:50 +03:00
namespace KActivities {
class Controller ;
}
namespace Latte {
namespace Layouts {
2020-08-25 16:09:51 +03:00
//! This is a Layouts map in the following structure:
//! ACTIVITY ID -> Layout Names for that activity
2020-08-25 18:07:24 +03:00
typedef QHash < QString , QStringList > AssignedLayoutsHash ;
2019-05-11 09:23:14 +03:00
//! Layouts::Synchronizer is a very IMPORTANT class which is responsible
//! for all ACTIVE layouts, meaning layouts that have been loaded
//! in memory.
//!
//! The main task of Synchronizer is to load/unload layouts based
//! on "user preferences"/"activities settings"/"application current
//! phase" (e.g. startup/closing)
//!
2019-05-11 03:11:50 +03:00
class Synchronizer : public QObject {
Q_OBJECT
public :
Synchronizer ( QObject * parent ) ;
~ Synchronizer ( ) override ;
void loadLayouts ( ) ;
void unloadLayouts ( ) ;
void hideAllViews ( ) ;
void pauseLayout ( QString layoutName ) ;
void syncActiveLayoutsToOriginalFiles ( ) ;
void syncLatteViewsToScreens ( ) ;
2020-08-25 18:07:24 +03:00
void syncMultipleLayoutsToActivities ( ) ;
2019-05-11 03:11:50 +03:00
bool latteViewExists ( Latte : : View * view ) const ;
bool layoutExists ( QString layoutName ) const ;
//! switch to specified layout, default previousMemoryUsage means that it didn't change
bool switchToLayout ( QString layoutName , int previousMemoryUsage = - 1 ) ;
int centralLayoutPos ( QString id ) const ;
QStringList centralLayoutsNames ( ) ;
2020-08-27 17:10:13 +03:00
QStringList currentLayoutsNames ( ) const ;
2019-05-11 03:11:50 +03:00
QStringList layouts ( ) const ;
QStringList menuLayouts ( ) const ;
void setMenuLayouts ( QStringList layouts ) ;
QStringList activities ( ) ;
2020-08-27 16:11:19 +03:00
QStringList freeActivities ( ) ;
2019-05-11 03:11:50 +03:00
QStringList runningActivities ( ) ;
2020-08-27 16:11:19 +03:00
QStringList freeRunningActivities ( ) ; //! These are activities that haven't been assigned to specific layout
2019-05-11 03:11:50 +03:00
2019-06-15 21:38:07 +03:00
Latte : : View * viewForContainment ( Plasma : : Containment * containment ) ;
2020-08-25 19:30:33 +03:00
Latte : : View * viewForContainment ( uint id ) ;
QList < CentralLayout * > currentLayouts ( ) const ;
QList < Latte : : View * > currentViews ( ) const ;
QList < Latte : : View * > currentViewsWithPlasmaShortcuts ( ) const ;
QList < Latte : : View * > sortedCurrentViews ( ) const ;
2020-08-25 22:15:39 +03:00
QList < Latte : : View * > viewsBasedOnActivityId ( const QString & id ) const ;
2019-06-15 21:38:07 +03:00
2020-08-25 22:15:39 +03:00
CentralLayout * centralLayout ( QString layoutname ) const ;
Layout : : GenericLayout * layout ( QString layoutname ) const ;
QList < CentralLayout * > centralLayoutsForActivity ( const QString activityid ) const ;
2019-05-11 03:11:50 +03:00
2020-03-16 18:17:17 +02:00
KActivities : : Controller * activitiesController ( ) const ;
2020-08-26 20:54:44 +03:00
public slots :
void updateKWinDisabledBorders ( ) ;
2019-05-11 03:11:50 +03:00
signals :
void centralLayoutsChanged ( ) ;
void layoutsChanged ( ) ;
void menuLayoutsChanged ( ) ;
void runningActicitiesChanged ( ) ;
void currentLayoutIsSwitching ( QString layoutName ) ;
private slots :
2020-08-26 20:54:44 +03:00
void onCurrentActivityChanged ( const QString & id ) ;
2020-08-13 21:28:52 +03:00
void onLayoutAdded ( const QString & layoutpath ) ;
2019-05-11 03:11:50 +03:00
private :
void addLayout ( CentralLayout * layout ) ;
void unloadCentralLayout ( CentralLayout * layout ) ;
2020-08-25 18:07:24 +03:00
bool isAssigned ( QString layoutName ) const ;
2019-05-11 03:11:50 +03:00
QString layoutPath ( QString layoutName ) ;
private :
bool m_multipleModeInitialized { false } ;
2020-08-13 22:23:59 +03:00
bool m_isLoaded { false } ;
2019-05-11 03:11:50 +03:00
QStringList m_layouts ;
QStringList m_menuLayouts ;
2020-08-25 18:07:24 +03:00
AssignedLayoutsHash m_assignedLayouts ;
2019-05-11 03:11:50 +03:00
QList < CentralLayout * > m_centralLayouts ;
Layouts : : Manager * m_manager ;
KActivities : : Controller * m_activitiesController ;
} ;
}
}
# endif