2017-03-18 13:21:17 +02: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/>.
*/
# ifndef GLOBALSETTINGS_H
# define GLOBALSETTINGS_H
# include "dockcorona.h"
# include "../liblattedock/dock.h"
2017-03-20 12:20:37 -05:00
# include <QFileDialog>
# include <QPointer>
2017-03-18 13:21:17 +02:00
# include <KConfigGroup>
# include <KSharedConfig>
class DockCorona ;
namespace Latte {
class GlobalSettings : public QObject {
Q_OBJECT
2017-03-18 14:16:32 +02:00
Q_PROPERTY ( bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged )
2017-03-18 13:21:17 +02:00
Q_PROPERTY ( bool exposeAltSession READ exposeAltSession WRITE setExposeAltSession NOTIFY exposeAltSessionChanged )
2017-06-05 21:13:54 +03:00
Q_PROPERTY ( bool syncLaunchers READ syncLaunchers WRITE setSyncLaunchers NOTIFY syncLaunchersChanged )
Q_PROPERTY ( QStringList globalLaunchers READ globalLaunchers WRITE setGlobalLaunchers NOTIFY globalLaunchersChanged )
2017-03-18 14:28:33 +02:00
Q_PROPERTY ( Latte : : Dock : : SessionType currentSession READ currentSession WRITE setCurrentSession NOTIFY currentSessionChanged )
2017-03-18 13:21:17 +02:00
Q_PROPERTY ( QAction * altSessionAction READ altSessionAction NOTIFY altSessionActionChanged )
2017-05-03 00:18:47 +03:00
Q_PROPERTY ( QAction * addWidgetsAction READ addWidgetsAction NOTIFY addWidgetsActionChanged )
2017-03-18 13:21:17 +02:00
public :
GlobalSettings ( QObject * parent = nullptr ) ;
~ GlobalSettings ( ) override ;
void load ( ) ;
2017-03-18 14:16:32 +02:00
bool autostart ( ) const ;
void setAutostart ( bool state ) ;
2017-03-18 13:21:17 +02:00
bool exposeAltSession ( ) const ;
void setExposeAltSession ( bool state ) ;
QAction * altSessionAction ( ) const ;
2017-06-05 21:13:54 +03:00
bool syncLaunchers ( ) const ;
void setSyncLaunchers ( bool sync ) ;
QStringList globalLaunchers ( ) const ;
void setGlobalLaunchers ( QStringList launchers ) ;
2017-05-03 00:18:47 +03:00
QAction * addWidgetsAction ( ) const ;
2017-03-18 14:28:33 +02:00
Latte : : Dock : : SessionType currentSession ( ) const ;
void setCurrentSession ( Latte : : Dock : : SessionType session ) ;
2017-04-23 12:14:44 +03:00
static bool importHelper ( const QString & fileName ) ;
2017-03-20 12:20:37 -05:00
Q_INVOKABLE void importConfiguration ( ) ;
Q_INVOKABLE void exportConfiguration ( ) ;
2017-04-23 17:26:36 -05:00
Q_INVOKABLE void importLayout ( const QString & name , const QString & file ) ;
2017-04-23 12:14:44 +03:00
Q_INVOKABLE QVariantList layouts ( ) ;
2017-03-20 12:20:37 -05:00
2017-03-18 13:21:17 +02:00
signals :
2017-05-03 00:18:47 +03:00
void addWidgetsActionChanged ( ) ;
2017-03-18 13:21:17 +02:00
void altSessionActionChanged ( ) ;
2017-06-05 21:13:54 +03:00
void autostartChanged ( ) ;
2017-04-24 16:56:34 +03:00
void clearLayoutSelection ( ) ;
2017-03-18 14:28:33 +02:00
void currentSessionChanged ( ) ;
2017-03-18 13:21:17 +02:00
void exposeAltSessionChanged ( ) ;
2017-06-05 21:13:54 +03:00
void globalLaunchersChanged ( ) ;
void syncLaunchersChanged ( ) ;
2017-03-18 13:21:17 +02:00
private slots :
2017-03-18 14:28:33 +02:00
void currentSessionChangedSlot ( Dock : : SessionType type ) ;
2017-03-18 13:21:17 +02:00
void enableAltSession ( bool enabled ) ;
2017-04-23 17:26:36 -05:00
void importLayoutInternal ( const QString & file ) ;
2017-06-05 21:33:08 +03:00
void loadLaunchers ( ) ;
2017-05-03 00:18:47 +03:00
void showWidgetsExplorer ( ) ;
2017-03-18 13:21:17 +02:00
private :
void save ( ) ;
2017-04-23 12:14:44 +03:00
void init ( ) ;
2017-04-23 22:34:29 +03:00
void initExtConfiguration ( ) ;
void loadExtConfiguration ( ) ;
void saveExtConfiguration ( ) ;
2017-03-18 13:21:17 +02:00
bool m_exposeAltSession { false } ;
2017-06-05 21:13:54 +03:00
bool m_syncLaunchers { false } ;
2017-05-03 00:18:47 +03:00
QAction * m_addWidgetsAction { nullptr } ;
2017-03-18 13:21:17 +02:00
QAction * m_altSessionAction { nullptr } ;
DockCorona * m_corona { nullptr } ;
2017-03-20 12:20:37 -05:00
QPointer < QFileDialog > m_fileDialog ;
2017-04-23 12:14:44 +03:00
QVariantList m_defaultLayouts ;
2017-04-23 22:34:29 +03:00
QVariantList m_userLayouts ;
QStringList m_userLayoutsFiles ;
2017-06-05 21:13:54 +03:00
QStringList m_globalLaunchers ;
2017-03-18 13:21:17 +02:00
KConfigGroup m_configGroup ;
2017-04-23 22:34:29 +03:00
KConfigGroup m_externalGroup ;
2017-03-18 13:21:17 +02:00
} ;
}
# endif // GLOBALSETTINGS_H