From b6134440bc9501ac9df8ad61d5ea7cdbc8a0d147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 18 May 2018 03:11:24 +0200 Subject: [PATCH] fix fallback icon theme --- fm/src/common.h | 30 ++++++++++++++++++++++++++++++ fm/src/mainwindow.cpp | 9 ++++++++- fm/src/settingsdialog.cpp | 22 ++++++++++++++-------- fm/src/settingsdialog.h | 2 +- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/fm/src/common.h b/fm/src/common.h index 989ee41..ca58eda 100644 --- a/fm/src/common.h +++ b/fm/src/common.h @@ -12,6 +12,7 @@ #include #include #include +#include #define FM_MAJOR 6 @@ -268,6 +269,35 @@ class Common } return result; } + static QStringList getIconThemes() + { + QStringList result; + for (int i=0;ivalue("clearCache").toBool()) { + qDebug() << "clear cache"; + Common::removeFileCache(); + Common::removeFolderCache(); + settings->setValue("clearCache", false); + } + QString temp = QIcon::themeName(); - if (temp.isEmpty()) { temp = settings->value("fallbackTheme").toString(); } + if (temp.isEmpty() || temp == "hicolor") { temp = settings->value("fallbackTheme").toString(); } if(temp.isEmpty() || temp == "hicolor") { if(QFile::exists(QDir::homePath() + "/" + ".gtkrc-2.0")) { // try gtk-2.0 QSettings gtkFile(QDir::homePath() + "/.gtkrc-2.0",QSettings::IniFormat,this); diff --git a/fm/src/settingsdialog.cpp b/fm/src/settingsdialog.cpp index 0b261e7..0c64722 100644 --- a/fm/src/settingsdialog.cpp +++ b/fm/src/settingsdialog.cpp @@ -105,8 +105,8 @@ QWidget *SettingsDialog::createGeneralSettings() { checkThumbs = new QCheckBox(grpAppear); checkHidden = new QCheckBox(grpAppear); checkTabs = new QCheckBox(grpAppear); - //cmbIconTheme = new QComboBox(grpAppear); - //layoutAppear->addRow(tr("Icon theme:"), cmbIconTheme); + cmbIconTheme = new QComboBox(grpAppear); + layoutAppear->addRow(tr("Fallback Icon theme:"), cmbIconTheme); layoutAppear->addRow(tr("Show thumbnails: "), checkThumbs); layoutAppear->addRow(tr("Show hidden files: "), checkHidden); layoutAppear->addRow(tr("Tabs on top: "), checkTabs); @@ -518,15 +518,16 @@ void SettingsDialog::readSettings() { mimeUtilsPtr->setDefaultsFileName(cmbDefaultMimeApps->currentText()); // Load icon themes - /*QString currentTheme = settingsPtr->value("forceTheme").toString(); - QDirIterator it("/usr/share/icons", QDir::Dirs | QDir::NoDotAndDotDot); + QString currentTheme = settingsPtr->value("fallbackTheme").toString(); + //QDirIterator it("/usr/share/icons", QDir::Dirs | QDir::NoDotAndDotDot); QStringList iconThemes; - while (it.hasNext()) { + iconThemes << Common::getIconThemes(); + /*while (it.hasNext()) { it.next(); iconThemes.append(it.fileName()); - } + }*/ cmbIconTheme->addItems(iconThemes); - cmbIconTheme->setCurrentIndex(iconThemes.indexOf(currentTheme));*/ + cmbIconTheme->setCurrentIndex(iconThemes.indexOf(currentTheme)); // Read custom actions checkOutput->setChecked(settingsPtr->value("showActionOutput", true).toBool()); @@ -733,7 +734,12 @@ bool SettingsDialog::saveSettings() { settingsPtr->setValue("hiddenMode", checkHidden->isChecked()); settingsPtr->setValue("confirmDelete", checkDelete->isChecked()); //settingsPtr->setValue("term", editTerm->text()); - //settingsPtr->setValue("forceTheme", cmbIconTheme->currentText()); + if (cmbIconTheme->currentText() != settingsPtr->value("fallbackTheme").toString()) { + //QIcon::setThemeName(cmbIconTheme->currentText()); + settingsPtr->setValue("clearCache", true); + QMessageBox::warning(this, tr("Restart to apply settings"), tr("You must restart to apply theme settings")); + } + settingsPtr->setValue("fallbackTheme", cmbIconTheme->currentText()); settingsPtr->setValue("defMimeAppsFile", cmbDefaultMimeApps->currentText()); // Custom actions diff --git a/fm/src/settingsdialog.h b/fm/src/settingsdialog.h index d7f1d97..dec9a58 100644 --- a/fm/src/settingsdialog.h +++ b/fm/src/settingsdialog.h @@ -63,7 +63,7 @@ protected slots: QCheckBox* checkTabs; QCheckBox* checkDelete; //QLineEdit* editTerm; - //QComboBox* cmbIconTheme; + QComboBox* cmbIconTheme; QComboBox* cmbDefaultMimeApps; QTreeWidget *actionsWidget;