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>
2018-03-06 22:54:37 +02:00
# include <QAbstractItemModel>
2017-07-02 15:02:07 +03:00
2017-07-02 16:12:58 +03:00
# include <KConfigGroup>
# include <KSharedConfig>
2018-01-12 20:11:20 +02:00
# include "../liblattedock/dock.h"
2017-07-03 10:41:59 +03:00
2018-03-06 22:54:37 +02:00
class SortedActivitiesModel ;
2017-07-02 15:02:07 +03:00
namespace Latte {
2018-01-12 20:11:20 +02:00
class LayoutManager ;
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-25 14:19:01 +03:00
Q_PROPERTY ( bool showInfoWindow READ showInfoWindow WRITE setShowInfoWindow NOTIFY showInfoWindowChanged )
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-24 17:56:07 +03:00
Q_PROPERTY ( QStringList launchers READ launchers WRITE setLaunchers NOTIFY launchersChanged )
2018-01-27 02:05:33 +02:00
Q_PROPERTY ( Latte : : Dock : : MouseSensitivity mouseSensitivity READ mouseSensitivity WRITE setMouseSensitivity NOTIFY mouseSensitivityChanged )
2018-03-06 22:54:37 +02:00
Q_PROPERTY ( QAbstractItemModel * runningActivitiesModel READ runningActivitiesModel NOTIFY runningActivitiesModelChanged )
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-25 14:19:01 +03:00
bool showInfoWindow ( ) const ;
void setShowInfoWindow ( bool show ) ;
2017-07-02 20:19:18 +03:00
int version ( ) const ;
void setVersion ( int ver ) ;
2018-04-01 15:04:52 +03:00
int screenTrackerInterval ( ) const ;
void setScreenTrackerInterval ( int duration ) ;
2017-07-03 10:41:59 +03:00
QString currentLayoutName ( ) const ;
void setCurrentLayoutName ( QString layoutName ) ;
2017-07-23 21:05:34 +03:00
QString lastNonAssignedLayoutName ( ) const ;
void setLastNonAssignedLayoutName ( QString layoutName ) ;
2018-03-29 23:24:18 +03:00
QSize downloadWindowSize ( ) const ;
void setDownloadWindowSize ( QSize size ) ;
2017-07-19 21:36:05 +03:00
QSize layoutsWindowSize ( ) const ;
2018-03-29 23:24:18 +03:00
void setLayoutsWindowSize ( QSize size ) ;
2017-07-19 21:36:05 +03:00
2018-03-03 13:03:05 +02:00
QStringList layoutsColumnWidths ( ) const ;
void setLayoutsColumnWidths ( QStringList widths ) ;
2017-07-24 17:56:07 +03:00
QStringList launchers ( ) const ;
void setLaunchers ( QStringList launcherList ) ;
2018-01-27 02:05:33 +02:00
Dock : : MouseSensitivity mouseSensitivity ( ) const ;
void setMouseSensitivity ( Dock : : MouseSensitivity sensitivity ) ;
2018-03-06 22:54:37 +02:00
QAbstractItemModel * runningActivitiesModel ( ) const ;
void setRunningActivitiesModel ( SortedActivitiesModel * model ) ;
void enableActivitiesModel ( ) ;
void disableActivitiesModel ( ) ;
2018-03-04 12:36:48 +02:00
public slots :
Q_INVOKABLE QString splitterIconPath ( ) ;
Q_INVOKABLE QString trademarkIconPath ( ) ;
2018-03-06 22:54:37 +02:00
Q_INVOKABLE float luminasFromFile ( QString imageFile , int edge ) ;
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 ( ) ;
2018-03-29 23:24:18 +03:00
void downloadWindowSizeChanged ( ) ;
2017-07-23 21:05:34 +03:00
void lastNonAssignedLayoutNameChanged ( ) ;
2018-03-03 13:03:05 +02:00
void layoutsColumnWidthsChanged ( ) ;
2017-07-19 21:36:05 +03:00
void layoutsWindowSizeChanged ( ) ;
2017-07-24 17:56:07 +03:00
void launchersChanged ( ) ;
2018-01-12 20:11:20 +02:00
void layoutsMemoryUsageChanged ( ) ;
2018-01-27 02:05:33 +02:00
void mouseSensitivityChanged ( ) ;
2018-03-06 22:54:37 +02:00
void runningActivitiesModelChanged ( ) ;
2018-04-01 15:04:52 +03:00
void screenTrackerIntervalChanged ( ) ;
2017-07-25 14:19:01 +03:00
void showInfoWindowChanged ( ) ;
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 ( ) ;
2018-01-12 20:11:20 +02:00
Dock : : LayoutsMemoryUsage layoutsMemoryUsage ( ) const ;
void setLayoutsMemoryUsage ( Dock : : LayoutsMemoryUsage layoutsMemoryUsage ) ;
2017-07-02 21:02:27 +03:00
private :
2017-07-25 14:19:01 +03:00
bool m_showInfoWindow { true } ;
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
2018-04-01 15:04:52 +03:00
int m_screenTrackerInterval { 2500 } ;
2017-07-03 10:41:59 +03:00
QString m_currentLayoutName ;
2017-07-23 21:05:34 +03:00
QString m_lastNonAssignedLayoutName ;
2018-03-29 23:24:18 +03:00
QSize m_downloadWindowSize { 800 , 550 } ;
2017-07-19 21:36:05 +03:00
QSize m_layoutsWindowSize { 700 , 450 } ;
2018-03-03 13:03:05 +02:00
QStringList m_layoutsColumnWidths ;
2017-07-24 17:56:07 +03:00
QStringList m_launchers ;
2018-03-03 13:03:05 +02:00
2018-01-12 20:11:20 +02:00
Dock : : LayoutsMemoryUsage m_memoryUsage ;
2018-01-27 02:05:33 +02:00
Dock : : MouseSensitivity m_mouseSensitivity { Dock : : HighSensitivity } ;
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
2018-03-06 22:54:37 +02:00
SortedActivitiesModel * m_runningActivitiesModel { nullptr } ;
2018-01-12 20:11:20 +02:00
friend class LayoutManager ;
2018-01-31 15:27:58 +02:00
friend class DockCorona ;
2017-07-02 15:02:07 +03:00
} ;
}
# endif //UNIVERSALSETTINGS_H