Changeset View
Changeset View
Standalone View
Standalone View
src/gtkconfigkcmodule.cpp
Show All 29 Lines | |||||
30 | #include <QStandardPaths> | 30 | #include <QStandardPaths> | ||
31 | #include <QFile> | 31 | #include <QFile> | ||
32 | #include <QMenu> | 32 | #include <QMenu> | ||
33 | #include <QDebug> | 33 | #include <QDebug> | ||
34 | #include <QDir> | 34 | #include <QDir> | ||
35 | #include <config.h> | 35 | #include <config.h> | ||
36 | #include "ui_gui.h" | 36 | #include "ui_gui.h" | ||
37 | #include "abstractappearance.h" | 37 | #include "abstractappearance.h" | ||
38 | #include "iconthemesmodel.h" | | |||
39 | #include "fontshelpers.h" | | |||
40 | #include <QSortFilterProxyModel> | 38 | #include <QSortFilterProxyModel> | ||
41 | #include <qstringlistmodel.h> | 39 | #include <qstringlistmodel.h> | ||
42 | #include <QSvgRenderer> | 40 | #include <QSvgRenderer> | ||
43 | #include <QPainter> | 41 | #include <QPainter> | ||
44 | 42 | | |||
45 | K_PLUGIN_FACTORY_WITH_JSON(GTKConfigKCModuleFactory, "kde-gtk-config.json", registerPlugin<GTKConfigKCModule>();) | 43 | K_PLUGIN_FACTORY_WITH_JSON(GTKConfigKCModuleFactory, "kde-gtk-config.json", registerPlugin<GTKConfigKCModule>();) | ||
46 | 44 | | |||
47 | QMap<QString, int> gtkToolbarInit() | | |||
48 | { | | |||
49 | QMap<QString, int> gtkToolbar; | | |||
50 | gtkToolbar["GTK_TOOLBAR_ICONS"] = 0; | | |||
51 | gtkToolbar["GTK_TOOLBAR_TEXT"] = 1; | | |||
52 | gtkToolbar["GTK_TOOLBAR_BOTH_HORIZ"] = 2; | | |||
53 | gtkToolbar["GTK_TOOLBAR_BOTH"] = 3; | | |||
54 | return gtkToolbar; | | |||
55 | } | | |||
56 | | ||||
57 | static QMap<QString, int> gtkToolbar = gtkToolbarInit(); | | |||
58 | | ||||
59 | GTKConfigKCModule::GTKConfigKCModule(QWidget* parent, const QVariantList& args ) | 45 | GTKConfigKCModule::GTKConfigKCModule(QWidget* parent, const QVariantList& args ) | ||
60 | : KCModule(parent) | 46 | : KCModule(parent) | ||
61 | , ui(new Ui::GUI) | 47 | , ui(new Ui::GUI) | ||
62 | , installer(0) | 48 | , installer(0) | ||
63 | , uninstaller(0) | 49 | , uninstaller(0) | ||
64 | , m_saveEnabled(true) | 50 | , m_saveEnabled(true) | ||
65 | { | 51 | { | ||
66 | Q_UNUSED(args); | 52 | Q_UNUSED(args); | ||
67 | KAboutData *acercade = new KAboutData("cgc", i18n("GTK Application Style"), PROJECT_VERSION, | 53 | KAboutData *acercade = new KAboutData("cgc", i18n("GTK Application Style"), PROJECT_VERSION, | ||
68 | QString(), KAboutLicense::LGPL_V3, i18n("Copyright 2011 José Antonio Sánchez Reynaga")); | 54 | QString(), KAboutLicense::LGPL_V3, i18n("Copyright 2011 José Antonio Sánchez Reynaga")); | ||
69 | acercade->addAuthor(i18n("José Antonio Sánchez Reynaga (antonioJASR)"),i18n("Main Developer"), "joanzare@gmail.com"); | 55 | acercade->addAuthor(i18n("José Antonio Sánchez Reynaga (antonioJASR)"),i18n("Main Developer"), "joanzare@gmail.com"); | ||
70 | acercade->addAuthor(i18n("Aleix Pol i Gonzalez"), i18n("Feature development. Previews, code refactoring."), "aleixpol@blue-systems.com"); | 56 | acercade->addAuthor(i18n("Aleix Pol i Gonzalez"), i18n("Feature development. Previews, code refactoring."), "aleixpol@blue-systems.com"); | ||
71 | acercade->addCredit(i18n("Manuel Tortosa (manutortosa)"), i18n("Ideas, tester, internationalization")); | 57 | acercade->addCredit(i18n("Manuel Tortosa (manutortosa)"), i18n("Ideas, tester, internationalization")); | ||
72 | acercade->addCredit(i18n("Adrián Chaves Fernández (Gallaecio)"), i18n("Internationalization")); | 58 | acercade->addCredit(i18n("Adrián Chaves Fernández (Gallaecio)"), i18n("Internationalization")); | ||
73 | setAboutData(acercade); | 59 | setAboutData(acercade); | ||
74 | setButtons(KCModule::Default | KCModule::Apply); | 60 | setButtons(KCModule::Default | KCModule::Apply); | ||
75 | ui->setupUi(this); | 61 | ui->setupUi(this); | ||
76 | appareance = new AppearenceGTK; | 62 | appareance = new AppearenceGTK; | ||
77 | 63 | | |||
78 | m_cursorsModel = new CursorThemesModel(this); | | |||
79 | QSortFilterProxyModel *cursorsProxyModel = new QSortFilterProxyModel(this); | | |||
80 | cursorsProxyModel->setSourceModel(m_cursorsModel); | | |||
81 | cursorsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); | | |||
82 | cursorsProxyModel->setSortRole(Qt::DisplayRole); | | |||
83 | cursorsProxyModel->sort(0); | | |||
84 | ui->cb_cursor->setModel(cursorsProxyModel); | | |||
85 | | ||||
86 | m_iconsModel = new IconThemesModel(false, this); | | |||
87 | QSortFilterProxyModel *iconsProxyModel = new QSortFilterProxyModel(this); | | |||
88 | iconsProxyModel->setSourceModel(m_iconsModel); | | |||
89 | iconsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); | | |||
90 | iconsProxyModel->setSortRole(Qt::DisplayRole); | | |||
91 | iconsProxyModel->sort(0); | | |||
92 | ui->cb_icon->setModel(iconsProxyModel); | | |||
93 | ui->cb_icon_fallback->setModel(iconsProxyModel); | | |||
94 | | ||||
95 | m_tempGtk2Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/gtkrc-2.0"; | 64 | m_tempGtk2Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/gtkrc-2.0"; | ||
96 | m_tempGtk3Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/.config/gtk-3.0/settings.ini"; | 65 | m_tempGtk3Preview = QStandardPaths::writableLocation(QStandardPaths::TempLocation)+ "/.config/gtk-3.0/settings.ini"; | ||
97 | 66 | | |||
98 | const QIcon previewIcon = QIcon::fromTheme("document-preview"); | 67 | const QIcon previewIcon = QIcon::fromTheme("document-preview"); | ||
99 | ui->gtk2Preview->setIcon(previewIcon); | 68 | ui->gtk2Preview->setIcon(previewIcon); | ||
100 | ui->gtk3Preview->setIcon(previewIcon); | 69 | ui->gtk3Preview->setIcon(previewIcon); | ||
101 | 70 | | |||
102 | QString gtk2Preview = QStandardPaths::findExecutable("gtk_preview", {CMAKE_INSTALL_FULL_LIBEXECDIR}); | 71 | QString gtk2Preview = QStandardPaths::findExecutable("gtk_preview", {CMAKE_INSTALL_FULL_LIBEXECDIR}); | ||
Show All 15 Lines | |||||
118 | 87 | | |||
119 | ui->gtk2Preview->setVisible(!gtk2Preview.isEmpty()); | 88 | ui->gtk2Preview->setVisible(!gtk2Preview.isEmpty()); | ||
120 | ui->gtk3Preview->setVisible(!gtk3Preview.isEmpty()); | 89 | ui->gtk3Preview->setVisible(!gtk3Preview.isEmpty()); | ||
121 | 90 | | |||
122 | //UI changes | 91 | //UI changes | ||
123 | connect(ui->cb_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 92 | connect(ui->cb_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
124 | connect(ui->cb_theme_gtk3, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 93 | connect(ui->cb_theme_gtk3, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
125 | connect(ui->checkBox_theme_gtk3_prefer_dark, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | 94 | connect(ui->checkBox_theme_gtk3_prefer_dark, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | ||
126 | connect(ui->cb_cursor, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | | |||
127 | connect(ui->cb_icon, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | | |||
128 | connect(ui->cb_icon_fallback ,SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | | |||
129 | connect(ui->font, &KFontRequester::fontSelected, this, >KConfigKCModule::appChanged); | | |||
130 | connect(ui->cb_toolbar_icons, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | | |||
131 | connect(ui->checkBox_icon_gtk_menus, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | | |||
132 | connect(ui->checkBox_icon_gtk_buttons, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | | |||
133 | connect(ui->buttonGroup_primary_button_warps_slider, SIGNAL(buttonToggled(QAbstractButton*, bool)), this, SLOT(appChanged())); | 95 | connect(ui->buttonGroup_primary_button_warps_slider, SIGNAL(buttonToggled(QAbstractButton*, bool)), this, SLOT(appChanged())); | ||
134 | 96 | | |||
135 | //preview updates | 97 | //preview updates | ||
136 | connect(ui->cb_icon_fallback, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); | | |||
137 | connect(ui->cb_icon, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); | | |||
138 | connect(ui->gtk2Preview, &QAbstractButton::clicked, this, >KConfigKCModule::runGtk2IfNecessary); | 98 | connect(ui->gtk2Preview, &QAbstractButton::clicked, this, >KConfigKCModule::runGtk2IfNecessary); | ||
139 | connect(ui->gtk3Preview, &QAbstractButton::clicked, this, >KConfigKCModule::runGtk3IfNecessary); | 99 | connect(ui->gtk3Preview, &QAbstractButton::clicked, this, >KConfigKCModule::runGtk3IfNecessary); | ||
140 | 100 | | |||
141 | QMenu* m = new QMenu(this); | 101 | QMenu* m = new QMenu(this); | ||
142 | m->addAction(QIcon::fromTheme("get-hot-new-stuff"), i18n("Download GTK2 themes..."), this, >KConfigKCModule::showThemeGHNS); | 102 | m->addAction(QIcon::fromTheme("get-hot-new-stuff"), i18n("Download GTK2 themes..."), this, >KConfigKCModule::showThemeGHNS); | ||
143 | m->addAction(QIcon::fromTheme("get-hot-new-stuff"), i18n("Download GTK3 themes..."), this, >KConfigKCModule::installThemeGTK3GHNS); | 103 | m->addAction(QIcon::fromTheme("get-hot-new-stuff"), i18n("Download GTK3 themes..."), this, >KConfigKCModule::installThemeGTK3GHNS); | ||
144 | m->addAction(QIcon::fromTheme("archive-insert"), i18n("Install a local theme..."), this, >KConfigKCModule::showDialogForInstall); | 104 | m->addAction(QIcon::fromTheme("archive-insert"), i18n("Install a local theme..."), this, >KConfigKCModule::showDialogForInstall); | ||
145 | m->addAction(QIcon::fromTheme("archive-remove"), i18n("Uninstall a local theme..."), this, >KConfigKCModule::showDialogForUninstall); | 105 | m->addAction(QIcon::fromTheme("archive-remove"), i18n("Uninstall a local theme..."), this, >KConfigKCModule::showDialogForUninstall); | ||
Show All 15 Lines | 111 | { | |||
161 | delete ui; | 121 | delete ui; | ||
162 | } | 122 | } | ||
163 | 123 | | |||
164 | void GTKConfigKCModule::syncUI() | 124 | void GTKConfigKCModule::syncUI() | ||
165 | { | 125 | { | ||
166 | appareance->setThemeGtk3(ui->cb_theme_gtk3->currentText()); | 126 | appareance->setThemeGtk3(ui->cb_theme_gtk3->currentText()); | ||
167 | appareance->setTheme(ui->cb_theme->currentText()); | 127 | appareance->setTheme(ui->cb_theme->currentText()); | ||
168 | appareance->setApplicationPreferDarkTheme(ui->checkBox_theme_gtk3_prefer_dark->isChecked()); | 128 | appareance->setApplicationPreferDarkTheme(ui->checkBox_theme_gtk3_prefer_dark->isChecked()); | ||
169 | appareance->setCursor(ui->cb_cursor->itemData(ui->cb_cursor->currentIndex(), CursorThemesModel::DirNameRole).toString()); | 129 | | ||
170 | appareance->setIcon(ui->cb_icon->itemData(ui->cb_icon->currentIndex(), IconThemesModel::DirNameRole).toString()); | | |||
171 | appareance->setIconFallback(ui->cb_icon_fallback->itemData(ui->cb_icon_fallback->currentIndex(), IconThemesModel::DirNameRole).toString()); | | |||
172 | appareance->setFont(fontToString(ui->font->font())); | | |||
173 | | ||||
174 | appareance->setToolbarStyle(gtkToolbar.key(ui->cb_toolbar_icons->currentIndex())); | | |||
175 | appareance->setShowIconsInButtons(ui->checkBox_icon_gtk_buttons->isChecked()); | | |||
176 | appareance->setShowIconsInMenus(ui->checkBox_icon_gtk_menus->isChecked()); | | |||
177 | appareance->setPrimaryButtonWarpsSlider(ui->buttonGroup_primary_button_warps_slider->checkedButton() == ui->radioButton_warp); | 130 | appareance->setPrimaryButtonWarpsSlider(ui->buttonGroup_primary_button_warps_slider->checkedButton() == ui->radioButton_warp); | ||
178 | } | 131 | } | ||
179 | 132 | | |||
180 | void GTKConfigKCModule::showThemeGHNS() | 133 | void GTKConfigKCModule::showThemeGHNS() | ||
181 | { | 134 | { | ||
182 | KNS3::DownloadDialog d("cgctheme.knsrc", this); | 135 | KNS3::DownloadDialog d("cgctheme.knsrc", this); | ||
183 | if(d.exec()) { | 136 | if(d.exec()) { | ||
184 | refreshLists(); | 137 | refreshLists(); | ||
185 | } | 138 | } | ||
186 | } | 139 | } | ||
187 | 140 | | |||
188 | void GTKConfigKCModule::installThemeGTK3GHNS() | 141 | void GTKConfigKCModule::installThemeGTK3GHNS() | ||
189 | { | 142 | { | ||
190 | KNS3::DownloadDialog d("cgcgtk3.knsrc", this); | 143 | KNS3::DownloadDialog d("cgcgtk3.knsrc", this); | ||
191 | if(d.exec()) { | 144 | if(d.exec()) { | ||
192 | refreshLists(); | 145 | refreshLists(); | ||
193 | } | 146 | } | ||
194 | } | 147 | } | ||
195 | 148 | | |||
196 | void GTKConfigKCModule::refreshLists() | 149 | void GTKConfigKCModule::refreshLists() | ||
197 | { | 150 | { | ||
198 | refreshThemesUi(true); | 151 | refreshThemesUi(true); | ||
199 | 152 | | |||
200 | const auto newFont = stringToFont(appareance->getFont()); | | |||
201 | if (newFont != ui->font->font()) | | |||
202 | ui->font->setFont(newFont); | | |||
203 | | ||||
204 | ui->cb_toolbar_icons->setCurrentIndex(gtkToolbar[appareance->getToolbarStyle()]); | | |||
205 | | ||||
206 | ui->checkBox_icon_gtk_buttons->setChecked(appareance->getShowIconsInButtons()); | | |||
207 | ui->checkBox_icon_gtk_menus->setChecked(appareance->getShowIconsInMenus()); | | |||
208 | const bool warps = appareance->getPrimaryButtonWarpsSlider(); | 153 | const bool warps = appareance->getPrimaryButtonWarpsSlider(); | ||
209 | ui->radioButton_warp->setChecked(warps); | 154 | ui->radioButton_warp->setChecked(warps); | ||
210 | ui->radioButton_dont_warp->setChecked(!warps); | 155 | ui->radioButton_dont_warp->setChecked(!warps); | ||
211 | | ||||
212 | makePreviewIconTheme(); | | |||
213 | } | | |||
214 | | ||||
215 | void tryIcon(QLabel* label, const QString& fallback, const QString& theme, const QString& iconName) | | |||
216 | { | | |||
217 | label->setToolTip(iconName); | | |||
218 | | ||||
219 | auto findIconAt = [label, theme, iconName](const QDir &where) -> bool { | | |||
220 | const QString path = IconThemesModel::findIconRecursivelyByName(iconName, where); | | |||
221 | | ||||
222 | if(!path.isEmpty()) { | | |||
223 | QPixmap p; | | |||
224 | QSize s(label->width(), label->height()); | | |||
225 | if (path.endsWith(".svg") || path.endsWith(".svgz")) { | | |||
226 | QImage image(s, QImage::Format_ARGB32_Premultiplied); | | |||
227 | image.fill(Qt::transparent); | | |||
228 | QPainter painter(&image); | | |||
229 | QSvgRenderer r(path); | | |||
230 | r.render(&painter); | | |||
231 | painter.end(); | | |||
232 | | ||||
233 | p = QPixmap::fromImage(image); | | |||
234 | } else { | | |||
235 | p = {path}; | | |||
236 | Q_ASSERT(!p.isNull()); | | |||
237 | p = p.scaled(s); | | |||
238 | } | | |||
239 | label->setPixmap(p); | | |||
240 | return true; | | |||
241 | } | | |||
242 | return false; | | |||
243 | }; | | |||
244 | if (!theme.isEmpty() && findIconAt(QDir(theme))) | | |||
245 | return; | | |||
246 | if (findIconAt(fallback)) | | |||
247 | return; | | |||
248 | | ||||
249 | QIcon notFoundIcon = QIcon::fromTheme("application-x-zerosize"); | | |||
250 | QPixmap noIcon(notFoundIcon.pixmap(48,48)); | | |||
251 | label->setPixmap(noIcon); | | |||
252 | | ||||
253 | qWarning() << "could not find icon" << iconName; | | |||
254 | } | | |||
255 | | ||||
256 | void GTKConfigKCModule::makePreviewIconTheme() | | |||
257 | { | | |||
258 | int icon_fallback = ui->cb_icon_fallback->currentIndex(); | | |||
259 | QString path_fallback = ui->cb_icon->itemData(icon_fallback, IconThemesModel::PathRole).toString(); | | |||
260 | | ||||
261 | int icon = ui->cb_icon->currentIndex(); | | |||
262 | QString path_icon = ui->cb_icon->itemData(icon, IconThemesModel::PathRole).toString(); | | |||
263 | | ||||
264 | tryIcon(ui->lb_prev_1, path_fallback, path_icon, "user-home"); | | |||
265 | tryIcon(ui->lb_prev_2, path_fallback, path_icon, "folder"); | | |||
266 | tryIcon(ui->lb_prev_3, path_fallback, path_icon, "user-trash"); | | |||
267 | tryIcon(ui->lb_prev_4, path_fallback, path_icon, "document-print"); | | |||
268 | tryIcon(ui->lb_prev_5, path_fallback, path_icon, "user-desktop"); | | |||
269 | tryIcon(ui->lb_prev_6, path_fallback, path_icon, "network-server"); | | |||
270 | tryIcon(ui->lb_prev_7, path_fallback, path_icon, "system-help"); | | |||
271 | tryIcon(ui->lb_prev_8, path_fallback, path_icon, "start-here"); | | |||
272 | tryIcon(ui->lb_prev_9, path_fallback, path_icon, "go-up"); | | |||
273 | } | 156 | } | ||
274 | 157 | | |||
275 | void GTKConfigKCModule::appChanged() | 158 | void GTKConfigKCModule::appChanged() | ||
276 | { | 159 | { | ||
277 | if (m_loading) | 160 | if (m_loading) | ||
278 | return; | 161 | return; | ||
279 | 162 | | |||
280 | savePreviewConfig(); | 163 | savePreviewConfig(); | ||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 211 | { | |||
341 | } | 224 | } | ||
342 | } | 225 | } | ||
343 | 226 | | |||
344 | void GTKConfigKCModule::save() | 227 | void GTKConfigKCModule::save() | ||
345 | { | 228 | { | ||
346 | /* qDebug() << "******************************************* INSTALLATION :\n" | 229 | /* qDebug() << "******************************************* INSTALLATION :\n" | ||
347 | << "theme : " << appareance->getTheme() << "\n" | 230 | << "theme : " << appareance->getTheme() << "\n" | ||
348 | << "themeGTK3 : " << appareance->getThemeGtk3() << "\n" | 231 | << "themeGTK3 : " << appareance->getThemeGtk3() << "\n" | ||
349 | << "icons : " << appareance->getIcon() << "\n" | | |||
350 | << "fallback icons : " << appareance->getIconFallback() << "\n" | | |||
351 | << "cursors : " << appareance->getCursor() << "\n" | | |||
352 | << "font family : " << appareance->getFont() << "\n" | | |||
353 | << "toolbar style : " << appareance->getToolbarStyle() << "\n" | | |||
354 | << "icons in buttons : " << appareance->getShowIconsInButtons() << "\n" | | |||
355 | << "icons in menus : " << appareance->getShowIconsInMenus() << "\n" | | |||
356 | << "********************************************************"; | 232 | << "********************************************************"; | ||
357 | */ | 233 | */ | ||
358 | syncUI(); | 234 | syncUI(); | ||
359 | if(!appareance->saveFileConfig()) | 235 | if(!appareance->saveFileConfig()) | ||
360 | KMessageBox::error(this, i18n("Failed to save configuration.")); | 236 | KMessageBox::error(this, i18n("Failed to save configuration.")); | ||
361 | } | 237 | } | ||
362 | 238 | | |||
363 | void setComboItem(QComboBox* combo, const QStringList& texts) | 239 | void setComboItem(QComboBox* combo, const QStringList& texts) | ||
364 | { | 240 | { | ||
365 | foreach(const QString& text, texts) { | 241 | foreach(const QString& text, texts) { | ||
366 | int pos = combo->findText(text); | 242 | int pos = combo->findText(text); | ||
367 | if(pos>=0) { | 243 | if(pos>=0) { | ||
368 | combo->setCurrentIndex(pos); | 244 | combo->setCurrentIndex(pos); | ||
369 | return; | 245 | return; | ||
370 | } | 246 | } | ||
371 | } | 247 | } | ||
372 | } | 248 | } | ||
373 | 249 | | |||
374 | void GTKConfigKCModule::defaults() | 250 | void GTKConfigKCModule::defaults() | ||
375 | { | 251 | { | ||
376 | refreshThemesUi(false); | 252 | refreshThemesUi(false); | ||
377 | 253 | | |||
378 | // qDebug() << "loading defaults..."; | 254 | // qDebug() << "loading defaults..."; | ||
379 | m_saveEnabled = false; | 255 | m_saveEnabled = false; | ||
380 | ui->font->setFont(font()); | | |||
381 | bool showIcons = !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); | | |||
382 | ui->checkBox_icon_gtk_buttons->setChecked(showIcons); | | |||
383 | ui->checkBox_icon_gtk_menus->setChecked(showIcons); | | |||
384 | 256 | | |||
385 | // this makes it consistent with Qt apps and restores the old Gtk behavior | 257 | // this makes it consistent with Qt apps and restores the old Gtk behavior | ||
386 | ui->radioButton_dont_warp->setChecked(true); | 258 | ui->radioButton_dont_warp->setChecked(true); | ||
387 | 259 | | |||
388 | setComboItem(ui->cb_theme, QStringList("oxygen-gtk") << "Clearlooks"); | 260 | setComboItem(ui->cb_theme, QStringList("oxygen-gtk") << "Clearlooks"); | ||
389 | setComboItem(ui->cb_theme_gtk3, QStringList("oxygen-gtk") << "Adwaita"); | 261 | setComboItem(ui->cb_theme_gtk3, QStringList("oxygen-gtk") << "Adwaita"); | ||
390 | 262 | | |||
391 | QStringList icons; | | |||
392 | icons << KIconLoader::global()->theme()->name() << "GNOME"; | | |||
393 | setComboItem(ui->cb_icon, icons); | | |||
394 | | ||||
395 | int idx = ui->cb_icon->currentIndex(); | | |||
396 | if(idx>=0) { | | |||
397 | setComboItem(ui->cb_icon_fallback, icons.mid(icons.indexOf(ui->cb_icon->currentText())+1)); | | |||
398 | } | | |||
399 | m_saveEnabled = true; | 263 | m_saveEnabled = true; | ||
400 | 264 | | |||
401 | makePreviewIconTheme(); | | |||
402 | appChanged(); | 265 | appChanged(); | ||
403 | } | 266 | } | ||
404 | 267 | | |||
405 | void GTKConfigKCModule::load() | 268 | void GTKConfigKCModule::load() | ||
406 | { | 269 | { | ||
407 | m_saveEnabled = false; | 270 | m_saveEnabled = false; | ||
408 | bool someCorrect = appareance->loadFileConfig(); | 271 | bool someCorrect = appareance->loadFileConfig(); | ||
409 | m_loading = true; | 272 | m_loading = true; | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 343 | { | |||
489 | //theme gtk3 | 352 | //theme gtk3 | ||
490 | refreshComboSameCurrentValue(ui->cb_theme_gtk3, | 353 | refreshComboSameCurrentValue(ui->cb_theme_gtk3, | ||
491 | useConfig ? appareance->getThemeGtk3() : ui->cb_theme_gtk3->currentText(), | 354 | useConfig ? appareance->getThemeGtk3() : ui->cb_theme_gtk3->currentText(), | ||
492 | appareance->gtk3Appearance()->installedThemesNames()); | 355 | appareance->gtk3Appearance()->installedThemesNames()); | ||
493 | 356 | | |||
494 | // dark theme for gtk3 | 357 | // dark theme for gtk3 | ||
495 | ui->checkBox_theme_gtk3_prefer_dark->setChecked(appareance->getApplicationPreferDarkTheme()); | 358 | ui->checkBox_theme_gtk3_prefer_dark->setChecked(appareance->getApplicationPreferDarkTheme()); | ||
496 | 359 | | |||
497 | //cursors | | |||
498 | QString currentCursor = useConfig ? appareance->getCursor() : ui->cb_cursor->currentText(); | | |||
499 | int currentCursorIdx = ui->cb_cursor->findData(currentCursor, CursorThemesModel::DirNameRole); | | |||
500 | ui->cb_cursor->setCurrentIndex(qMax(currentCursorIdx, 0)); | | |||
501 | | ||||
502 | //icons | | |||
503 | QString currentIcon = useConfig ? appareance->getIcon() : ui->cb_icon->currentText(), | | |||
504 | currentFallback = useConfig ? appareance->getIconFallback() : ui->cb_icon_fallback->currentText(); | | |||
505 | int currentIconIdx = ui->cb_icon->findData(currentIcon, IconThemesModel::DirNameRole); | | |||
506 | int currentFallbackIdx = ui->cb_icon_fallback->findData(currentFallback, IconThemesModel::DirNameRole); | | |||
507 | ui->cb_icon->setCurrentIndex(qMax(currentIconIdx, 0)); | | |||
508 | ui->cb_icon_fallback->setCurrentIndex(qMax(currentFallbackIdx, 0)); | | |||
509 | 360 | | |||
510 | m_saveEnabled = wasenabled; | 361 | m_saveEnabled = wasenabled; | ||
511 | if(currentCursorIdx<0 || currentIconIdx<0 || currentFallbackIdx<0) | | |||
512 | emit changed(true); | 362 | emit changed(true); | ||
513 | } | 363 | } | ||
514 | 364 | | |||
515 | void GTKConfigKCModule::showDialogForInstall() | 365 | void GTKConfigKCModule::showDialogForInstall() | ||
516 | { | 366 | { | ||
517 | if(!installer) { | 367 | if(!installer) { | ||
518 | installer = new DialogInstaller(this); | 368 | installer = new DialogInstaller(this); | ||
519 | connect(installer, &DialogInstaller::themeInstalled, this, >KConfigKCModule::refreshLists); | 369 | connect(installer, &DialogInstaller::themeInstalled, this, >KConfigKCModule::refreshLists); | ||
Show All 28 Lines |