diff options
author | Weblate <noreply@weblate.org> | 2017-08-17 16:02:28 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2017-08-17 16:02:28 +0000 |
commit | 073b18e631b0837ce4126d1f23a384d5e64266b6 (patch) | |
tree | 9ca53c29b4f6a2f4ebb931753fe90bd4a478a802 /src-qt5/core/lumina-theme-engine/src | |
parent | Translated using Weblate (Swedish) (diff) | |
parent | Clean up more of the lumina-xconfig tiling options. much nicer now. (diff) | |
download | lumina-073b18e631b0837ce4126d1f23a384d5e64266b6.tar.gz lumina-073b18e631b0837ce4126d1f23a384d5e64266b6.tar.bz2 lumina-073b18e631b0837ce4126d1f23a384d5e64266b6.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-theme-engine/src')
15 files changed, 126 insertions, 45 deletions
diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengine-qtplugin.pro b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengine-qtplugin.pro index a186cd49..3dca4fd1 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengine-qtplugin.pro +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengine-qtplugin.pro @@ -2,7 +2,7 @@ include(../../lthemeengine.pri) TEMPLATE = lib TARGET = lthemeengine -CONFIG += plugin +CONFIG *= plugin greaterThan(QT_MINOR_VERSION, 7) { QT += gui-private theme_support-private 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 9d6c9bea..453bde1d 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 @@ -70,7 +70,7 @@ QPlatformSystemTrayIcon *lthemeenginePlatformTheme::createPlatformSystemTrayIcon QDBusMenuConnection conn; m_dbusTrayAvailable = conn.isStatusNotifierHostRegistered(); m_checkDBusTray = false; - qCDebug(llthemeengine) << "D-Bus system tray:" << (m_dbusTrayAvailable ? "yes" : "no"); + //qCDebug(llthemeengine) << "D-Bus system tray:" << (m_dbusTrayAvailable ? "yes" : "no"); } return (m_dbusTrayAvailable ? new QDBusTrayIcon() : nullptr); } @@ -177,10 +177,10 @@ void lthemeenginePlatformTheme::readSettings(){ settings.beginGroup("Appearance"); m_style = settings.value("style", "Fusion").toString(); if(settings.value("custom_palette", false).toBool()){ - QString schemePath = settings.value("color_scheme_path").toString(); + QString schemePath = settings.value("color_scheme_path","airy").toString(); m_customPalette = new QPalette(loadColorScheme(schemePath)); } - m_iconTheme = settings.value("icon_theme").toString(); + m_iconTheme = settings.value("icon_theme", "material-design-light").toString(); settings.endGroup(); settings.beginGroup("Fonts"); m_generalFont = settings.value("general", QPlatformTheme::font(QPlatformTheme::SystemFont)).value<QFont>(); @@ -237,7 +237,20 @@ QString lthemeenginePlatformTheme::loadStyleSheets(const QStringList &paths){ return content; } -QPalette lthemeenginePlatformTheme::loadColorScheme(const QString &filePath){ +QPalette lthemeenginePlatformTheme::loadColorScheme(QString filePath){ + if(!filePath.contains("/") && !filePath.endsWith(".conf") && !filePath.isEmpty()){ + //relative theme name, auto-complete it + QStringList dirs; + dirs << getenv("XDG_CONFIG_HOME"); + dirs << QString(getenv("XDG_CONFIG_DIRS")).split(":"); + dirs << QString(getenv("XDG_DATA_DIRS")).split(":"); + QString relpath = "/lthemeengine/colors/%1.conf"; + relpath = relpath.arg(filePath); + for(int i=0; i<dirs.length(); i++){ + if(QFile::exists(dirs[i]+relpath)){ filePath = dirs[i]+relpath; break; } + } + } + QPalette customPalette; QSettings settings(filePath, QSettings::IniFormat); settings.beginGroup("ColorScheme"); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.h index 5313b73e..17323328 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.h @@ -65,7 +65,7 @@ private: bool hasWidgets(); #endif QString loadStyleSheets(const QStringList &paths); - QPalette loadColorScheme(const QString &filePath); + QPalette loadColorScheme(QString filePath); QString m_style, m_iconTheme, m_userStyleSheet, m_prevStyleSheet; QPalette *m_customPalette = nullptr; QFont m_generalFont, m_fixedFont; diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengine-style.pro b/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengine-style.pro index 0b40de64..0f68e7e4 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengine-style.pro +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengine-style.pro @@ -2,11 +2,11 @@ include(../../lthemeengine.pri) TEMPLATE = lib TARGET = lthemeengine-style -QT += widgets +QT *= widgets # Input -CONFIG += plugin +CONFIG *= plugin target.path = $$PLUGINDIR/styles INSTALLS += target diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.cpp index 4d585409..04ca6a0b 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.cpp @@ -190,8 +190,7 @@ void AppearancePage::readSettings(){ m_ui->customPaletteButton->setChecked(settings.value("custom_palette", false).toBool()); QString colorSchemePath = settings.value("color_scheme_path").toString(); QDir("/").mkpath(lthemeengine::userColorSchemePath()); - findColorSchemes(lthemeengine::userColorSchemePath()); - findColorSchemes(lthemeengine::sharedColorSchemePath().join(", ")); + findColorSchemes( QStringList() << lthemeengine::userColorSchemePath() << lthemeengine::sharedColorSchemePath()); if(m_ui->colorSchemeComboBox->count() == 0){ m_customPalette = palette(); //load fallback palette } @@ -223,12 +222,16 @@ void AppearancePage::setPalette(QWidget *w, QPalette p){ w->setPalette(p); } -void AppearancePage::findColorSchemes(const QString &path){ - QDir dir(path); - dir.setFilter(QDir::Files); - dir.setNameFilters(QStringList() << "*.conf"); - foreach (QFileInfo info, dir.entryInfoList()){ - m_ui->colorSchemeComboBox->addItem(info.baseName(), info.filePath()); +void AppearancePage::findColorSchemes(QStringList paths){ + paths.removeDuplicates(); + for(int i=0; i<paths.length(); i++){ + if( !QFile::exists(paths[i])){ continue; } + QDir dir(paths[i]); + dir.setFilter(QDir::Files); + dir.setNameFilters(QStringList() << "*.conf"); + foreach (QFileInfo info, dir.entryInfoList()){ + m_ui->colorSchemeComboBox->addItem(info.baseName(), info.filePath()); + } } } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.h index 23bab52f..3f0fa427 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.h @@ -35,7 +35,7 @@ private: void readSettings(); void setStyle(QWidget *w, QStyle *s); void setPalette(QWidget *w, QPalette p); - void findColorSchemes(const QString &path); + void findColorSchemes(QStringList paths); QPalette loadColorScheme(const QString &filePath); void createColorScheme(const QString &name, const QPalette &palette); Ui::AppearancePage *m_ui; 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 36b0c2fa..fdeb8966 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp @@ -6,6 +6,7 @@ #define LTHEMEENGINE_DATADIR "/usr/local/share" #endif +#include <QDebug> QString lthemeengine::configPath(){ return QDir::homePath() + "/.config/lthemeengine/"; @@ -46,7 +47,8 @@ QStringList lthemeengine::sharedStyleSheetPath(){ QStringList dirs; dirs << QString(getenv("XDG_CONFIG_HOME")); dirs << QString(getenv("XDG_CONFIG_DIRS")).split(":"); - for(int i=0; i<dirs.length(); i++){ dirs[i].append("/lthemeengine/colors/"); } + dirs << QString(getenv("XDG_DATA_DIRS")).split(":"); + for(int i=0; i<dirs.length(); i++){ dirs[i].append("/lthemeengine/qss/"); } if(dirs.isEmpty()){ dirs << LTHEMEENGINE_DATADIR"/lthemeengine/qss/"; } //no XDG settings - use the hardcoded path return dirs; } @@ -59,8 +61,10 @@ QStringList lthemeengine::sharedColorSchemePath(){ 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/colors/"); } if(dirs.isEmpty()){ dirs << LTHEMEENGINE_DATADIR"/lthemeengine/colors/"; } //no XDG settings - use the hardcoded path + qDebug() << "Got Color Dirs:" << dirs; return dirs; } 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 93a1d433..8a466ed9 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h @@ -8,7 +8,7 @@ #define LTHEMEENGINE_STRINGIFY(s) LTHEMEENGINE_TOSTRING(s) #define LTHEMEENGINE_VERSION_INT (LTHEMEENGINE_VERSION_MAJOR<<8 | LTHEMEENGINE_VERSION_MINOR) -#define LTHEMEENGINE_VERSION_STR LTHEMEENGINE_STRINGIFY(LTHEMEENGINE_VERSION_MAJOR.QT5CT_VERSION_MINOR) +#define LTHEMEENGINE_VERSION_STR LTHEMEENGINE_STRINGIFY(LTHEMEENGINE_VERSION_MAJOR.LTHEMEENGINE_VERSION_MINOR) #include <QString> #include <QStringList> diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.pro b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.pro index cc36ee5b..721b8888 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.pro +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.pro @@ -2,7 +2,7 @@ include(../../lthemeengine.pri) TEMPLATE = app -QT += widgets +QT *= widgets SOURCES += \ main.cpp \ @@ -43,13 +43,12 @@ HEADERS += \ qsspage.h \ qsseditordialog.h -!equals (DISABLE_WIDGETS,1) { DEFINES += USE_WIDGETS -} -target.path = $$BINDIR +TARGET = lthemeengine +target.path = $${L_BINDIR} desktop.files = lthemeengine.desktop -desktop.path = $$DATADIR/applications +desktop.path = $${L_SHAREDIR}/applications INSTALLS += target desktop diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/main.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/main.cpp index 4c1b89fa..b0d5fe08 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/main.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/main.cpp @@ -23,7 +23,7 @@ int main(int argc, char **argv){ QStringList errorMessages; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); if(env.contains("QT_STYLE_OVERRIDE")){ errorMessages << app.translate("main", "Please remove the <b>QT_STYLE_OVERRIDE</b> environment variable"); } - if(env.value("QT_QPA_PLATFORMTHEME") != "lthemeengine"){ errorMessages << app.translate("main", "The <b>QT_QPA_PLATFORMTHEME</b> environment variable is not set correctly"); } + //if(env.value("QT_QPA_PLATFORMTHEME") != "lthemeengine"){ errorMessages << app.translate("main", "The <b>QT_QPA_PLATFORMTHEME</b> environment variable is not set correctly"); } if(!QStyleFactory::keys().contains("lthemeengine-style")){ errorMessages << app.translate("main", "Unable to find <b>liblthemeengine-style.so</b>"); } if(!errorMessages.isEmpty()){ QMessageBox::critical(0, app.translate("main", "Error"), errorMessages.join("<br><br>")); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp index 97d4ea1a..ac891a80 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.cpp @@ -13,6 +13,30 @@ QSSEditorDialog::QSSEditorDialog(const QString &filePath, QWidget *parent) : QDi setWindowTitle(tr("%1 - Style Sheet Editor").arg(file.fileName())); QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); restoreGeometry(settings.value("QSSEditor/geometry").toByteArray()); + //Generate the list of standard colors for the user to pick + QStringList colors; + colors << tr("base (alternate)")+"::::alternate-base" + << tr("base")+"::::base" + << tr("text (bright)")+"::::bright-text" + << tr("button")+"::::button" + << tr("text (button)")+"::::button-text" + << tr("dark")+"::::dark" + << tr("highlight")+"::::highlight" + << tr("text (highlight)")+"::::highlighted-text" + << tr("light")+"::::light" + << tr("link")+"::::link" + << tr("link (visited)")+"::::link-visited" + << tr("mid")+"::::mid" + << tr("midlight")+"::::midlight" + << tr("shadow")+"::::shadow" + << tr("text")+"::::text" + << tr("window")+"::::window" + << tr("text (window)")+"::::window-text"; + colors.sort(); //sort by translated display name + colorMenu = new QMenu(m_ui->tool_color); + for(int i=0; i<colors.length(); i++){ colorMenu->addAction( colors[i].section("::::",0,0) )->setWhatsThis(colors[i].section("::::",1,1) ); } + m_ui->tool_color->setMenu(colorMenu); + connect(colorMenu, SIGNAL(triggered(QAction*)), this, SLOT(colorPicked(QAction*)) ); } QSSEditorDialog::~QSSEditorDialog(){ @@ -39,3 +63,9 @@ void QSSEditorDialog::on_buttonBox_clicked(QAbstractButton *button){ else if(id == QDialogButtonBox::Save){ save(); } else{ reject(); } } + +void QSSEditorDialog::colorPicked(QAction* act){ + QString id = act->whatsThis(); + if(id.isEmpty()){ return; } + m_ui->textEdit->insertPlainText( QString("palette(%1)").arg(id) ); +} diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h index ea615e81..114611fe 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.h @@ -3,6 +3,8 @@ #include <QDialog> #include <QString> +#include <QMenu> +#include <QAction> namespace Ui { class QSSEditorDialog; @@ -20,12 +22,15 @@ public: private slots: void on_buttonBox_clicked(QAbstractButton *button); + void colorPicked(QAction*); private: void save(); void hideEvent(QHideEvent *); Ui::QSSEditorDialog *m_ui; QString m_filePath; + QMenu *colorMenu; + }; #endif // QSSEDITORDIALOG_H diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui index 7627b4d4..f75a21c6 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsseditordialog.ui @@ -31,14 +31,38 @@ </widget> </item> <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Save</set> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QToolButton" name="tool_color"> + <property name="text"> + <string>Palette</string> + </property> + <property name="icon"> + <iconset theme="preferences-desktop-color"> + <normaloff>.</normaloff>.</iconset> + </property> + <property name="popupMode"> + <enum>QToolButton::InstantPopup</enum> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Save</set> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> 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 d690ef5d..2cf0f221 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp @@ -95,8 +95,7 @@ void QSSPage::on_removeButton_clicked(){ void QSSPage::readSettings(){ //load stylesheets m_ui->qssListWidget->clear(); - findStyleSheets(lthemeengine::userStyleSheetPath()); - findStyleSheets(lthemeengine::sharedStyleSheetPath().join(", ")); + findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); QStringList styleSheets = settings.value("Interface/stylesheets").toStringList(); for(int i = 0; i < m_ui->qssListWidget->count(); ++i){ @@ -106,16 +105,20 @@ void QSSPage::readSettings(){ } } -void QSSPage::findStyleSheets(const QString &path){ - QDir dir(path); - dir.setFilter(QDir::Files); - dir.setNameFilters(QStringList() << "*.qss"); - foreach (QFileInfo info, dir.entryInfoList()){ - QListWidgetItem *item = new QListWidgetItem(info.fileName(), m_ui->qssListWidget); - item->setToolTip(info.filePath()); - item->setData(QSS_FULL_PATH_ROLE, info.filePath()); - item->setData(QSS_WRITABLE_ROLE, info.isWritable()); +void QSSPage::findStyleSheets(QStringList paths){ + paths.removeDuplicates(); + for(int i=0; i<paths.length(); i++){ + if(!QFile::exists(paths[i])){ continue; } + QDir dir(paths[i]); + dir.setFilter(QDir::Files); + dir.setNameFilters(QStringList() << "*.qss"); + foreach (QFileInfo info, dir.entryInfoList()){ + QListWidgetItem *item = new QListWidgetItem(info.fileName(), m_ui->qssListWidget); + item->setToolTip(info.filePath()); + item->setData(QSS_FULL_PATH_ROLE, info.filePath()); + item->setData(QSS_WRITABLE_ROLE, info.isWritable()); } + } } void QSSPage::on_renameButton_clicked(){ 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 1fe0ed73..5e924ad9 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h @@ -30,7 +30,7 @@ private slots: private: void readSettings(); - void findStyleSheets(const QString &path); + void findStyleSheets(QStringList paths); Ui::QSSPage *m_ui; QMenu *m_menu; }; |