aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-theme-engine
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-09-11 14:53:32 -0400
committerKen Moore <ken@ixsystems.com>2017-09-11 14:53:32 -0400
commit91b49f991eaa2c2c6ba50ec129db9f7c0405c14d (patch)
treecba9d453d0c35dee10b2abc088e6cdcadaca9839 /src-qt5/core/lumina-theme-engine
parentAdd support for a "desktop_stylesheets" config knob which will activated if t... (diff)
downloadlumina-91b49f991eaa2c2c6ba50ec129db9f7c0405c14d.tar.gz
lumina-91b49f991eaa2c2c6ba50ec129db9f7c0405c14d.tar.bz2
lumina-91b49f991eaa2c2c6ba50ec129db9f7c0405c14d.zip
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.
Diffstat (limited to 'src-qt5/core/lumina-theme-engine')
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp14
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h2
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp3
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp18
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h3
5 files changed, 33 insertions, 7 deletions
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; i<dirs.length(); i++){ dirs[i].append("/lthemeengine/desktop_qss/"); }
+ if(dirs.isEmpty()){ dirs << LTHEMEENGINE_DATADIR"/lthemeengine/desktop_qss/"; } //no XDG settings - use the hardcoded path
+ return dirs;
+ }
+
QString lthemeengine::userColorSchemePath(){
return configPath() + "colors/";
}
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h
index 8a466ed9..06dd3e09 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h
@@ -21,6 +21,8 @@ public:
static QStringList iconPaths();
static QString userStyleSheetPath();
static QStringList sharedStyleSheetPath();
+ static QString userDesktopStyleSheetPath();
+ static QStringList sharedDesktopStyleSheetPath();
static QString userColorSchemePath();
static QStringList sharedColorSchemePath();
static QString systemLanguageID();
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp
index 719a0f49..91db14ee 100644
--- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp
+++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp
@@ -16,7 +16,8 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent), m_ui(new Ui::MainWind
m_ui->tabWidget->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
bgstack15