You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
323 lines
11 KiB
323 lines
11 KiB
Description: Add optional overriding of icon theme.
|
|
Author: Walter Lapchynski <wxl@ubuntu.com>
|
|
Last-Updated: 2018-08-22
|
|
Applied-Upstream: https://github.com/lxqt/lxqt-panel/pull/674/commits/1a70479ed931e07a67a182223426328ab3fcbeff
|
|
--- a/panel/config/configpaneldialog.cpp
|
|
+++ b/panel/config/configpaneldialog.cpp
|
|
@@ -56,3 +56,8 @@ void ConfigPanelDialog::showConfigPlugin
|
|
{
|
|
showPage(mPluginsPage);
|
|
}
|
|
+
|
|
+void ConfigPanelDialog::updateIconThemeSettings()
|
|
+{
|
|
+ mPanelPage->updateIconThemeSettings();
|
|
+}
|
|
--- a/panel/config/configpaneldialog.h
|
|
+++ b/panel/config/configpaneldialog.h
|
|
@@ -43,6 +43,7 @@ public:
|
|
|
|
void showConfigPanelPage();
|
|
void showConfigPluginsPage();
|
|
+ void updateIconThemeSettings();
|
|
|
|
private:
|
|
ConfigPanelWidget *mPanelPage;
|
|
--- a/panel/config/configpanelwidget.cpp
|
|
+++ b/panel/config/configpanelwidget.cpp
|
|
@@ -57,6 +57,7 @@ ConfigPanelWidget::ConfigPanelWidget(LXQ
|
|
|
|
fillComboBox_position();
|
|
fillComboBox_alignment();
|
|
+ fillComboBox_icon();
|
|
|
|
mOldPanelSize = mPanel->panelSize();
|
|
mOldIconSize = mPanel->iconSize();
|
|
@@ -115,6 +116,9 @@ ConfigPanelWidget::ConfigPanelWidget(LXQ
|
|
connect(ui->slider_opacity, &QSlider::valueChanged, this, &ConfigPanelWidget::editChanged);
|
|
|
|
connect(ui->checkBox_reserveSpace, &QAbstractButton::toggled, [this](bool checked) { mPanel->setReserveSpace(checked, true); });
|
|
+
|
|
+ connect(ui->groupBox_icon, &QGroupBox::clicked, this, &ConfigPanelWidget::editChanged);
|
|
+ connect(ui->comboBox_icon, QOverload<int>::of(&QComboBox::activated), this, &ConfigPanelWidget::editChanged);
|
|
}
|
|
|
|
|
|
@@ -211,6 +215,59 @@ void ConfigPanelWidget::fillComboBox_ali
|
|
};
|
|
}
|
|
|
|
+/************************************************
|
|
+ *
|
|
+ ************************************************/
|
|
+void ConfigPanelWidget::fillComboBox_icon()
|
|
+{
|
|
+ ui->groupBox_icon->setChecked(!mPanel->iconTheme().isEmpty());
|
|
+
|
|
+ QStringList themeList;
|
|
+ QStringList processed;
|
|
+ const QStringList baseDirs = QIcon::themeSearchPaths();
|
|
+ for (const QString &baseDirName : baseDirs)
|
|
+ {
|
|
+ QDir baseDir(baseDirName);
|
|
+ if (!baseDir.exists())
|
|
+ continue;
|
|
+ const QFileInfoList dirs = baseDir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name);
|
|
+ for (const QFileInfo &dir : dirs)
|
|
+ {
|
|
+ if (!processed.contains(dir.canonicalFilePath()))
|
|
+ {
|
|
+ processed << dir.canonicalFilePath();
|
|
+ QDir Dir(dir.canonicalFilePath());
|
|
+ QSettings file(Dir.absoluteFilePath(QStringLiteral("index.theme")), QSettings::IniFormat);
|
|
+ if (file.status() == QSettings::NoError
|
|
+ && !file.value(QStringLiteral("Icon Theme/Directories")).toStringList().join(QLatin1Char(' ')).isEmpty()
|
|
+ && !file.value(QStringLiteral("Icon Theme/Hidden"), false).toBool())
|
|
+ {
|
|
+ themeList << Dir.dirName();
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ if (!themeList.isEmpty())
|
|
+ {
|
|
+ themeList.sort();
|
|
+ ui->comboBox_icon->insertItems(0, themeList);
|
|
+ QString curTheme = QIcon::themeName();
|
|
+ if (!curTheme.isEmpty())
|
|
+ ui->comboBox_icon->setCurrentText(curTheme);
|
|
+ }
|
|
+}
|
|
+
|
|
+
|
|
+/************************************************
|
|
+ *
|
|
+ ************************************************/
|
|
+void ConfigPanelWidget::updateIconThemeSettings()
|
|
+{
|
|
+ ui->groupBox_icon->setChecked(!mPanel->iconTheme().isEmpty());
|
|
+ QString curTheme = QIcon::themeName();
|
|
+ if (!curTheme.isEmpty())
|
|
+ ui->comboBox_icon->setCurrentText(curTheme);
|
|
+}
|
|
|
|
/************************************************
|
|
*
|
|
@@ -284,6 +341,11 @@ void ConfigPanelWidget::editChanged()
|
|
|
|
QString image = ui->checkBox_customBgImage->isChecked() ? ui->lineEdit_customBgImage->text() : QString();
|
|
mPanel->setBackgroundImage(image, true);
|
|
+
|
|
+ if (!ui->groupBox_icon->isChecked())
|
|
+ mPanel->setIconTheme(QString());
|
|
+ else if (!ui->comboBox_icon->currentText().isEmpty())
|
|
+ mPanel->setIconTheme(ui->comboBox_icon->currentText());
|
|
}
|
|
|
|
|
|
--- a/panel/config/configpanelwidget.h
|
|
+++ b/panel/config/configpanelwidget.h
|
|
@@ -49,6 +49,7 @@ public:
|
|
|
|
int screenNum() const { return mScreenNum; }
|
|
ILXQtPanel::Position position() const { return mPosition; }
|
|
+ void updateIconThemeSettings();
|
|
|
|
signals:
|
|
void changed();
|
|
@@ -73,6 +74,7 @@ private:
|
|
void addPosition(const QString& name, int screen, LXQtPanel::Position position);
|
|
void fillComboBox_position();
|
|
void fillComboBox_alignment();
|
|
+ void fillComboBox_icon();
|
|
int indexForPosition(int screen, ILXQtPanel::Position position);
|
|
int getMaxLength();
|
|
|
|
--- a/panel/config/configpanelwidget.ui
|
|
+++ b/panel/config/configpanelwidget.ui
|
|
@@ -555,6 +555,44 @@
|
|
</layout>
|
|
</widget>
|
|
</item>
|
|
+ <item>
|
|
+ <widget class="QGroupBox" name="groupBox_icon">
|
|
+ <property name="toolTip">
|
|
+ <string>A partial workaround for widget styles that
|
|
+cannot give a separate theme to the panel.
|
|
+
|
|
+You might also want to disable:
|
|
+
|
|
+LXQt Appearance Configuration →
|
|
+Icons Theme →
|
|
+Colorize icons based on widget style (palette)</string>
|
|
+ </property>
|
|
+ <property name="title">
|
|
+ <string>Override icon &theme</string>
|
|
+ </property>
|
|
+ <property name="checkable">
|
|
+ <bool>true</bool>
|
|
+ </property>
|
|
+ <property name="checked">
|
|
+ <bool>false</bool>
|
|
+ </property>
|
|
+ <layout class="QFormLayout" name="formLayout_2">
|
|
+ <property name="formAlignment">
|
|
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
+ </property>
|
|
+ <item row="0" column="0">
|
|
+ <widget class="QLabel" name="label_3">
|
|
+ <property name="text">
|
|
+ <string>Icon theme for panels:</string>
|
|
+ </property>
|
|
+ </widget>
|
|
+ </item>
|
|
+ <item row="0" column="1">
|
|
+ <widget class="QComboBox" name="comboBox_icon"/>
|
|
+ </item>
|
|
+ </layout>
|
|
+ </widget>
|
|
+ </item>
|
|
</layout>
|
|
</widget>
|
|
<resources/>
|
|
--- a/panel/lxqtpanel.cpp
|
|
+++ b/panel/lxqtpanel.cpp
|
|
@@ -1354,6 +1354,28 @@ void LXQtPanel::setShowDelay(int showDel
|
|
saveSettings(true);
|
|
}
|
|
|
|
+QString LXQtPanel::iconTheme() const
|
|
+{
|
|
+ return mSettings->value("iconTheme").toString();
|
|
+}
|
|
+
|
|
+void LXQtPanel::setIconTheme(const QString& iconTheme)
|
|
+{
|
|
+ LXQtPanelApplication *a = reinterpret_cast<LXQtPanelApplication*>(qApp);
|
|
+ a->setIconTheme(iconTheme);
|
|
+}
|
|
+
|
|
+void LXQtPanel::updateConfigDialog() const
|
|
+{
|
|
+ if (!mConfigDialog.isNull() && mConfigDialog->isVisible())
|
|
+ {
|
|
+ mConfigDialog->updateIconThemeSettings();
|
|
+ const QList<QWidget*> widgets = mConfigDialog->findChildren<QWidget*>();
|
|
+ for (QWidget *widget : widgets)
|
|
+ widget->update();
|
|
+ }
|
|
+}
|
|
+
|
|
bool LXQtPanel::isPluginSingletonAndRunnig(QString const & pluginId) const
|
|
{
|
|
Plugin const * plugin = mPlugins->pluginByID(pluginId);
|
|
--- a/panel/lxqtpanel.h
|
|
+++ b/panel/lxqtpanel.h
|
|
@@ -222,6 +222,7 @@ public:
|
|
bool hidable() const { return mHidable; }
|
|
int animationTime() const { return mAnimationTime; }
|
|
int showDelay() const { return mShowDelayTimer.interval(); }
|
|
+ QString iconTheme() const;
|
|
|
|
/*!
|
|
* \brief Checks if a given Plugin is running and has the
|
|
@@ -232,6 +233,11 @@ public:
|
|
* ILXQtPanelPlugin::SingleInstance flag set, false otherwise.
|
|
*/
|
|
bool isPluginSingletonAndRunnig(QString const & pluginId) const;
|
|
+ /*!
|
|
+ * \brief Updates the config dialog. Used for updating its icons
|
|
+ * when the panel-specific icon theme changes.
|
|
+ */
|
|
+ void updateConfigDialog() const;
|
|
|
|
public slots:
|
|
/**
|
|
@@ -299,6 +305,7 @@ public slots:
|
|
void setHidable(bool hidable, bool save); //!< \sa setPanelSize()
|
|
void setAnimationTime(int animationTime, bool save); //!< \sa setPanelSize()
|
|
void setShowDelay(int showDelay, bool save); //!< \sa setPanelSize()
|
|
+ void setIconTheme(const QString& iconTheme);
|
|
|
|
/**
|
|
* @brief Saves the current configuration, i.e. writes the current
|
|
@@ -549,7 +556,7 @@ private:
|
|
* @brief Stores if mLength is stored in pixels or relative to the
|
|
* screen size in percents. If true, the length is stored in percents,
|
|
* otherwise in pixels.
|
|
- *
|
|
+ *
|
|
* \sa mLength
|
|
*/
|
|
bool mLengthInPercents;
|
|
--- a/panel/lxqtpanelapplication.cpp
|
|
+++ b/panel/lxqtpanelapplication.cpp
|
|
@@ -117,6 +117,15 @@ LXQtPanelApplication::LXQtPanelApplicati
|
|
|
|
QStringList panels = d->mSettings->value("panels").toStringList();
|
|
|
|
+ // WARNING: Giving a separate icon theme to the panel is wrong and has side effects.
|
|
+ // However, it is optional and can be used as the last resort for avoiding a low
|
|
+ // contrast in the case of symbolic SVG icons. (The correct way of doing that is
|
|
+ // using a Qt widget style that can assign a separate theme/QPalette to the panel.)
|
|
+ mGlobalIconTheme = QIcon::themeName();
|
|
+ const QString iconTheme = d->mSettings->value("iconTheme").toString();
|
|
+ if (!iconTheme.isEmpty())
|
|
+ QIcon::setThemeName(iconTheme);
|
|
+
|
|
if (panels.isEmpty())
|
|
{
|
|
panels << "panel1";
|
|
@@ -280,3 +289,21 @@ bool LXQtPanelApplication::isPluginSingl
|
|
|
|
return false;
|
|
}
|
|
+
|
|
+// See LXQtPanelApplication::LXQtPanelApplication for why this isn't good.
|
|
+void LXQtPanelApplication::setIconTheme(const QString &iconTheme)
|
|
+{
|
|
+ Q_D(LXQtPanelApplication);
|
|
+
|
|
+ d->mSettings->setValue("iconTheme", iconTheme == mGlobalIconTheme ? QString() : iconTheme);
|
|
+ QString newTheme = iconTheme.isEmpty() ? mGlobalIconTheme : iconTheme;
|
|
+ if (newTheme != QIcon::themeName())
|
|
+ {
|
|
+ QIcon::setThemeName(newTheme);
|
|
+ for(LXQtPanel* panel : qAsConst(mPanels))
|
|
+ {
|
|
+ panel->update();
|
|
+ panel->updateConfigDialog();
|
|
+ }
|
|
+ }
|
|
+}
|
|
--- a/panel/lxqtpanelapplication.h
|
|
+++ b/panel/lxqtpanelapplication.h
|
|
@@ -69,12 +69,14 @@ public:
|
|
explicit LXQtPanelApplication(int& argc, char** argv);
|
|
~LXQtPanelApplication();
|
|
|
|
+ void setIconTheme(const QString &iconTheme);
|
|
+
|
|
/*!
|
|
* \brief Determines the number of LXQtPanel objects
|
|
* \return the current number of LXQtPanel objects
|
|
*/
|
|
- int count() { return mPanels.count(); }
|
|
-
|
|
+ int count() const { return mPanels.count(); }
|
|
+
|
|
/*!
|
|
* \brief Checks if a given Plugin is running and has the
|
|
* ILXQtPanelPlugin::SingleInstance flag set. As Plugins are added to
|
|
@@ -123,6 +125,10 @@ private:
|
|
*/
|
|
QList<LXQtPanel*> mPanels;
|
|
/*!
|
|
+ * \brief The global icon theme used by all apps (except for panels perhaps).
|
|
+ */
|
|
+ QString mGlobalIconTheme;
|
|
+ /*!
|
|
* \brief Creates a new LXQtPanel with the given name and connects the
|
|
* appropriate signals and slots.
|
|
* This method can be used at application startup.
|