Adapt custom stylesheet path to new default install location
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 12 Feb 2015 21:24:34 +0000 (22:24 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 12 Feb 2015 21:24:34 +0000 (22:24 +0100)
When switching from a KDE4 build to Qt5/KF5, the default install
location for data files switches from /usr/share/apps/quassel to
/usr/share/quassel, as is standard. Users who have selected one of
the pre-installed stylesheets will use that setting.

Thus, if a custom stylesheet is configured and points to /usr/share/apps,
in case it is not found we will now try and look into /usr/share as well.
If we find the stylesheet in the new location, we'll also update the
stored setting.

src/uisupport/uistyle.cpp

index 944b604..ea0cb19 100644 (file)
@@ -104,8 +104,22 @@ void UiStyle::loadStyleSheet()
     QString styleSheet;
     styleSheet += loadStyleSheet("file:///" + Quassel::findDataFilePath("stylesheets/default.qss"));
     styleSheet += loadStyleSheet("file:///" + Quassel::configDirPath() + "settings.qss");
     QString styleSheet;
     styleSheet += loadStyleSheet("file:///" + Quassel::findDataFilePath("stylesheets/default.qss"));
     styleSheet += loadStyleSheet("file:///" + Quassel::configDirPath() + "settings.qss");
-    if (s.value("UseCustomStyleSheet", false).toBool())
-        styleSheet += loadStyleSheet("file:///" + s.value("CustomStyleSheetPath").toString(), true);
+    if (s.value("UseCustomStyleSheet", false).toBool()) {
+        QString customSheetPath(s.value("CustomStyleSheetPath").toString());
+        QString customSheet = loadStyleSheet("file:///" + customSheetPath, true);
+        if (customSheet.isEmpty()) {
+            // MIGRATION: changed default install path for data from /usr/share/apps to /usr/share
+            if (customSheetPath.startsWith("/usr/share/apps/quassel")) {
+                customSheetPath.replace(QRegExp("^/usr/share/apps"), "/usr/share");
+                customSheet = loadStyleSheet("file:///" + customSheetPath, true);
+                if (!customSheet.isEmpty()) {
+                    s.setValue("CustomStyleSheetPath", customSheetPath);
+                    qDebug() << "Custom stylesheet path migrated to" << customSheetPath;
+                }
+            }
+        }
+        styleSheet += customSheet;
+    }
     styleSheet += loadStyleSheet("file:///" + Quassel::optionValue("qss"), true);
 
     if (!styleSheet.isEmpty()) {
     styleSheet += loadStyleSheet("file:///" + Quassel::optionValue("qss"), true);
 
     if (!styleSheet.isEmpty()) {