diff options
author | Weblate <noreply@weblate.org> | 2017-08-17 16:04:15 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2017-08-17 16:04:15 +0000 |
commit | da678fc7fa150351ce15acf8fed2c90dde244db7 (patch) | |
tree | 8c5702ce54b5e533b61c5a2ce555e5b5bdde1d48 /src-qt5/core/lumina-theme-engine | |
parent | Translated using Weblate (French) (diff) | |
parent | Merge remote-tracking branch 'origin/master' (diff) | |
download | lumina-da678fc7fa150351ce15acf8fed2c90dde244db7.tar.gz lumina-da678fc7fa150351ce15acf8fed2c90dde244db7.tar.bz2 lumina-da678fc7fa150351ce15acf8fed2c90dde244db7.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core/lumina-theme-engine')
31 files changed, 436 insertions, 507 deletions
diff --git a/src-qt5/core/lumina-theme-engine/colors/airy.conf b/src-qt5/core/lumina-theme-engine/colors/airy.conf new file mode 100644 index 00000000..94008b7a --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/colors/airy.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#000000, #dcdcdc, #dcdcdc, #5e5c5b, #646464, #e1e1e1, #000000, #0a0a0a, #0a0a0a, #c8c8c8, #ffffff, #e7e4e0, #0986d3, #0a0a0a, #0986d3, #a70b06, #5c5b5a, #ffffff, #646464, #050505 +disabled_colors=#ffffff, #424245, #dcdcdc, #5e5c5b, #646464, #e1e1e1, #808080, #ffffff, #808080, #969696, #c8c8c8, #e7e4e0, #0986d3, #808080, #0986d3, #a70b06, #5c5b5a, #ffffff, #646464, #ffffff +inactive_colors=#323232, #b4b4b4, #dcdcdc, #5e5c5b, #646464, #e1e1e1, #323232, #323232, #323232, #969696, #c8c8c8, #e7e4e0, #0986d3, #323232, #0986d3, #a70b06, #5c5b5a, #ffffff, #646464, #323232 diff --git a/src-qt5/core/lumina-theme-engine/colors/darker.conf b/src-qt5/core/lumina-theme-engine/colors/darker.conf new file mode 100644 index 00000000..9c822b60 --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/colors/darker.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#ffffff, #424245, #979797, #5e5c5b, #302f2e, #4a4947, #ffffff, #ffffff, #ffffff, #3d3d3d, #222020, #e7e4e0, #12608a, #f9f9f9, #0986d3, #a70b06, #5c5b5a, #ffffff, #3f3f36, #ffffff +disabled_colors=#808080, #424245, #979797, #5e5c5b, #302f2e, #4a4947, #808080, #ffffff, #808080, #3d3d3d, #222020, #e7e4e0, #12608a, #808080, #0986d3, #a70b06, #5c5b5a, #ffffff, #3f3f36, #ffffff +inactive_colors=#ffffff, #424245, #979797, #5e5c5b, #302f2e, #4a4947, #ffffff, #ffffff, #ffffff, #3d3d3d, #222020, #e7e4e0, #12608a, #f9f9f9, #0986d3, #a70b06, #5c5b5a, #ffffff, #3f3f36, #ffffff diff --git a/src-qt5/core/lumina-theme-engine/colors/dusk.conf b/src-qt5/core/lumina-theme-engine/colors/dusk.conf new file mode 100644 index 00000000..5186ecef --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/colors/dusk.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#000000, #7f7f7f, #ffffff, #cbc7c4, #7f7f7f, #b8b5b2, #000000, #ffffff, #000000, #7f7f7f, #7f7f7f, #707070, #308cc6, #ffffff, #0000ff, #ff00ff, #7f7f7f, #000000, #7f7f7f, #000000 +disabled_colors=#bebebe, #7f7f7f, #ffffff, #cbc7c4, #7f7f7f, #b8b5b2, #bebebe, #ffffff, #bebebe, #7f7f7f, #7f7f7f, #b1aeab, #7f7f7f, #ffffff, #0000ff, #ff00ff, #7f7f7f, #000000, #7f7f7f, #000000 +inactive_colors=#000000, #7f7f7f, #ffffff, #cbc7c4, #7f7f7f, #b8b5b2, #000000, #ffffff, #000000, #7f7f7f, #7f7f7f, #707070, #308cc6, #ffffff, #0000ff, #ff00ff, #7f7f7f, #000000, #7f7f7f, #000000 diff --git a/src-qt5/core/lumina-theme-engine/colors/sand.conf b/src-qt5/core/lumina-theme-engine/colors/sand.conf new file mode 100644 index 00000000..92349195 --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/colors/sand.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#000000, #ffffdc, #979797, #5e5c5b, #302f2e, #4a4947, #000000, #000000, #000000, #ffffdc, #ffffdc, #e7e4e0, #5f5b5d, #f9f9f9, #0986d3, #a70b06, #ffffdc, #000000, #3f3f36, #000000 +disabled_colors=#4a4947, #ffffdc, #979797, #5e5c5b, #302f2e, #4a4947, #4a4947, #4a4947, #4a4947, #ffffdc, #ffffdc, #e7e4e0, #5f5b5d, #f9f9f9, #0986d3, #a70b06, #ffffdc, #000000, #3f3f36, #000000 +inactive_colors=#000000, #ffffdc, #979797, #5e5c5b, #302f2e, #4a4947, #000000, #000000, #000000, #ffffdc, #ffffdc, #e7e4e0, #5f5b5d, #f9f9f9, #0986d3, #a70b06, #ffffdc, #000000, #3f3f36, #000000 diff --git a/src-qt5/core/lumina-theme-engine/colors/simple.conf b/src-qt5/core/lumina-theme-engine/colors/simple.conf new file mode 100644 index 00000000..8db9d75b --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/colors/simple.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#000000, #efebe7, #ffffff, #cbc7c4, #9f9d9a, #b8b5b2, #000000, #ffffff, #000000, #ffffff, #efebe7, #b1aeab, #308cc6, #ffffff, #0000ff, #ff0000, #f7f5f3, #000000, #ffffdc, #000000 +disabled_colors=#bebebe, #efebe7, #ffffff, #cbc7c4, #9f9d9a, #b8b5b2, #bebebe, #ffffff, #bebebe, #efebe7, #efebe7, #b1aeab, #9f9d9a, #ffffff, #0000ff, #ff0000, #f7f5f3, #000000, #ffffdc, #000000 +inactive_colors=#000000, #efebe7, #ffffff, #cbc7c4, #9f9d9a, #b8b5b2, #000000, #ffffff, #000000, #ffffff, #efebe7, #b1aeab, #308cc6, #ffffff, #0000ff, #ff0000, #f7f5f3, #000000, #ffffdc, #000000 diff --git a/src-qt5/core/lumina-theme-engine/colors/waves.conf b/src-qt5/core/lumina-theme-engine/colors/waves.conf new file mode 100644 index 00000000..7c7b4530 --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/colors/waves.conf @@ -0,0 +1,4 @@ +[ColorScheme] +active_colors=#b0b0b0, #010b2c, #979797, #5e5c5b, #302f2e, #4a4947, #b0b0b0, #b0b0b0, #b0b0b0, #010b2c, #010b2c, #b0b0b0, #302f2e, #b0b0b0, #0986d3, #a70b06, #5c5b5a, #ffffff, #0a0a0a, #ffffff +disabled_colors=#808080, #010b2c, #979797, #5e5c5b, #302f2e, #4a4947, #808080, #808080, #808080, #00071d, #00071d, #b0b0b0, #00071d, #808080, #0986d3, #a70b06, #5c5b5a, #ffffff, #0a0a0a, #ffffff +inactive_colors=#b0b0b0, #010b2c, #979797, #5e5c5b, #302f2e, #4a4947, #b0b0b0, #b0b0b0, #b0b0b0, #010b2c, #010b2c, #b0b0b0, #302f2e, #b0b0b0, #0986d3, #a70b06, #5c5b5a, #ffffff, #0a0a0a, #ffffff diff --git a/src-qt5/core/lumina-theme-engine/lthemeengine.pri b/src-qt5/core/lumina-theme-engine/lthemeengine.pri index be67734b..40202045 100644 --- a/src-qt5/core/lumina-theme-engine/lthemeengine.pri +++ b/src-qt5/core/lumina-theme-engine/lthemeengine.pri @@ -1,32 +1,11 @@ -#Some conf to redirect intermediate stuff in separate dirs -UI_DIR=./.build/ui/ -MOC_DIR=./.build/moc/ -OBJECTS_DIR=./.build/obj -RCC_DIR=./.build/rcc - -QMAKE_DISTCLEAN += -r .build - -CONFIG += c++11 - +QT *= core gui widgets x11extras network !isEqual (QT_MAJOR_VERSION, 5) { error("Use Qt 5.4.0 or higher.") } +include(../../OS-detect.pri) -!greaterThan(QT_MINOR_VERSION, 3) { - error("Use Qt 5.4.0 or higher.") -} +CONFIG *= c++11 #Install paths -unix { - isEmpty(PREFIX) { - PREFIX = /usr - } - isEmpty(PLUGINDIR) { - PLUGINDIR = $$[QT_INSTALL_PLUGINS] - } - - BINDIR = $$PREFIX/bin - DATADIR = $$PREFIX/share - - DEFINES += LTHEMEENGINE_DATADIR=\\\"$$DATADIR\\\" -} + PLUGINDIR = $${DISTDIR}$$[QT_INSTALL_PLUGINS] + DEFINES += LTHEMEENGINE_DATADIR=\\\"$$L_SHAREDIR\\\" diff --git a/src-qt5/core/lumina-theme-engine/lthemeengine.pro b/src-qt5/core/lumina-theme-engine/lthemeengine.pro deleted file mode 100644 index d8ba709e..00000000 --- a/src-qt5/core/lumina-theme-engine/lthemeengine.pro +++ /dev/null @@ -1,57 +0,0 @@ -QT += core gui -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets x11extras network - -QMAKE_DISTCLEAN += -r .build - -CONFIG += c++11 - -desktop.files=src/lthemeengine/ltheme.desktop -desktop.path=$${L_SHAREDIR}/applications/ - -#Install paths -unix { - isEmpty(PREFIX) { - PREFIX = /usr - } - isEmpty(PLUGINDIR) { - PLUGINDIR = $$[QT_INSTALL_PLUGINS] - } - - BINDIR = $$PREFIX/bin - DATADIR = $$PREFIX/share - - DEFINES += LTHEMEENGINE_DATADIR=\\\"$$DATADIR\\\" -} - -TEMPLATE = subdirs - -SUBDIRS += src/lthemeengine-qtplugin src/lthemeengine-style src/lthemeengine - -unix:exists($$[QT_INSTALL_BINS]/lrelease){ -LRELEASE_EXECUTABLE = $$[QT_INSTALL_BINS]/lrelease -} - -unix:exists($$[QT_INSTALL_BINS]/lrelease-qt5){ -LRELEASE_EXECUTABLE = $$[QT_INSTALL_BINS]/lrelease-qt5 -} - - -isEmpty(LRELEASE_EXECUTABLE){ -error(Could not find lrelease executable) -} -else { -message(Found lrelease executable: $$LRELEASE_EXECUTABLE) -} - -message (PREFIX=$$PREFIX) -message (BINDIR=$$BINDIR) -message (DATADIR=$$DATADIR) -message (PLUGINDIR=$$PLUGINDIR) -equals (DISABLE_WIDGETS,1):message ("QtWidgets are disabled!") - -#Some conf to redirect intermediate stuff in separate dirs -UI_DIR=./.build/ui/ -MOC_DIR=./.build/moc/ -OBJECTS_DIR=./.build/obj -RCC_DIR=./.build/rcc - diff --git a/src-qt5/core/lumina-theme-engine/lumina-theme-engine.pro b/src-qt5/core/lumina-theme-engine/lumina-theme-engine.pro new file mode 100644 index 00000000..d91091d3 --- /dev/null +++ b/src-qt5/core/lumina-theme-engine/lumina-theme-engine.pro @@ -0,0 +1,11 @@ +include(../../OS-detect.pri) + +TEMPLATE = subdirs +SUBDIRS += src/lthemeengine-qtplugin \ + src/lthemeengine-style \ + src/lthemeengine + +colors.files = colors/*.conf +colors.path = $${L_SHAREDIR}/lthemeengine/colors + +INSTALLS += colors 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 064c7642..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 @@ -19,10 +19,6 @@ SOURCES += \ lthemeengineplatformtheme.cpp \ ../lthemeengine/lthemeengine.cpp -!equals (DISABLE_WIDGETS,1) { - QT += widgets -} - OTHER_FILES += lthemeengine.json INCLUDEPATH += ../ 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 dcede34c..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); } @@ -82,8 +82,7 @@ const QPalette *lthemeenginePlatformTheme::palette(QPlatformTheme::Palette type) } const QFont *lthemeenginePlatformTheme::font(QPlatformTheme::Font type) const{ - if(type == QPlatformTheme::FixedFont) - return &m_fixedFont; + if(type == QPlatformTheme::FixedFont){ return &m_fixedFont; } return &m_generalFont; } @@ -105,16 +104,15 @@ QVariant lthemeenginePlatformTheme::themeHint(QPlatformTheme::ThemeHint hint) co } void lthemeenginePlatformTheme::applySettings(){ - if(!QGuiApplication::desktopSettingsAware()) - return; + if(!QGuiApplication::desktopSettingsAware()){ return; } #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) - if(!m_update){ - //do not override application palette - if(QCoreApplication::testAttribute(Qt::AA_SetPalette)){ - m_usePalette = false; - qCDebug(llthemeengine) << "palette support is disabled"; - } - } + if(!m_update){ + //do not override application palette + if(QCoreApplication::testAttribute(Qt::AA_SetPalette)){ + m_usePalette = false; + qCDebug(llthemeengine) << "palette support is disabled"; + } + } #endif #ifdef QT_WIDGETS_LIB if(hasWidgets()){ @@ -127,36 +125,29 @@ void lthemeenginePlatformTheme::applySettings(){ #else qApp->setWheelScrollLines(m_wheelScrollLines); #endif - if(m_update && qApp->style()->objectName() == "lthemeengine-style") //ignore application style - qApp->setStyle("lthemeengine-style"); //recreate style object - if(m_update && m_usePalette){ - if(m_customPalette) - qApp->setPalette(*m_customPalette); - else - qApp->setPalette(qApp->style()->standardPalette()); - } + if(m_update && qApp->style()->objectName() == "lthemeengine-style") /* ignore application style */ { qApp->setStyle("lthemeengine-style"); } //recreate style object + if(m_update && m_usePalette){ + if(m_customPalette){ qApp->setPalette(*m_customPalette); } + else{ qApp->setPalette(qApp->style()->standardPalette()); } + } //do not override application style - if(m_prevStyleSheet == qApp->styleSheet()) - qApp->setStyleSheet(m_userStyleSheet); - else - qCDebug(llthemeengine) << "custom style sheet is disabled"; - m_prevStyleSheet = m_userStyleSheet; + if(m_prevStyleSheet == qApp->styleSheet()){ qApp->setStyleSheet(m_userStyleSheet); } + else{ qCDebug(llthemeengine) << "custom style sheet is disabled";} + m_prevStyleSheet = m_userStyleSheet; } #endif QGuiApplication::setFont(m_generalFont); //apply font QIcon::setThemeName(m_iconTheme); //apply icons - if(m_customPalette && m_usePalette) - QGuiApplication::setPalette(*m_customPalette); //apply palette + if(m_customPalette && m_usePalette){ QGuiApplication::setPalette(*m_customPalette); } //apply palette #ifdef QT_WIDGETS_LIB - if(hasWidgets()){ - foreach (QWidget *w, qApp->allWidgets()){ + if(hasWidgets()){ + foreach (QWidget *w, qApp->allWidgets()){ QEvent e(QEvent::ThemeChange); QApplication::sendEvent(w, &e); } } #endif - if(!m_update) - m_update = true; + if(!m_update){ m_update = true; } } #ifdef QT_WIDGETS_LIB @@ -186,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>(); @@ -210,20 +201,13 @@ void lthemeenginePlatformTheme::readSettings(){ if(settings.childKeys().contains("gui_effects")){ QStringList effectList = settings.value("gui_effects").toStringList(); m_uiEffects = 0; - if(effectList.contains("General")) - m_uiEffects |= QPlatformTheme::GeneralUiEffect; - if(effectList.contains("AnimateMenu")) - m_uiEffects |= QPlatformTheme::AnimateMenuUiEffect; - if(effectList.contains("FadeMenu")) - m_uiEffects |= QPlatformTheme::FadeMenuUiEffect; - if(effectList.contains("AnimateCombo")) - m_uiEffects |= QPlatformTheme::AnimateComboUiEffect; - if(effectList.contains("AnimateTooltip")) - m_uiEffects |= QPlatformTheme::AnimateTooltipUiEffect; - if(effectList.contains("FadeTooltip")) - m_uiEffects |= QPlatformTheme::FadeTooltipUiEffect; - if(effectList.contains("AnimateToolBox")) - m_uiEffects |= QPlatformTheme::AnimateToolBoxUiEffect; + if(effectList.contains("General")){ m_uiEffects |= QPlatformTheme::GeneralUiEffect; } + if(effectList.contains("AnimateMenu")){ m_uiEffects |= QPlatformTheme::AnimateMenuUiEffect; } + if(effectList.contains("FadeMenu")){ m_uiEffects |= QPlatformTheme::FadeMenuUiEffect; } + if(effectList.contains("AnimateCombo")){ m_uiEffects |= QPlatformTheme::AnimateComboUiEffect; } + if(effectList.contains("AnimateTooltip")){ m_uiEffects |= QPlatformTheme::AnimateTooltipUiEffect; } + if(effectList.contains("FadeTooltip")){ m_uiEffects |= QPlatformTheme::FadeTooltipUiEffect; } + if(effectList.contains("AnimateToolBox")){ m_uiEffects |= QPlatformTheme::AnimateToolBoxUiEffect; } } //load style sheets #ifdef QT_WIDGETS_LIB @@ -242,8 +226,7 @@ bool lthemeenginePlatformTheme::hasWidgets(){ QString lthemeenginePlatformTheme::loadStyleSheets(const QStringList &paths){ QString content; foreach (QString path, paths){ - if(!QFile::exists(path)) - continue; + if(!QFile::exists(path)){ continue; } QFile file(path); file.open(QIODevice::ReadOnly); content.append(file.readAll()); @@ -254,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"); @@ -270,8 +266,6 @@ QPalette lthemeenginePlatformTheme::loadColorScheme(const QString &filePath){ customPalette.setColor(QPalette::Disabled, role, QColor(disabledColors.at(i))); } } - else{ - customPalette = *QPlatformTheme::palette(SystemPalette); //load fallback palette - } + else{ customPalette = *QPlatformTheme::palette(SystemPalette); } //load fallback palette return customPalette; } 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-qtplugin/main.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/main.cpp index 12e4a581..28898890 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/main.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/main.cpp @@ -11,10 +11,9 @@ public: }; QPlatformTheme *lthemeenginePlatformThemePlugin::create(const QString &key, const QStringList ¶ms){ - Q_UNUSED(params); - if (key.toLower() == "lthemeengine") - return new lthemeenginePlatformTheme(); - return NULL; + Q_UNUSED(params); + if (key.toLower() == "lthemeengine") { return new lthemeenginePlatformTheme(); } + return NULL; } QT_END_NAMESPACE 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-style/lthemeengineproxystyle.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengineproxystyle.cpp index 2c66144f..a560a36a 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengineproxystyle.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/lthemeengineproxystyle.cpp @@ -14,16 +14,12 @@ lthemeengineProxyStyle::~lthemeengineProxyStyle(){ int lthemeengineProxyStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const{ if(hint == QStyle::SH_DialogButtonBox_ButtonsHaveIcons){ - if(m_dialogButtonsHaveIcons == Qt::Unchecked) - return 0; - else if(m_dialogButtonsHaveIcons == Qt::Checked) - return 1; + if(m_dialogButtonsHaveIcons == Qt::Unchecked){ return 0; } + else if(m_dialogButtonsHaveIcons == Qt::Checked){ return 1; } } else if(hint == QStyle::QStyle::SH_ItemView_ActivateItemOnSingleClick){ - if(m_activateItemOnSingleClick == Qt::Unchecked) - return 0; - else if(m_activateItemOnSingleClick == Qt::Checked) - return 1; + if(m_activateItemOnSingleClick == Qt::Unchecked){ return 0; } + else if(m_activateItemOnSingleClick == Qt::Checked){ return 1; } } return QProxyStyle::styleHint(hint, option, widget, returnData); } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/plugin.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/plugin.cpp index fb9e5fb2..31c59a0c 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/plugin.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-style/plugin.cpp @@ -13,15 +13,13 @@ public: }; QStyle *lthemeengineStylePlugin::create(const QString &key){ - if (key == "lthemeengine-style") - { - QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); - QString style = settings.value("Appearance/style", "Fusion").toString(); - if(key == style || !QStyleFactory::keys().contains(style)) - style = "Fusion"; - return new lthemeengineProxyStyle(style); + if (key == "lthemeengine-style"){ + QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); + QString style = settings.value("Appearance/style", "Fusion").toString(); + if(key == style || !QStyleFactory::keys().contains(style)){ style = "Fusion"; } + return new lthemeengineProxyStyle(style); } - return 0; + return 0; } #include "plugin.moc" 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 95f2c9b7..04ca6a0b 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/appearancepage.cpp @@ -42,8 +42,7 @@ AppearancePage::AppearancePage(QWidget *parent) : TabPage(parent), m_ui(new Ui:: } AppearancePage::~AppearancePage(){ - if(m_selectedStyle) - delete m_selectedStyle; + if(m_selectedStyle){ delete m_selectedStyle; } delete m_ui; delete m_previewUi; } @@ -59,13 +58,11 @@ void AppearancePage::writeSettings(){ void AppearancePage::on_styleComboBox_activated(const QString &text){ QStyle *style = QStyleFactory::create(text); - if(!style) - return; - setStyle(m_previewWidget, style); - if(m_selectedStyle) - delete m_selectedStyle; - m_selectedStyle = style; - updatePalette(); + if(!style){ return; } + setStyle(m_previewWidget, style); + if(m_selectedStyle){ delete m_selectedStyle; } + m_selectedStyle = style; + updatePalette(); } void AppearancePage::on_colorSchemeComboBox_activated(int){ @@ -75,94 +72,84 @@ void AppearancePage::on_colorSchemeComboBox_activated(int){ void AppearancePage::createColorScheme(){ QString name = QInputDialog::getText(this, tr("Enter Color Scheme Name"), tr("File name:")); - if(name.isEmpty()) + if(name.isEmpty()){ return; } + if(!name.endsWith(".conf", Qt::CaseInsensitive)){ name.append(".conf"); } + if(m_ui->colorSchemeComboBox->findText(name.section('.',0,0)) != -1){ + QMessageBox::warning(this, tr("Error"), tr("The color scheme \"%1\" already exists").arg(name.section('.',0,0))); return; - if(!name.endsWith(".conf", Qt::CaseInsensitive)) - name.append(".conf"); - if(m_ui->colorSchemeComboBox->findText(name.section('.',0,0)) != -1){ - QMessageBox::warning(this, tr("Error"), tr("The color scheme \"%1\" already exists").arg(name.section('.',0,0))); - return; - } - QString schemePath = lthemeengine::userColorSchemePath() + "/" + name; - createColorScheme(schemePath, palette()); - m_ui->colorSchemeComboBox->addItem(name.section('.',0,0), schemePath); + } + QString schemePath = lthemeengine::userColorSchemePath() + "/" + name; + createColorScheme(schemePath, palette()); + m_ui->colorSchemeComboBox->addItem(name.section('.',0,0), schemePath); } void AppearancePage::changeColorScheme(){ - if(m_ui->colorSchemeComboBox->currentIndex() < 0) + if(m_ui->colorSchemeComboBox->currentIndex() < 0){ return; } + if(!QFileInfo(m_ui->colorSchemeComboBox->currentData().toString()).isWritable()){ + QMessageBox::information(this, tr("Warning"), tr("The color scheme \"%1\" is read only").arg(m_ui->colorSchemeComboBox->currentText())); return; - if(!QFileInfo(m_ui->colorSchemeComboBox->currentData().toString()).isWritable()){ - QMessageBox::information(this, tr("Warning"), tr("The color scheme \"%1\" is read only").arg(m_ui->colorSchemeComboBox->currentText())); - return; } - PaletteEditDialog d(m_customPalette, m_selectedStyle, this); - connect(&d, SIGNAL(paletteChanged(QPalette)), SLOT(setPreviewPalette(QPalette))); - if(d.exec() == QDialog::Accepted){ - m_customPalette = d.selectedPalette(); - createColorScheme(m_ui->colorSchemeComboBox->currentData().toString(), m_customPalette); + PaletteEditDialog d(m_customPalette, m_selectedStyle, this); + connect(&d, SIGNAL(paletteChanged(QPalette)), SLOT(setPreviewPalette(QPalette))); + if(d.exec() == QDialog::Accepted){ + m_customPalette = d.selectedPalette(); + createColorScheme(m_ui->colorSchemeComboBox->currentData().toString(), m_customPalette); } - updatePalette(); + updatePalette(); } void AppearancePage::removeColorScheme(){ int index = m_ui->colorSchemeComboBox->currentIndex(); - if(index < 0 || m_ui->colorSchemeComboBox->count() <= 1) + if(index < 0 || m_ui->colorSchemeComboBox->count() <= 1){ return; } + if(!QFileInfo(m_ui->colorSchemeComboBox->currentData().toString()).isWritable()){ + QMessageBox::information(this, tr("Warning"), tr("The color scheme \"%1\" is read only").arg(m_ui->colorSchemeComboBox->currentText())); return; - if(!QFileInfo(m_ui->colorSchemeComboBox->currentData().toString()).isWritable()){ - QMessageBox::information(this, tr("Warning"), tr("The color scheme \"%1\" is read only").arg(m_ui->colorSchemeComboBox->currentText())); - return; } - int button = QMessageBox::question(this, tr("Confirm Remove"),tr("Are you sure you want to remove color scheme \"%1\"?").arg(m_ui->colorSchemeComboBox->currentText()), QMessageBox::Yes | QMessageBox::No); - if(button != QMessageBox::Yes) - return; - if(QFile::remove(m_ui->colorSchemeComboBox->currentData().toString())){ - m_ui->colorSchemeComboBox->removeItem(index); - on_colorSchemeComboBox_activated(0); - } + int button = QMessageBox::question(this, tr("Confirm Remove"),tr("Are you sure you want to remove color scheme \"%1\"?").arg(m_ui->colorSchemeComboBox->currentText()), QMessageBox::Yes | QMessageBox::No); + if(button != QMessageBox::Yes){ return; } + if(QFile::remove(m_ui->colorSchemeComboBox->currentData().toString())){ + m_ui->colorSchemeComboBox->removeItem(index); + on_colorSchemeComboBox_activated(0); + } } void AppearancePage::copyColorScheme(){ - if(m_ui->colorSchemeComboBox->currentIndex() < 0) + if(m_ui->colorSchemeComboBox->currentIndex() < 0) { return; } + QString name = QInputDialog::getText(this, tr("Enter Color Scheme Name"), tr("File name:"),QLineEdit::Normal, tr("%1 (copy)").arg(m_ui->colorSchemeComboBox->currentText())); + if(name.isEmpty() || name == m_ui->colorSchemeComboBox->currentText()){ return; } + if(!name.endsWith(".conf", Qt::CaseInsensitive)) { name.append(".conf"); } + if(m_ui->colorSchemeComboBox->findText(name.section('.',0,0)) != -1){ + QMessageBox::warning(this, tr("Error"), tr("The color scheme \"%1\" already exists").arg(name.section('.',0,0))); return; - QString name = QInputDialog::getText(this, tr("Enter Color Scheme Name"), tr("File name:"),QLineEdit::Normal, tr("%1 (copy)").arg(m_ui->colorSchemeComboBox->currentText())); - if(name.isEmpty() || name == m_ui->colorSchemeComboBox->currentText()) - return; - if(!name.endsWith(".conf", Qt::CaseInsensitive))name.append(".conf"); - if(m_ui->colorSchemeComboBox->findText(name.section('.',0,0)) != -1){ - QMessageBox::warning(this, tr("Error"), tr("The color scheme \"%1\" already exists").arg(name.section('.',0,0))); - return; - } - QString newPath = lthemeengine::userColorSchemePath() + "/" + name; - QFile::copy(m_ui->colorSchemeComboBox->currentData().toString(), newPath); - m_ui->colorSchemeComboBox->addItem(name.section('.',0,0), newPath); + } + QString newPath = lthemeengine::userColorSchemePath() + "/" + name; + QFile::copy(m_ui->colorSchemeComboBox->currentData().toString(), newPath); + m_ui->colorSchemeComboBox->addItem(name.section('.',0,0), newPath); } void AppearancePage::renameColorScheme(){ int index = m_ui->colorSchemeComboBox->currentIndex(); - if(index < 0) - return; - if(!QFileInfo(m_ui->colorSchemeComboBox->currentData().toString()).isWritable()){ - QMessageBox::information(this, tr("Warning"), tr("The color scheme \"%1\" is read only").arg(m_ui->colorSchemeComboBox->currentText())); - return; - } - QString name = QInputDialog::getText(this, tr("Enter Color Scheme Name"), tr("File name:"), QLineEdit::Normal, m_ui->colorSchemeComboBox->currentText()); - if(name.isEmpty() || name == m_ui->colorSchemeComboBox->currentText()) - return; - if(!name.endsWith(".conf", Qt::CaseInsensitive))name.append(".conf"); - if(m_ui->colorSchemeComboBox->findText(name.section('.',0,0)) != -1){ - QMessageBox::warning(this, tr("Error"), tr("The color scheme \"%1\" already exists").arg(name.section('.',0,0))); - return; - } - QString newPath = lthemeengine::userColorSchemePath() + "/" + name; - QFile::rename(m_ui->colorSchemeComboBox->currentData().toString(), newPath); - m_ui->colorSchemeComboBox->setItemText(index, name.section('.',0,0)); - m_ui->colorSchemeComboBox->setItemData(index, newPath); + if(index < 0){ return; } + if(!QFileInfo(m_ui->colorSchemeComboBox->currentData().toString()).isWritable()){ + QMessageBox::information(this, tr("Warning"), tr("The color scheme \"%1\" is read only").arg(m_ui->colorSchemeComboBox->currentText())); + return; + } + QString name = QInputDialog::getText(this, tr("Enter Color Scheme Name"), tr("File name:"), QLineEdit::Normal, m_ui->colorSchemeComboBox->currentText()); + if(name.isEmpty() || name == m_ui->colorSchemeComboBox->currentText()){ return; } + if(!name.endsWith(".conf", Qt::CaseInsensitive)){ name.append(".conf"); } + if(m_ui->colorSchemeComboBox->findText(name.section('.',0,0)) != -1){ + QMessageBox::warning(this, tr("Error"), tr("The color scheme \"%1\" already exists").arg(name.section('.',0,0))); + return; + } + QString newPath = lthemeengine::userColorSchemePath() + "/" + name; + QFile::rename(m_ui->colorSchemeComboBox->currentData().toString(), newPath); + m_ui->colorSchemeComboBox->setItemText(index, name.section('.',0,0)); + m_ui->colorSchemeComboBox->setItemData(index, newPath); } void AppearancePage::updatePalette(){ - if(!m_selectedStyle) - return; - setPreviewPalette(m_ui->customPaletteButton->isChecked() ? m_customPalette : m_selectedStyle->standardPalette()); + if(!m_selectedStyle){ return; } + setPreviewPalette(m_ui->customPaletteButton->isChecked() ? m_customPalette : m_selectedStyle->standardPalette()); } void AppearancePage::setPreviewPalette(const QPalette &p){ @@ -171,15 +158,15 @@ void AppearancePage::setPreviewPalette(const QPalette &p){ if(m_ui->paletteComboBox->currentIndex() == 0){ colorGroup = QPalette::Active; } - else if(m_ui->paletteComboBox->currentIndex() == 1){ - colorGroup = QPalette::Inactive; - } - for (int i = 0; i < QPalette::NColorRoles; i++){ - QPalette::ColorRole role = QPalette::ColorRole(i); - previewPalette.setColor(QPalette::Active, role, p.color(colorGroup, role)); - previewPalette.setColor(QPalette::Inactive, role, p.color(colorGroup, role)); - } - setPalette(m_ui->mdiArea, previewPalette); + else if(m_ui->paletteComboBox->currentIndex() == 1){ + colorGroup = QPalette::Inactive; + } + for (int i = 0; i < QPalette::NColorRoles; i++){ + QPalette::ColorRole role = QPalette::ColorRole(i); + previewPalette.setColor(QPalette::Active, role, p.color(colorGroup, role)); + previewPalette.setColor(QPalette::Inactive, role, p.color(colorGroup, role)); + } + setPalette(m_ui->mdiArea, previewPalette); } void AppearancePage::updateActions(){ @@ -188,11 +175,11 @@ void AppearancePage::updateActions(){ m_renameColorSchemeAction->setVisible(false); m_removeColorSchemeAction->setVisible(false); } - else{ - m_changeColorSchemeAction->setVisible(true); - m_renameColorSchemeAction->setVisible(true); - m_removeColorSchemeAction->setVisible(m_ui->colorSchemeComboBox->count() > 1); - } + else{ + m_changeColorSchemeAction->setVisible(true); + m_renameColorSchemeAction->setVisible(true); + m_removeColorSchemeAction->setVisible(m_ui->colorSchemeComboBox->count() > 1); + } } void AppearancePage::readSettings(){ @@ -203,27 +190,26 @@ 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 } - else{ - int index = m_ui->colorSchemeComboBox->findData(colorSchemePath); - if(index >= 0) - m_ui->colorSchemeComboBox->setCurrentIndex(index); - m_customPalette = loadColorScheme(m_ui->colorSchemeComboBox->currentData().toString()); - } - on_styleComboBox_activated(m_ui->styleComboBox->currentText()); - settings.endGroup(); + else{ + int index = m_ui->colorSchemeComboBox->findData(colorSchemePath); + if(index >= 0) + m_ui->colorSchemeComboBox->setCurrentIndex(index); + m_customPalette = loadColorScheme(m_ui->colorSchemeComboBox->currentData().toString()); + } + on_styleComboBox_activated(m_ui->styleComboBox->currentText()); + settings.endGroup(); } void AppearancePage::setStyle(QWidget *w, QStyle *s){ foreach (QObject *o, w->children()){ - if(o->isWidgetType()){ - setStyle(qobject_cast<QWidget *>(o), s); + if(o->isWidgetType()){ + setStyle(qobject_cast<QWidget *>(o), s); + } } - } w->setStyle(s); } @@ -236,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()); + } } } @@ -261,10 +251,10 @@ QPalette AppearancePage::loadColorScheme(const QString &filePath){ customPalette.setColor(QPalette::Disabled, role, QColor(disabledColors.at(i))); } } - else{ - customPalette = palette(); //load fallback palette - } - return customPalette; + else{ + customPalette = palette(); //load fallback palette + } + return customPalette; } void AppearancePage::createColorScheme(const QString &name, const QPalette &palette){ 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/iconthemepage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp index cfe002aa..1a09ac0d 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/iconthemepage.cpp @@ -22,22 +22,20 @@ IconThemePage::~IconThemePage(){ void IconThemePage::writeSettings(){ QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); QTreeWidgetItem *item = m_ui->treeWidget->currentItem(); - if(item) - settings.setValue("Appearance/icon_theme", item->data(3, Qt::UserRole)); + if(item){ settings.setValue("Appearance/icon_theme", item->data(3, Qt::UserRole)); } } void IconThemePage::readSettings(){ QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); QString name = settings.value("Appearance/icon_theme").toString(); - if(name.isEmpty()) - return; - for(int i = 0; i < m_ui->treeWidget->topLevelItemCount(); ++i){ - QTreeWidgetItem *item = m_ui->treeWidget->topLevelItem(i); - if(item->data(3, Qt::UserRole).toString() == name){ - m_ui->treeWidget->setCurrentItem(item); - break; - } + if(name.isEmpty()){ return; } + for(int i = 0; i < m_ui->treeWidget->topLevelItemCount(); ++i){ + QTreeWidgetItem *item = m_ui->treeWidget->topLevelItem(i); + if(item->data(3, Qt::UserRole).toString() == name){ + m_ui->treeWidget->setCurrentItem(item); + break; } + } } void IconThemePage::loadThemes(){ @@ -61,39 +59,33 @@ void IconThemePage::loadTheme(const QString &path){ config.setIniCodec("UTF-8"); config.beginGroup("Icon Theme"); QStringList dirs = config.value("Directories").toStringList(); - if(dirs.isEmpty() || config.value("Hidden", false).toBool()) - return; - QString name, comment; - QString lang = QLocale::system().name(); - name = config.value(QString("Name[%1]").arg(lang)).toString(); - comment = config.value(QString("Comment[%1]").arg(lang)).toString(); - if(lang.contains("_")) - lang = lang.split("_").first(); - if(name.isEmpty()) - name = config.value(QString("Name[%1]").arg(lang)).toString(); - if(comment.isEmpty()) - comment = config.value(QString("Comment[%1]").arg(lang)).toString(); - if(name.isEmpty()) - name = config.value("Name").toString(); - if(comment.isEmpty()) - comment = config.value("Comment").toString(); - config.endGroup(); - QIcon icon1 = findIcon(path, 24, "document-save"); - QIcon icon2 = findIcon(path, 24, "document-print"); - QIcon icon3 = findIcon(path, 24, "media-playback-stop"); - QTreeWidgetItem *item = new QTreeWidgetItem(); - item->setIcon(0, icon1); - item->setIcon(1, icon2); - item->setIcon(2, icon3); - item->setText(3, name); - item->setData(3, Qt::UserRole, QFileInfo(path).path().section("/", -1)); - item->setToolTip(3, comment); - item->setSizeHint(0, QSize(24,24)); - m_ui->treeWidget->addTopLevelItem(item); - m_ui->treeWidget->resizeColumnToContents(0); - m_ui->treeWidget->resizeColumnToContents(1); - m_ui->treeWidget->resizeColumnToContents(2); - m_ui->treeWidget->resizeColumnToContents(3); + if(dirs.isEmpty() || config.value("Hidden", false).toBool()){ return; } + QString name, comment; + QString lang = QLocale::system().name(); + name = config.value(QString("Name[%1]").arg(lang)).toString(); + comment = config.value(QString("Comment[%1]").arg(lang)).toString(); + if(lang.contains("_")){ lang = lang.split("_").first(); } + if(name.isEmpty()){ name = config.value(QString("Name[%1]").arg(lang)).toString(); } + if(comment.isEmpty()){ comment = config.value(QString("Comment[%1]").arg(lang)).toString(); } + if(name.isEmpty()){ name = config.value("Name").toString(); } + if(comment.isEmpty()){ comment = config.value("Comment").toString(); } + config.endGroup(); + QIcon icon1 = findIcon(path, 24, "document-save"); + QIcon icon2 = findIcon(path, 24, "document-print"); + QIcon icon3 = findIcon(path, 24, "media-playback-stop"); + QTreeWidgetItem *item = new QTreeWidgetItem(); + item->setIcon(0, icon1); + item->setIcon(1, icon2); + item->setIcon(2, icon3); + item->setText(3, name); + item->setData(3, Qt::UserRole, QFileInfo(path).path().section("/", -1)); + item->setToolTip(3, comment); + item->setSizeHint(0, QSize(24,24)); + m_ui->treeWidget->addTopLevelItem(item); + m_ui->treeWidget->resizeColumnToContents(0); + m_ui->treeWidget->resizeColumnToContents(1); + m_ui->treeWidget->resizeColumnToContents(2); + m_ui->treeWidget->resizeColumnToContents(3); } QIcon IconThemePage::findIcon(const QString &themePath, int size, const QString &name){ @@ -127,18 +119,15 @@ QIcon IconThemePage::findIcon(const QString &themePath, int size, const QString } config.endGroup(); } - if (!haveInherits) - return QIcon(); - parents.append("hicolor"); //add fallback themes - parents.append("gnome"); - parents.removeDuplicates(); - foreach (QString parent, parents){ - QString parentThemePath = QDir(QFileInfo(themePath).path() + "/../" + parent).canonicalPath() + "/index.theme"; - if(!QFile::exists(parentThemePath) || parentThemePath == themePath) - continue; - QIcon icon = findIcon(parentThemePath, size, name); - if(!icon.isNull()) - return icon; - } - return QIcon(); + if (!haveInherits){ return QIcon(); } + parents.append("hicolor"); //add fallback themes + parents.append("gnome"); + parents.removeDuplicates(); + foreach (QString parent, parents){ + QString parentThemePath = QDir(QFileInfo(themePath).path() + "/../" + parent).canonicalPath() + "/index.theme"; + if(!QFile::exists(parentThemePath) || parentThemePath == themePath){ continue; } + QIcon icon = findIcon(parentThemePath, size, name); + if(!icon.isNull()){ return icon; } + } + return QIcon(); } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/interfacepage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/interfacepage.cpp index a44e75e4..38f6ef8f 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/interfacepage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/interfacepage.cpp @@ -36,22 +36,15 @@ void InterfacePage::writeSettings(){ settings.setValue("toolbutton_style", m_ui->toolButtonStyleComboBox->currentData()); settings.setValue("wheel_scroll_lines", m_ui->wheelScrollLinesSpinBox->value()); QStringList effects; - if(m_ui->guiEffectsCheckBox->isChecked()) - effects << "General"; - if(m_ui->menuEffectComboBox->currentIndex() == 1) - effects << "AnimateMenu"; - else if(m_ui->menuEffectComboBox->currentIndex() == 2) - effects << "FadeMenu"; - if(m_ui->comboBoxEffectComboBox->currentIndex() == 1) - effects << "AnimateCombo"; - if(m_ui->toolTipEffectComboBox->currentIndex() == 1) - effects << "AnimateTooltip"; - else if(m_ui->toolTipEffectComboBox->currentIndex() == 2) - effects << "FadeTooltip"; - if(m_ui->toolBoxEffectComboBox->currentIndex() == 1) - effects << "AnimateToolBox"; - settings.setValue("gui_effects", effects); - settings.endGroup(); + if(m_ui->guiEffectsCheckBox->isChecked()){ effects << "General";} + if(m_ui->menuEffectComboBox->currentIndex() == 1){ effects << "AnimateMenu"; } + else if(m_ui->menuEffectComboBox->currentIndex() == 2){ effects << "FadeMenu"; } + if(m_ui->comboBoxEffectComboBox->currentIndex() == 1){ effects << "AnimateCombo"; } + if(m_ui->toolTipEffectComboBox->currentIndex() == 1){ effects << "AnimateTooltip"; } + else if(m_ui->toolTipEffectComboBox->currentIndex() == 2){ effects << "FadeTooltip"; } + if(m_ui->toolBoxEffectComboBox->currentIndex() == 1){ effects << "AnimateToolBox"; } + settings.setValue("gui_effects", effects); + settings.endGroup(); } void InterfacePage::readSettings(){ @@ -62,27 +55,19 @@ void InterfacePage::readSettings(){ m_ui->guiEffectsCheckBox->setChecked(qApp->isEffectEnabled(Qt::UI_General)); int layout = settings.value("buttonbox_layout", style()->styleHint(QStyle::SH_DialogButtonLayout)).toInt(); int index = m_ui->buttonLayoutComboBox->findData(layout); - if(index >= 0) - m_ui->buttonLayoutComboBox->setCurrentIndex(index); - if(qApp->isEffectEnabled(Qt::UI_AnimateMenu)) - m_ui->menuEffectComboBox->setCurrentIndex(1); - else if(qApp->isEffectEnabled(Qt::UI_FadeMenu)) - m_ui->menuEffectComboBox->setCurrentIndex(2); - if(qApp->isEffectEnabled(Qt::UI_AnimateCombo)) - m_ui->comboBoxEffectComboBox->setCurrentIndex(1); - if(qApp->isEffectEnabled(Qt::UI_AnimateTooltip)) - m_ui->toolTipEffectComboBox->setCurrentIndex(1); - else if(qApp->isEffectEnabled(Qt::UI_FadeTooltip)) - m_ui->toolTipEffectComboBox->setCurrentIndex(2); - if(qApp->isEffectEnabled(Qt::UI_AnimateToolBox)) - m_ui->toolBoxEffectComboBox->setCurrentIndex(1); - m_ui->singleClickCheckBox->setCheckState((Qt::CheckState)settings.value("activate_item_on_single_click", Qt::PartiallyChecked).toInt()); - m_ui->dialogIconsCheckBox->setCheckState((Qt::CheckState)settings.value("dialog_buttons_have_icons", Qt::PartiallyChecked).toInt()); - m_ui->menuIconsCheckBox->setChecked(!qApp->testAttribute(Qt::AA_DontShowIconsInMenus)); - int toolbarStyle = settings.value("toolbutton_style", Qt::ToolButtonFollowStyle).toInt(); - index = m_ui->toolButtonStyleComboBox->findData(toolbarStyle); - if(index >= 0) - m_ui->toolButtonStyleComboBox->setCurrentIndex(index); - m_ui->wheelScrollLinesSpinBox->setValue(settings.value("wheel_scroll_lines", 3).toInt()); - settings.endGroup(); + if(index >= 0){ m_ui->buttonLayoutComboBox->setCurrentIndex(index); } + if(qApp->isEffectEnabled(Qt::UI_AnimateMenu)){ m_ui->menuEffectComboBox->setCurrentIndex(1); } + else if(qApp->isEffectEnabled(Qt::UI_FadeMenu)){ m_ui->menuEffectComboBox->setCurrentIndex(2); } + if(qApp->isEffectEnabled(Qt::UI_AnimateCombo)){ m_ui->comboBoxEffectComboBox->setCurrentIndex(1); } + if(qApp->isEffectEnabled(Qt::UI_AnimateTooltip)){ m_ui->toolTipEffectComboBox->setCurrentIndex(1); } + else if(qApp->isEffectEnabled(Qt::UI_FadeTooltip)){ m_ui->toolTipEffectComboBox->setCurrentIndex(2); } + if(qApp->isEffectEnabled(Qt::UI_AnimateToolBox)){ m_ui->toolBoxEffectComboBox->setCurrentIndex(1); } + m_ui->singleClickCheckBox->setCheckState((Qt::CheckState)settings.value("activate_item_on_single_click", Qt::PartiallyChecked).toInt()); + m_ui->dialogIconsCheckBox->setCheckState((Qt::CheckState)settings.value("dialog_buttons_have_icons", Qt::PartiallyChecked).toInt()); + m_ui->menuIconsCheckBox->setChecked(!qApp->testAttribute(Qt::AA_DontShowIconsInMenus)); + int toolbarStyle = settings.value("toolbutton_style", Qt::ToolButtonFollowStyle).toInt(); + index = m_ui->toolButtonStyleComboBox->findData(toolbarStyle); + if(index >= 0){ m_ui->toolButtonStyleComboBox->setCurrentIndex(index); } + m_ui->wheelScrollLinesSpinBox->setValue(settings.value("wheel_scroll_lines", 3).toInt()); + settings.endGroup(); } 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 979c8c43..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/"; @@ -25,19 +26,16 @@ QStringList lthemeengine::iconPaths(){ paths << "/usr/local/share/icons"; } else{ - foreach (QString p, xdgDataDirs.split(":")) - paths << QDir(p + "/icons/").absolutePath(); + foreach (QString p, xdgDataDirs.split(":")){ paths << QDir(p + "/icons/").absolutePath(); } + } + if(xdgDataHome.isEmpty()){ xdgDataHome = QDir::homePath() + "/.local/share"; } + paths << "/usr/share/pixmaps"; + paths << xdgDataHome + "/icons"; + paths.removeDuplicates(); + //remove invalid + foreach (QString p, paths){ + if(!QDir(p).exists()){ paths.removeAll(p); } } - if(xdgDataHome.isEmpty()) - xdgDataHome = QDir::homePath() + "/.local/share"; - paths << "/usr/share/pixmaps"; - paths << xdgDataHome + "/icons"; - paths.removeDuplicates(); - //remove invalid - foreach (QString p, paths){ - if(!QDir(p).exists()) - paths.removeAll(p); - } return paths; } @@ -49,12 +47,9 @@ 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/"); - } - if(dirs.isEmpty()){ - dirs << LTHEMEENGINE_DATADIR"/lthemeengine/qss/"; //no XDG settings - use the hardcoded path - } + 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; } @@ -66,24 +61,19 @@ QStringList lthemeengine::sharedColorSchemePath(){ 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/"); - } - if(dirs.isEmpty()){ - dirs << LTHEMEENGINE_DATADIR"/lthemeengine/colors/"; //no XDG settings - use the hardcoded path - } + 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; } QString lthemeengine::systemLanguageID(){ #ifdef Q_OS_UNIX QByteArray v = qgetenv ("LC_ALL"); - if (v.isEmpty()) - v = qgetenv ("LC_MESSAGES"); - if (v.isEmpty()) - v = qgetenv ("LANG"); - if (!v.isEmpty()) - return QLocale (v).name(); + if (v.isEmpty()){ v = qgetenv ("LC_MESSAGES"); } + if (v.isEmpty()){ v = qgetenv ("LANG"); } + if (!v.isEmpty()){ return QLocale (v).name(); } #endif return QLocale::system().name(); } 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 55d0fc36..b0d5fe08 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/main.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/main.cpp @@ -22,15 +22,9 @@ int main(int argc, char **argv){ //checking environment 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(!QStyleFactory::keys().contains("lthemeengine-style")){ - errorMessages << app.translate("main", "Unable to find <b>liblthemeengine-style.so</b>"); - } + 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(!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>")); return 0; 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 c93b1052..719a0f49 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp @@ -38,9 +38,8 @@ void MainWindow::on_buttonBox_clicked(QAbstractButton *button){ if(id == QDialogButtonBox::Ok || id == QDialogButtonBox::Apply){ for(int i = 0; i < m_ui->tabWidget->count(); ++i){ TabPage *p = qobject_cast<TabPage*>(m_ui->tabWidget->widget(i)); - if(p) - p->writeSettings(); - } + if(p) { p->writeSettings(); } + } } if(id == QDialogButtonBox::Ok || id == QDialogButtonBox::Cancel){ close(); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/paletteeditdialog.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/paletteeditdialog.cpp index 8a8e86d0..9cce5a6e 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/paletteeditdialog.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/paletteeditdialog.cpp @@ -37,15 +37,12 @@ QPalette PaletteEditDialog::selectedPalette() const{ void PaletteEditDialog::setPalette(const QPalette &palette){ for(int i = 0; i < QPalette::NColorRoles; i++){ - if(!m_ui->tableWidget->item(i,0)) - m_ui->tableWidget->setItem(i, 0, new QTableWidgetItem()); - if(!m_ui->tableWidget->item(i,1)) - m_ui->tableWidget->setItem(i, 1, new QTableWidgetItem()); - if(!m_ui->tableWidget->item(i,2)) - m_ui->tableWidget->setItem(i, 2, new QTableWidgetItem()); - m_ui->tableWidget->item(i,0)->setBackgroundColor(palette.color(QPalette::Active, QPalette::ColorRole(i))); - m_ui->tableWidget->item(i,1)->setBackgroundColor(palette.color(QPalette::Inactive, QPalette::ColorRole(i))); - m_ui->tableWidget->item(i,2)->setBackgroundColor(palette.color(QPalette::Disabled, QPalette::ColorRole(i))); + if(!m_ui->tableWidget->item(i,0)){ m_ui->tableWidget->setItem(i, 0, new QTableWidgetItem()); } + if(!m_ui->tableWidget->item(i,1)){ m_ui->tableWidget->setItem(i, 1, new QTableWidgetItem()); } + if(!m_ui->tableWidget->item(i,2)){ m_ui->tableWidget->setItem(i, 2, new QTableWidgetItem()); } + m_ui->tableWidget->item(i,0)->setBackgroundColor(palette.color(QPalette::Active, QPalette::ColorRole(i))); + m_ui->tableWidget->item(i,1)->setBackgroundColor(palette.color(QPalette::Inactive, QPalette::ColorRole(i))); + m_ui->tableWidget->item(i,2)->setBackgroundColor(palette.color(QPalette::Disabled, QPalette::ColorRole(i))); } QStringList labels; labels << tr("Window text") << tr("Button background") << tr("Bright") << tr("Less bright") << tr("Dark") << tr("Less dark") << tr("Normal text") << tr("Bright text") << tr("Button text") << tr("Normal background") << tr("Window") << tr("Shadow") << tr("Highlight") << tr("Highlighted text") << tr("Link") << tr("Visited link") << tr("Alternate background") << tr("Default") << tr("Tooltip background") << tr("Tooltip text"); 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 aa4bb810..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(){ @@ -36,10 +60,12 @@ void QSSEditorDialog::on_buttonBox_clicked(QAbstractButton *button){ save(); accept(); } - else if(id == QDialogButtonBox::Save){ - save(); - } - else{ - reject(); - } + 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 c9bfc14a..2cf0f221 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp @@ -36,10 +36,9 @@ void QSSPage::writeSettings(){ QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); 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(); - } + if(item->checkState() == Qt::Checked){ styleSheets << item->data(QSS_FULL_PATH_ROLE).toString(); } settings.setValue("Interface/stylesheets", styleSheets); + } } void QSSPage::on_qssListWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *){ @@ -57,26 +56,24 @@ void QSSPage::on_qssListWidget_currentItemChanged(QListWidgetItem *current, QLis void QSSPage::on_createButton_clicked(){ QString name = QInputDialog::getText(this, tr("Enter Style Sheet Name"), tr("File name:")); - if(name.isEmpty()) + if(name.isEmpty()){ return; } + if(!name.endsWith(".qss", Qt::CaseInsensitive)){ name.append(".qss"); } + QString filePath = lthemeengine::userStyleSheetPath() + name; + if(QFile::exists(filePath)){ + QMessageBox::warning(this, tr("Error"), tr("The file \"%1\" already exists").arg(filePath)); return; - if(!name.endsWith(".qss", Qt::CaseInsensitive)) - name.append(".qss"); - QString filePath = lthemeengine::userStyleSheetPath() + name; - if(QFile::exists(filePath)){ - QMessageBox::warning(this, tr("Error"), tr("The file \"%1\" already exists").arg(filePath)); - return; - } - //creating empty file - QFile file(filePath); - file.open(QIODevice::WriteOnly); - file.close(); - //creating item - QFileInfo info(filePath); - 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()); - item->setCheckState(Qt::Unchecked); + } + //creating empty file + QFile file(filePath); + file.open(QIODevice::WriteOnly); + file.close(); + //creating item + QFileInfo info(filePath); + 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()); + item->setCheckState(Qt::Unchecked); } void QSSPage::on_editButton_clicked(){ @@ -89,68 +86,62 @@ void QSSPage::on_editButton_clicked(){ void QSSPage::on_removeButton_clicked(){ QListWidgetItem *item = m_ui->qssListWidget->currentItem(); - if(!item) - return; - int button = QMessageBox::question(this, tr("Confirm Remove"),tr("Are you sure you want to remove style sheet \"%1\"?").arg(item->text()), QMessageBox::Yes | QMessageBox::No); - if(button == QMessageBox::Yes){ - QFile::remove(item->data(QSS_FULL_PATH_ROLE).toString()); - delete item; - } + if(!item){ return; } + int button = QMessageBox::question(this, tr("Confirm Remove"),tr("Are you sure you want to remove style sheet \"%1\"?").arg(item->text()), QMessageBox::Yes | QMessageBox::No); + if(button == QMessageBox::Yes){ QFile::remove(item->data(QSS_FULL_PATH_ROLE).toString()); } + delete item; } 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){ QListWidgetItem *item = m_ui->qssListWidget->item(i); - if(styleSheets.contains(item->data(QSS_FULL_PATH_ROLE).toString())) - item->setCheckState(Qt::Checked); - else - item->setCheckState(Qt::Unchecked); + if(styleSheets.contains(item->data(QSS_FULL_PATH_ROLE).toString())){ item->setCheckState(Qt::Checked); } + else { item->setCheckState(Qt::Unchecked); } } } -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(){ QListWidgetItem *item = m_ui->qssListWidget->currentItem(); - if(!item) + if(!item){ return; } + QString name = QInputDialog::getText(this, tr("Rename Style Sheet"), tr("Style sheet name:"), QLineEdit::Normal, item->text(), 0); + if(name.isEmpty()){ return; } + if(!m_ui->qssListWidget->findItems(name, Qt::MatchExactly).isEmpty()){ + QMessageBox::warning(this, tr("Error"), tr("The style sheet \"%1\" already exists").arg(name)); return; - QString name = QInputDialog::getText(this, tr("Rename Style Sheet"), tr("Style sheet name:"), QLineEdit::Normal, item->text(), 0); - if(name.isEmpty()) - return; - if(!m_ui->qssListWidget->findItems(name, Qt::MatchExactly).isEmpty()){ - QMessageBox::warning(this, tr("Error"), tr("The style sheet \"%1\" already exists").arg(name)); - return; - } - if(!name.endsWith(".qss", Qt::CaseInsensitive)) name.append(".qss"); - QString newPath = lthemeengine::userStyleSheetPath() + name; - if(!QFile::rename(item->data(QSS_FULL_PATH_ROLE).toString(), newPath)){ - QMessageBox::warning(this, tr("Error"), tr("Unable to rename file")); - return; - } - item->setText(name); - item->setData(QSS_FULL_PATH_ROLE, newPath); - item->setToolTip(newPath); + } + if(!name.endsWith(".qss", Qt::CaseInsensitive)){ name.append(".qss"); } + QString newPath = lthemeengine::userStyleSheetPath() + name; + if(!QFile::rename(item->data(QSS_FULL_PATH_ROLE).toString(), newPath)){ + QMessageBox::warning(this, tr("Error"), tr("Unable to rename file")); + return; + } + item->setText(name); + item->setData(QSS_FULL_PATH_ROLE, newPath); + item->setToolTip(newPath); } void QSSPage::on_qssListWidget_customContextMenuRequested(const QPoint &pos){ QListWidgetItem *item = m_ui->qssListWidget->currentItem(); - if(item && item->data(QSS_WRITABLE_ROLE).toBool()){ - m_menu->exec(m_ui->qssListWidget->viewport()->mapToGlobal(pos)); - } + if(item && item->data(QSS_WRITABLE_ROLE).toBool()){ m_menu->exec(m_ui->qssListWidget->viewport()->mapToGlobal(pos)); } } 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; }; |