From 20f4eae9ba21030e5f1758e4b4ce7b9449ad7cfd Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 11 Sep 2017 14:29:14 -0400 Subject: Add support for a "desktop_stylesheets" config knob which will activated if the application loading the theme engine is called "lumina-desktop". --- .../src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src-qt5/core/lumina-theme-engine') diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp index 453bde1d..692223c7 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp @@ -211,7 +211,9 @@ void lthemeenginePlatformTheme::readSettings(){ } //load style sheets #ifdef QT_WIDGETS_LIB - QStringList qssPaths = settings.value("stylesheets").toStringList(); + QStringList qssPaths; + if(qApp->applicationName()=="lumina-desktop"){ qssPaths << settings.value("desktop_stylesheets").toStringList(); } + qssPaths << settings.value("stylesheets").toStringList(); m_userStyleSheet = loadStyleSheets(qssPaths); #endif settings.endGroup(); -- cgit From 91b49f991eaa2c2c6ba50ec129db9f7c0405c14d Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 11 Sep 2017 14:53:32 -0400 Subject: Rename the "stylesheets" tab and split it up into two tabs: "Application Theme" and "Desktop Theme". Also re-work the qsspage class a bit to understand whether it is running in "desktop" or "application" mode. --- .../src/lthemeengine/lthemeengine.cpp | 14 ++++++++++++++ .../src/lthemeengine/lthemeengine.h | 2 ++ .../src/lthemeengine/mainwindow.cpp | 3 ++- .../lumina-theme-engine/src/lthemeengine/qsspage.cpp | 18 +++++++++++++----- .../lumina-theme-engine/src/lthemeengine/qsspage.h | 3 ++- 5 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src-qt5/core/lumina-theme-engine') diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp index fdeb8966..701745c4 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp @@ -53,6 +53,20 @@ QStringList lthemeengine::sharedStyleSheetPath(){ return dirs; } +QString lthemeengine::userDesktopStyleSheetPath(){ + return configPath() + "desktop_qss/"; +} + +QStringList lthemeengine::sharedDesktopStyleSheetPath(){ + QStringList dirs; + dirs << QString(getenv("XDG_CONFIG_HOME")); + dirs << QString(getenv("XDG_CONFIG_DIRS")).split(":"); + dirs << QString(getenv("XDG_DATA_DIRS")).split(":"); + for(int i=0; itabWidget->addTab(new IconThemePage(this), tr("Icon Theme")); m_ui->tabWidget->addTab(new InterfacePage(this), tr("Interface")); #ifdef USE_WIDGETS - m_ui->tabWidget->addTab(new QSSPage(this), tr("Style Sheets")); + m_ui->tabWidget->addTab(new QSSPage(this, false), tr("Application Theme")); + m_ui->tabWidget->addTab(new QSSPage(this, true), tr("Desktop Theme")); #endif QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); restoreGeometry(settings.value("SettingsWindow/geometry").toByteArray()); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp index 2cf0f221..681de6c9 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp @@ -12,8 +12,9 @@ #define QSS_FULL_PATH_ROLE (Qt::ItemDataRole(Qt::UserRole)) #define QSS_WRITABLE_ROLE (Qt::ItemDataRole(Qt::UserRole + 1)) -QSSPage::QSSPage(QWidget *parent) : TabPage(parent), m_ui(new Ui::QSSPage){ +QSSPage::QSSPage(QWidget *parent, bool desktop) : TabPage(parent), m_ui(new Ui::QSSPage){ m_ui->setupUi(this); + desktop_qss = desktop; QDir("/").mkpath(lthemeengine::userStyleSheetPath()); m_menu = new QMenu(this); m_menu->addAction(QIcon::fromTheme("accessories-text-editor"), tr("Edit"), this, SLOT(on_editButton_clicked())); @@ -37,7 +38,8 @@ void QSSPage::writeSettings(){ for(int i = 0; i < m_ui->qssListWidget->count(); ++i){ QListWidgetItem *item = m_ui->qssListWidget->item(i); if(item->checkState() == Qt::Checked){ styleSheets << item->data(QSS_FULL_PATH_ROLE).toString(); } - settings.setValue("Interface/stylesheets", styleSheets); + if(desktop_qss){ settings.setValue("Interface/desktop_stylesheets", styleSheets); } + else{ settings.setValue("Interface/stylesheets", styleSheets); } } } @@ -58,7 +60,9 @@ void QSSPage::on_createButton_clicked(){ QString name = QInputDialog::getText(this, tr("Enter Style Sheet Name"), tr("File name:")); if(name.isEmpty()){ return; } if(!name.endsWith(".qss", Qt::CaseInsensitive)){ name.append(".qss"); } - QString filePath = lthemeengine::userStyleSheetPath() + name; + QString filePath; + if(desktop_qss){ filePath = lthemeengine::userDesktopStyleSheetPath() + name; } + else{ filePath = lthemeengine::userStyleSheetPath() + name; } if(QFile::exists(filePath)){ QMessageBox::warning(this, tr("Error"), tr("The file \"%1\" already exists").arg(filePath)); return; @@ -95,9 +99,13 @@ void QSSPage::on_removeButton_clicked(){ void QSSPage::readSettings(){ //load stylesheets m_ui->qssListWidget->clear(); - findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); + if(desktop_qss){ findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); } + else{findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); } QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); - QStringList styleSheets = settings.value("Interface/stylesheets").toStringList(); + QStringList styleSheets; + if(desktop_qss){ styleSheets = settings.value("Interface/desktop_stylesheets").toStringList(); } + else{ styleSheets = settings.value("Interface/stylesheets").toStringList(); } + for(int i = 0; i < m_ui->qssListWidget->count(); ++i){ QListWidgetItem *item = m_ui->qssListWidget->item(i); if(styleSheets.contains(item->data(QSS_FULL_PATH_ROLE).toString())){ item->setCheckState(Qt::Checked); } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h index 5e924ad9..76417ddf 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h @@ -15,7 +15,7 @@ class QSSPage : public TabPage Q_OBJECT public: - explicit QSSPage(QWidget *parent = 0); + explicit QSSPage(QWidget *parent = 0, bool desktop = false); ~QSSPage(); void writeSettings(); @@ -33,6 +33,7 @@ private: void findStyleSheets(QStringList paths); Ui::QSSPage *m_ui; QMenu *m_menu; + bool desktop_qss; }; #endif // QSSPAGE_H -- cgit