Changeset View
Changeset View
Standalone View
Standalone View
src/gtkconfigkcmodule.cpp
Show All 30 Lines | |||||
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" | 38 | #include "iconthemesmodel.h" | ||
39 | #include "fontshelpers.h" | | |||
40 | #include <QSortFilterProxyModel> | 39 | #include <QSortFilterProxyModel> | ||
41 | #include <qstringlistmodel.h> | 40 | #include <qstringlistmodel.h> | ||
42 | #include <QSvgRenderer> | 41 | #include <QSvgRenderer> | ||
43 | #include <QPainter> | 42 | #include <QPainter> | ||
44 | 43 | | |||
45 | K_PLUGIN_FACTORY_WITH_JSON(GTKConfigKCModuleFactory, "kde-gtk-config.json", registerPlugin<GTKConfigKCModule>();) | 44 | K_PLUGIN_FACTORY_WITH_JSON(GTKConfigKCModuleFactory, "kde-gtk-config.json", registerPlugin<GTKConfigKCModule>();) | ||
46 | 45 | | |||
47 | QMap<QString, int> gtkToolbarInit() | 46 | QMap<QString, int> gtkToolbarInit() | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 64 | { | |||
121 | 120 | | |||
122 | //UI changes | 121 | //UI changes | ||
123 | connect(ui->cb_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 122 | connect(ui->cb_theme, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
124 | connect(ui->cb_theme_gtk3, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 123 | connect(ui->cb_theme_gtk3, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
125 | connect(ui->checkBox_theme_gtk3_prefer_dark, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | 124 | connect(ui->checkBox_theme_gtk3_prefer_dark, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | ||
126 | connect(ui->cb_cursor, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 125 | connect(ui->cb_cursor, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
127 | connect(ui->cb_icon, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 126 | connect(ui->cb_icon, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
128 | connect(ui->cb_icon_fallback ,SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | 127 | 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())); | 128 | connect(ui->cb_toolbar_icons, SIGNAL(currentIndexChanged(int)), this, SLOT(appChanged())); | ||
131 | connect(ui->checkBox_icon_gtk_menus, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | 129 | connect(ui->checkBox_icon_gtk_menus, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | ||
132 | connect(ui->checkBox_icon_gtk_buttons, &QAbstractButton::clicked, this, >KConfigKCModule::appChanged); | 130 | 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())); | 131 | connect(ui->buttonGroup_primary_button_warps_slider, SIGNAL(buttonToggled(QAbstractButton*, bool)), this, SLOT(appChanged())); | ||
134 | 132 | | |||
135 | //preview updates | 133 | //preview updates | ||
136 | connect(ui->cb_icon_fallback, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); | 134 | connect(ui->cb_icon_fallback, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); | ||
137 | connect(ui->cb_icon, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); | 135 | connect(ui->cb_icon, SIGNAL(activated(QString)), this, SLOT(makePreviewIconTheme())); | ||
Show All 26 Lines | |||||
164 | void GTKConfigKCModule::syncUI() | 162 | void GTKConfigKCModule::syncUI() | ||
165 | { | 163 | { | ||
166 | appareance->setThemeGtk3(ui->cb_theme_gtk3->currentText()); | 164 | appareance->setThemeGtk3(ui->cb_theme_gtk3->currentText()); | ||
167 | appareance->setTheme(ui->cb_theme->currentText()); | 165 | appareance->setTheme(ui->cb_theme->currentText()); | ||
168 | appareance->setApplicationPreferDarkTheme(ui->checkBox_theme_gtk3_prefer_dark->isChecked()); | 166 | appareance->setApplicationPreferDarkTheme(ui->checkBox_theme_gtk3_prefer_dark->isChecked()); | ||
169 | appareance->setCursor(ui->cb_cursor->itemData(ui->cb_cursor->currentIndex(), CursorThemesModel::DirNameRole).toString()); | 167 | appareance->setCursor(ui->cb_cursor->itemData(ui->cb_cursor->currentIndex(), CursorThemesModel::DirNameRole).toString()); | ||
170 | appareance->setIcon(ui->cb_icon->itemData(ui->cb_icon->currentIndex(), IconThemesModel::DirNameRole).toString()); | 168 | 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()); | 169 | appareance->setIconFallback(ui->cb_icon_fallback->itemData(ui->cb_icon_fallback->currentIndex(), IconThemesModel::DirNameRole).toString()); | ||
172 | appareance->setFont(fontToString(ui->font->font())); | | |||
173 | 170 | | |||
174 | appareance->setToolbarStyle(gtkToolbar.key(ui->cb_toolbar_icons->currentIndex())); | 171 | appareance->setToolbarStyle(gtkToolbar.key(ui->cb_toolbar_icons->currentIndex())); | ||
175 | appareance->setShowIconsInButtons(ui->checkBox_icon_gtk_buttons->isChecked()); | 172 | appareance->setShowIconsInButtons(ui->checkBox_icon_gtk_buttons->isChecked()); | ||
176 | appareance->setShowIconsInMenus(ui->checkBox_icon_gtk_menus->isChecked()); | 173 | appareance->setShowIconsInMenus(ui->checkBox_icon_gtk_menus->isChecked()); | ||
177 | appareance->setPrimaryButtonWarpsSlider(ui->buttonGroup_primary_button_warps_slider->checkedButton() == ui->radioButton_warp); | 174 | appareance->setPrimaryButtonWarpsSlider(ui->buttonGroup_primary_button_warps_slider->checkedButton() == ui->radioButton_warp); | ||
178 | } | 175 | } | ||
179 | 176 | | |||
180 | void GTKConfigKCModule::showThemeGHNS() | 177 | void GTKConfigKCModule::showThemeGHNS() | ||
Show All 11 Lines | 188 | if(d.exec()) { | |||
192 | refreshLists(); | 189 | refreshLists(); | ||
193 | } | 190 | } | ||
194 | } | 191 | } | ||
195 | 192 | | |||
196 | void GTKConfigKCModule::refreshLists() | 193 | void GTKConfigKCModule::refreshLists() | ||
197 | { | 194 | { | ||
198 | refreshThemesUi(true); | 195 | refreshThemesUi(true); | ||
199 | 196 | | |||
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()]); | 197 | ui->cb_toolbar_icons->setCurrentIndex(gtkToolbar[appareance->getToolbarStyle()]); | ||
205 | 198 | | |||
206 | ui->checkBox_icon_gtk_buttons->setChecked(appareance->getShowIconsInButtons()); | 199 | ui->checkBox_icon_gtk_buttons->setChecked(appareance->getShowIconsInButtons()); | ||
207 | ui->checkBox_icon_gtk_menus->setChecked(appareance->getShowIconsInMenus()); | 200 | ui->checkBox_icon_gtk_menus->setChecked(appareance->getShowIconsInMenus()); | ||
208 | const bool warps = appareance->getPrimaryButtonWarpsSlider(); | 201 | const bool warps = appareance->getPrimaryButtonWarpsSlider(); | ||
209 | ui->radioButton_warp->setChecked(warps); | 202 | ui->radioButton_warp->setChecked(warps); | ||
210 | ui->radioButton_dont_warp->setChecked(!warps); | 203 | ui->radioButton_dont_warp->setChecked(!warps); | ||
211 | 204 | | |||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Line(s) | |||||
372 | } | 365 | } | ||
373 | 366 | | |||
374 | void GTKConfigKCModule::defaults() | 367 | void GTKConfigKCModule::defaults() | ||
375 | { | 368 | { | ||
376 | refreshThemesUi(false); | 369 | refreshThemesUi(false); | ||
377 | 370 | | |||
378 | // qDebug() << "loading defaults..."; | 371 | // qDebug() << "loading defaults..."; | ||
379 | m_saveEnabled = false; | 372 | m_saveEnabled = false; | ||
380 | ui->font->setFont(font()); | | |||
381 | bool showIcons = !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); | 373 | bool showIcons = !QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus); | ||
382 | ui->checkBox_icon_gtk_buttons->setChecked(showIcons); | 374 | ui->checkBox_icon_gtk_buttons->setChecked(showIcons); | ||
383 | ui->checkBox_icon_gtk_menus->setChecked(showIcons); | 375 | ui->checkBox_icon_gtk_menus->setChecked(showIcons); | ||
384 | 376 | | |||
385 | // this makes it consistent with Qt apps and restores the old Gtk behavior | 377 | // this makes it consistent with Qt apps and restores the old Gtk behavior | ||
386 | ui->radioButton_dont_warp->setChecked(true); | 378 | ui->radioButton_dont_warp->setChecked(true); | ||
387 | 379 | | |||
388 | setComboItem(ui->cb_theme, QStringList("oxygen-gtk") << "Clearlooks"); | 380 | setComboItem(ui->cb_theme, QStringList("oxygen-gtk") << "Clearlooks"); | ||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |