2017-07-05 22:03:39 +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/>.
*
*/
2018-02-03 14:34:07 +03:00
# ifndef SETTINGSDIALOG_H
# define SETTINGSDIALOG_H
2017-07-05 22:03:39 +03:00
2018-02-03 12:34:13 +03:00
# include "../liblattedock/dock.h"
2017-07-20 11:27:22 +03:00
2017-07-05 22:03:39 +03:00
# include <QObject>
2018-01-17 19:29:20 +03:00
# include <QButtonGroup>
2017-07-05 22:03:39 +03:00
# include <QDialog>
# include <QDebug>
2017-07-17 22:07:04 +03:00
# include <QStandardItemModel>
2018-02-03 14:10:43 +03:00
# include <QTimer>
2017-07-05 22:03:39 +03:00
2017-07-17 22:07:04 +03:00
namespace Ui {
2018-02-03 14:34:07 +03:00
class SettingsDialog ;
2017-07-05 22:03:39 +03:00
}
2018-01-15 20:44:00 +03:00
namespace KActivities {
class Controller ;
}
2017-07-17 22:07:04 +03:00
namespace Latte {
2018-01-27 02:27:48 +03:00
class DockCorona ;
2018-01-07 20:33:18 +03:00
class Layout ;
2017-07-17 22:07:04 +03:00
}
2017-07-05 22:03:39 +03:00
namespace Latte {
2018-07-03 22:15:45 +03:00
class SettingsDialog : public QDialog
{
2017-07-05 22:03:39 +03:00
Q_OBJECT
public :
2018-02-03 14:34:07 +03:00
SettingsDialog ( QWidget * parent , DockCorona * corona ) ;
~ SettingsDialog ( ) ;
2017-07-05 22:03:39 +03:00
2018-01-27 03:52:31 +03:00
void setCurrentPage ( Dock : : LatteConfigPage page ) ;
2017-07-19 19:34:59 +03:00
QStringList activities ( ) ;
QStringList availableActivities ( ) ;
2018-02-17 02:15:45 +03:00
void requestImagesDialog ( int row ) ;
2018-02-17 02:26:35 +03:00
void requestColorsDialog ( int row ) ;
2018-02-17 02:15:45 +03:00
2017-07-05 22:03:39 +03:00
private slots :
2017-07-07 23:00:53 +03:00
// auto connections
2017-08-27 17:00:34 +03:00
void on_newButton_clicked ( ) ;
2017-07-05 22:03:39 +03:00
void on_copyButton_clicked ( ) ;
2018-01-03 11:31:06 +03:00
void on_downloadButton_clicked ( ) ;
2018-04-16 00:45:44 +03:00
void on_lockedButton_clicked ( ) ;
2018-01-29 23:50:55 +03:00
void on_pauseButton_clicked ( ) ;
2017-07-05 22:03:39 +03:00
void on_removeButton_clicked ( ) ;
2017-07-17 23:49:32 +03:00
void on_switchButton_clicked ( ) ;
2017-07-05 22:03:39 +03:00
void on_importButton_clicked ( ) ;
void on_exportButton_clicked ( ) ;
2017-07-07 23:00:53 +03:00
void accept ( ) override ;
void reject ( ) override ;
void apply ( ) ;
void restoreDefaults ( ) ;
2018-03-21 19:41:01 +03:00
void updatePerLayoutButtonsState ( ) ;
2017-07-05 22:03:39 +03:00
2018-01-17 21:22:50 +03:00
void layoutsChanged ( ) ;
2017-07-19 19:34:59 +03:00
void itemChanged ( QStandardItem * item ) ;
2017-07-17 23:49:32 +03:00
2017-07-05 22:03:39 +03:00
private :
2017-08-27 17:00:34 +03:00
void addLayoutForFile ( QString file , QString layoutName = QString ( ) , bool newTempDirectory = true , bool showNotification = true ) ;
2018-01-29 23:38:30 +03:00
//! When an activity is closed for some reason the window manager hides and reshows
2018-08-30 08:47:53 +03:00
//! the windows. This function prevents this because we don't want to delete the window
2018-01-29 23:38:30 +03:00
//! on reject in such case.
void blockDeleteOnActivityStopped ( ) ;
2018-01-29 21:30:13 +03:00
void loadSettings ( ) ;
2017-07-19 19:34:59 +03:00
void recalculateAvailableActivities ( ) ;
2018-05-10 21:14:48 +03:00
void insertLayoutInfoAtRow ( int row , QString path , QString color , QString textColor , QString name , bool menu , bool disabledBorders ,
QStringList activities , bool locked = false ) ;
2018-01-29 21:30:13 +03:00
void updateApplyButtonsState ( ) ;
2017-07-19 19:34:59 +03:00
2017-07-20 17:29:46 +03:00
bool dataAreAccepted ( ) ;
2017-07-21 00:48:57 +03:00
bool idExistsInModel ( QString id ) ;
2017-07-22 22:52:31 +03:00
bool importLayoutsFromV1ConfigFile ( QString file ) ;
2017-07-22 10:39:35 +03:00
bool nameExistsInModel ( QString name ) ;
2017-07-20 17:55:44 +03:00
bool saveAllChanges ( ) ;
2017-07-20 17:29:46 +03:00
2017-07-22 10:39:35 +03:00
int ascendingRowFor ( QString name ) ;
2017-07-21 19:24:17 +03:00
QString uniqueTempDirectory ( ) ;
2017-07-22 14:13:26 +03:00
QString uniqueLayoutName ( QString name ) ;
2017-07-21 19:24:17 +03:00
2018-01-29 21:30:13 +03:00
QList < int > currentSettings ( ) ;
QStringList currentLayoutsSettings ( ) ;
private :
2017-07-19 19:34:59 +03:00
QStringList m_availableActivities ;
2017-07-21 19:24:17 +03:00
QStringList m_tempDirectories ;
2017-07-21 00:48:57 +03:00
QStringList m_initLayoutPaths ;
2017-07-17 22:07:04 +03:00
2018-01-17 19:29:20 +03:00
QButtonGroup * m_inMemoryButtons ;
2018-01-27 03:05:33 +03:00
QButtonGroup * m_mouseSensitivityButtons ;
2018-01-17 19:29:20 +03:00
2018-01-29 23:38:30 +03:00
QTimer m_activityClosedTimer ;
bool m_blockDeleteOnReject { false } ;
2018-01-27 02:27:48 +03:00
DockCorona * m_corona { nullptr } ;
2017-07-17 22:07:04 +03:00
QStandardItemModel * m_model { nullptr } ;
2018-02-03 14:34:07 +03:00
Ui : : SettingsDialog * ui ;
2017-07-20 11:27:22 +03:00
2018-01-07 20:33:18 +03:00
QHash < const QString , Layout * > m_layouts ;
2018-01-29 21:30:13 +03:00
QList < int > o_settings ;
QStringList o_settingsLayouts ;
2017-07-05 22:03:39 +03:00
} ;
}
2018-02-03 14:34:07 +03:00
# endif // SETTINGSDIALOG_H