aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-08-03 14:03:29 -0400
committerKen Moore <ken@ixsystems.com>2017-08-03 14:04:05 -0400
commit4530400268bf9a8749513e69a7bfb574fca20f09 (patch)
tree7e0e4cd58253f896d6371d7adad04c5a5809deb8 /src-qt5
parentGet the icon loading routines all switched over to the old QIcon::fromTheme()... (diff)
downloadlumina-4530400268bf9a8749513e69a7bfb574fca20f09.tar.gz
lumina-4530400268bf9a8749513e69a7bfb574fca20f09.tar.bz2
lumina-4530400268bf9a8749513e69a7bfb574fca20f09.zip
Cleanup some fallback routines for loading icons from the Qt theme methods.
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/libLumina/LIconCache.cpp13
-rw-r--r--src-qt5/core/libLumina/LuminaXDG.cpp9
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp21
-rw-r--r--src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.h2
4 files changed, 33 insertions, 12 deletions
diff --git a/src-qt5/core/libLumina/LIconCache.cpp b/src-qt5/core/libLumina/LIconCache.cpp
index 9d122df7..bb81bc47 100644
--- a/src-qt5/core/libLumina/LIconCache.cpp
+++ b/src-qt5/core/libLumina/LIconCache.cpp
@@ -55,9 +55,9 @@ QString LIconCache::findFile(QString icon){
if(icon.isEmpty()){ return ""; }
//Get the currently-set theme
QString cTheme = QIcon::themeName();
- if(cTheme.isEmpty()){
- QIcon::setThemeName("material-design-light");
- cTheme = "material-design-light";
+ if(cTheme.isEmpty()){
+ QIcon::setThemeName("material-design-light");
+ cTheme = "material-design-light";
}
//Make sure the current search paths correspond to this theme
if( QDir::searchPaths("icontheme").filter("/"+cTheme+"/").isEmpty() ){
@@ -309,7 +309,12 @@ bool LIconCache::isThemeIcon(QString id){
}
QIcon LIconCache::iconFromTheme(QString id){
- return QIcon::fromTheme(id);
+ QIcon ico = QIcon::fromTheme(id);
+ if(ico.isNull()){
+ //icon missing in theme? run the old icon-finder system
+ ico = QIcon(findFile(id));
+ }
+ return ico;
}
// === PRIVATE SLOTS ===
diff --git a/src-qt5/core/libLumina/LuminaXDG.cpp b/src-qt5/core/libLumina/LuminaXDG.cpp
index fed998a2..01b3305e 100644
--- a/src-qt5/core/libLumina/LuminaXDG.cpp
+++ b/src-qt5/core/libLumina/LuminaXDG.cpp
@@ -747,9 +747,12 @@ void LXDG::setEnvironmentVars(){
QIcon LXDG::findIcon(QString iconName, QString fallback){
//With the addition of the Lumina theme engine (8/3/17), switch back to using the Qt icon from theme method for apps
- QIcon tmp = QIcon::fromTheme(iconName);
- if(tmp.isNull()){ tmp = QIcon::fromTheme(fallback); }
- return tmp;
+ QIcon tmp;
+ if(!iconName.contains("libreoffice")){ //libreoffice is stupid - their svg icons are un-renderable with Qt
+ tmp = QIcon::fromTheme(iconName);
+ if(tmp.isNull()){ tmp = QIcon::fromTheme(fallback); }
+ }
+ if(!tmp.isNull()){ return tmp; } //found one in the theme
//NOTE: This was re-written on 11/10/15 to avoid using the QIcon::fromTheme() framework
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;
bgstack15