2017-07-02 15:02:07 +03:00
/*
* Copyright 2017 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 UNIVERSALSETTINGS_H
# define UNIVERSALSETTINGS_H
# include <QObject>
2017-07-02 16:12:58 +03:00
# include <KConfigGroup>
# include <KSharedConfig>
2017-07-03 10:41:59 +03:00
# include "layoutsettings.h"
2017-07-02 15:02:07 +03:00
namespace Latte {
2017-07-02 15:06:35 +03:00
//! This class holds all the settings that are universally available
//! independent of layouts
2017-07-02 15:02:07 +03:00
class UniversalSettings : public QObject {
Q_OBJECT
2017-07-04 15:05:54 +03:00
Q_PROPERTY ( bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged )
2017-07-02 15:02:07 +03:00
2017-07-03 10:41:59 +03:00
Q_PROPERTY ( QString currentLayoutName READ currentLayoutName WRITE setCurrentLayoutName NOTIFY currentLayoutNameChanged )
2017-07-02 15:02:07 +03:00
public :
2017-07-02 16:12:58 +03:00
UniversalSettings ( KSharedConfig : : Ptr config , QObject * parent = nullptr ) ;
2017-07-02 15:02:07 +03:00
~ UniversalSettings ( ) override ;
2017-07-02 16:12:58 +03:00
2017-07-02 20:19:18 +03:00
void load ( ) ;
2017-07-04 15:05:54 +03:00
bool autostart ( ) const ;
void setAutostart ( bool state ) ;
2017-07-02 20:19:18 +03:00
int version ( ) const ;
void setVersion ( int ver ) ;
2017-07-03 10:41:59 +03:00
QString currentLayoutName ( ) const ;
void setCurrentLayoutName ( QString layoutName ) ;
2017-07-19 21:36:05 +03:00
QSize layoutsWindowSize ( ) const ;
void setLayoutsWindowSize ( QSize ) ;
2017-07-02 20:19:18 +03:00
signals :
2017-07-04 15:05:54 +03:00
void autostartChanged ( ) ;
2017-07-03 10:41:59 +03:00
void currentLayoutNameChanged ( ) ;
2017-07-19 21:36:05 +03:00
void layoutsWindowSizeChanged ( ) ;
2017-07-02 20:19:18 +03:00
void versionChanged ( ) ;
private slots :
void loadConfig ( ) ;
void saveConfig ( ) ;
2017-07-02 16:12:58 +03:00
private :
2017-07-02 21:02:27 +03:00
void cleanupSettings ( ) ;
private :
2017-07-02 20:19:18 +03:00
//when there isnt a version it is an old universal file
int m_version { 1 } ;
2017-07-02 16:12:58 +03:00
2017-07-03 10:41:59 +03:00
QString m_currentLayoutName ;
2017-07-19 21:36:05 +03:00
QSize m_layoutsWindowSize { 700 , 450 } ;
2017-07-03 10:41:59 +03:00
2017-07-02 20:19:18 +03:00
KConfigGroup m_universalGroup ;
2017-07-02 21:02:27 +03:00
KSharedConfig : : Ptr m_config ;
2017-07-03 10:41:59 +03:00
2017-07-02 15:02:07 +03:00
} ;
}
# endif //UNIVERSALSETTINGS_H