Warning, file /plasma/latte-dock/app/settings/settingsdialog.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * Copyright 2017  Smith AR <audoban@openmailbox.org>
0003  *                 Michail Vourlakos <mvourlakos@gmail.com>
0004  *
0005  * This file is part of Latte-Dock
0006  *
0007  * Latte-Dock is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU General Public License as
0009  * published by the Free Software Foundation; either version 2 of
0010  * the License, or (at your option) any later version.
0011  *
0012  * Latte-Dock is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015  * GNU General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU General Public License
0018  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0019  *
0020  */
0021 
0022 #ifndef SETTINGSDIALOG_H
0023 #define SETTINGSDIALOG_H
0024 
0025 // local
0026 #include "../liblatte2/types.h"
0027 
0028 // Qt
0029 #include <QObject>
0030 #include <QButtonGroup>
0031 #include <QDialog>
0032 #include <QDebug>
0033 #include <QStandardItemModel>
0034 #include <QTimer>
0035 
0036 // KDE
0037 #include <KHelpMenu>
0038 
0039 namespace Ui {
0040 class SettingsDialog;
0041 }
0042 
0043 namespace KActivities {
0044 class Controller;
0045 }
0046 
0047 namespace Latte {
0048 class Corona;
0049 class CentralLayout;
0050 }
0051 
0052 namespace Latte {
0053 
0054 class SettingsDialog : public QDialog
0055 {
0056     Q_OBJECT
0057 public:
0058     SettingsDialog(QWidget *parent, Latte::Corona *corona);
0059     ~SettingsDialog();
0060 
0061     void toggleCurrentPage();
0062 
0063     void addActivityInCurrent(const QString &activityId);
0064     void removeActivityFromCurrent(const QString &activityId);
0065     void addShareInCurrent(const QString &layoutId);
0066     void removeShareFromCurrent(const QString &layoutId);
0067 
0068     bool inMultipleLayoutsLook() const;
0069     bool isActive(QString layoutName) const;
0070     bool isShared(int row) const;
0071     bool isMenuCell(int column) const;
0072 
0073     QString nameForId(QString id) const;
0074     QString idForRow(int row) const;
0075 
0076     QStringList activities();
0077     QStringList availableActivities();
0078     QStringList availableSharesFor(int row);
0079 
0080     void requestImagesDialog(int row);
0081     void requestColorsDialog(int row);
0082 
0083 private slots:
0084     // auto connections
0085     void on_newButton_clicked();
0086     void on_copyButton_clicked();
0087     void on_downloadButton_clicked();
0088     void on_lockedButton_clicked();
0089     void on_pauseButton_clicked();
0090     void on_removeButton_clicked();
0091     void on_sharedButton_clicked();
0092     void on_switchButton_clicked();
0093     void on_importButton_clicked();
0094     void on_exportButton_clicked();
0095 
0096     void accept() override;
0097     void reject() override;
0098     void apply();
0099     void restoreDefaults();
0100     void showLayoutInformation();
0101     void showScreensInformation();
0102     void updatePerLayoutButtonsState();
0103 
0104     void layoutsChanged();
0105     void itemChanged(QStandardItem *item);
0106 
0107 private:
0108     void addLayoutForFile(QString file, QString layoutName = QString(), bool newTempDirectory = true, bool showNotification = true);
0109     //! When an activity is closed for some reason the window manager hides and reshows
0110     //! the windows. This function prevents this because we don't want to delete the window
0111     //! on reject in such case.
0112     void blockDeleteOnActivityStopped();
0113     void loadSettings();
0114     void recalculateAvailableActivities();
0115     void insertLayoutInfoAtRow(int row, QString path, QString color, QString textColor, QString name, bool menu, bool disabledBorders,
0116                                QStringList activities, bool locked = false);
0117     void updateApplyButtonsState();
0118     void updateSharedLayoutsStates();
0119     void updateSharedLayoutsUiElements();
0120     void syncActiveShares();
0121 
0122     bool dataAreAccepted();
0123     bool idExistsInModel(QString id);
0124     bool importLayoutsFromV1ConfigFile(QString file);
0125     bool nameExistsInModel(QString name);
0126     bool saveAllChanges();    
0127 
0128     int rowForId(QString id) const;
0129     int rowForName(QString layoutName) const;
0130     int ascendingRowFor(QString name);
0131 
0132     QString uniqueTempDirectory();
0133     QString uniqueLayoutName(QString name);
0134 
0135     QList<int> currentSettings();
0136     QStringList currentLayoutsSettings();
0137 
0138 private:
0139 
0140     QStringList m_availableActivities;
0141     QStringList m_tempDirectories;
0142     QStringList m_initLayoutPaths;
0143 
0144     QButtonGroup *m_inMemoryButtons;
0145     QButtonGroup *m_mouseSensitivityButtons;
0146 
0147     QTimer m_activityClosedTimer;
0148     bool m_blockDeleteOnReject{false};
0149 
0150     KHelpMenu *m_helpMenu{nullptr};
0151 
0152     Latte::Corona *m_corona{nullptr};
0153 
0154     QAction *m_editLayoutAction{nullptr};
0155 
0156     QStandardItemModel *m_model{nullptr};
0157     Ui::SettingsDialog *ui;
0158 
0159     //! SharedLayout #settingsid, Shares #settingsid
0160     QHash<const QString, QStringList> m_sharesMap;
0161     QHash<const QString, Latte::CentralLayout *> m_layouts;
0162 
0163     QList<int> o_settings;
0164     QStringList o_settingsLayouts;
0165 };
0166 
0167 }
0168 
0169 #endif // SETTINGSDIALOG_H