Changeset View
Changeset View
Standalone View
Standalone View
src/gtkconfigkcmodule.h
Show All 14 Lines | |||||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | 17 | * Lesser General Public License for more details. | ||
18 | * | 18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | 19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 20 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | 21 | */ | ||
22 | 22 | | |||
23 | | ||||
24 | #ifndef GTKCONFIGKCMODULE_H | 23 | #ifndef GTKCONFIGKCMODULE_H | ||
25 | #define GTKCONFIGKCMODULE_H | 24 | #define GTKCONFIGKCMODULE_H | ||
26 | 25 | | |||
27 | #include <KCModule> | 26 | #include <KCModule> | ||
28 | #include <kns3/downloaddialog.h> | | |||
29 | 27 | | |||
30 | #include "appearencegtk.h" | 28 | #include <QDBusInterface> | ||
31 | #include "dialog_installer.h" | 29 | #include <QAbstractTableModel> | ||
32 | #include "dialog_uninstaller.h" | 30 | #include <QMap> | ||
31 | | ||||
32 | class GtkThemesListModel : public QAbstractTableModel { | ||||
33 | Q_OBJECT | ||||
34 | public: | ||||
35 | GtkThemesListModel(QObject *parent = nullptr); | ||||
36 | | ||||
37 | void setThemesList(const QMap<QString, QString> &themes); | ||||
38 | bool containsTheme(const QString &themeName); | ||||
39 | int rowCount(const QModelIndex &parent) const override; | ||||
40 | int columnCount(const QModelIndex &parent) const override; | ||||
41 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; | ||||
42 | | ||||
43 | private: | ||||
44 | QMap<QString, QString> themesList; | ||||
45 | }; | ||||
33 | 46 | | |||
34 | class KProcess; | 47 | class QStringList; | ||
35 | namespace Ui { class Modulo; class GUI; } | 48 | namespace Ui { class GUI; } | ||
36 | 49 | | |||
37 | class GTKConfigKCModule : public KCModule | 50 | class GTKConfigKCModule : public KCModule | ||
38 | { | 51 | { | ||
39 | Q_OBJECT | 52 | Q_OBJECT | ||
40 | public: | 53 | public: | ||
41 | explicit GTKConfigKCModule(QWidget *parent = 0 ,const QVariantList &args = QVariantList() ); | 54 | explicit GTKConfigKCModule(QWidget *parent = nullptr, const QVariantList &args = QVariantList()); | ||
42 | ~GTKConfigKCModule(); | 55 | ~GTKConfigKCModule() override; | ||
43 | | ||||
44 | void refreshThemesUi(bool useConfig = false); | | |||
45 | 56 | | |||
46 | void save() override; | 57 | void save() override; | ||
47 | void defaults() override; | 58 | void defaults() override; | ||
48 | void load() override; | 59 | void load() override; | ||
49 | 60 | | |||
50 | public Q_SLOTS: | 61 | private Q_SLOTS: | ||
51 | void refreshLists(); | 62 | void updateThemesListsWithoutLoosingSelection(); | ||
52 | 63 | | |||
53 | // It is called whenever something in the UI has changed | 64 | void installGtk2ThemeFromGHNS(); | ||
54 | void appChanged(); | 65 | void installGtk3ThemeFromGHNS(); | ||
55 | void savePreviewConfig(); | 66 | void installGtkThemeFromFile(); | ||
56 | 67 | void removeGtk2Theme(); | |||
57 | void showThemeGHNS(); | 68 | void removeGtk3Theme(); | ||
58 | void installThemeGTK3GHNS(); | 69 | | ||
59 | 70 | void showGtk2Preview(); | |||
60 | void showDialogForInstall(); | 71 | void showGtk3Preview(); | ||
61 | void showDialogForUninstall(); | 72 | | ||
62 | 73 | void themesSelectionsChanged(); | |||
63 | void runGtk2IfNecessary(bool); | | |||
64 | void runGtk3IfNecessary(bool); | | |||
65 | void untogglePreview(); | | |||
66 | 74 | | |||
67 | private: | 75 | private: | ||
68 | void syncUI(); | 76 | void saveGtk2Theme(); | ||
69 | bool m_loading = false; | 77 | void saveGtk3Theme(); | ||
70 | 78 | | |||
79 | void loadGtkThemes(); | ||||
80 | void loadGtk2Themes(const QStringList &possibleThemesPaths); | ||||
81 | void loadGtk3Themes(const QStringList &possibleThemesPaths); | ||||
82 | | ||||
83 | static QStringList possiblePathsToGtkThemes(); | ||||
84 | | ||||
85 | void selectCurrentGtk2ThemeInCheckbox(); | ||||
86 | void selectCurrentGtk3ThemeInCheckbox(); | ||||
87 | | ||||
88 | void updateDeletionPossibilityForSelectedGtk2Theme(); | ||||
89 | void updateDeletionPossibilityForSelectedGtk3Theme(); | ||||
90 | | ||||
91 | QString currentGtk2Theme; | ||||
92 | QString currentGtk3Theme; | ||||
93 | GtkThemesListModel gtk2ThemesModel; | ||||
94 | GtkThemesListModel gtk3ThemesModel; | ||||
95 | QDBusInterface gtkConfigInterface; | ||||
71 | Ui::GUI *ui; | 96 | Ui::GUI *ui; | ||
72 | AppearenceGTK *appareance; | | |||
73 | | ||||
74 | DialogInstaller *installer; | | |||
75 | DialogUninstaller *uninstaller; | | |||
76 | KProcess *m_p2; | | |||
77 | KProcess *m_p3; | | |||
78 | QString m_tempGtk2Preview; | | |||
79 | QString m_tempGtk3Preview; | | |||
80 | bool m_saveEnabled; | | |||
81 | }; | 97 | }; | ||
82 | 98 | | |||
83 | #endif // MODULO_H | 99 | #endif // GTKCONFIGKCMODULE_H |