logger: Refactor the logging framework
[quassel.git] / src / qtui / qtuiapplication.cpp
index 73e67b2..c9475fe 100644 (file)
 
 #include "qtuiapplication.h"
 
-#include <QIcon>
 #include <QDir>
+#include <QFile>
 #include <QStringList>
 
 #ifdef HAVE_KDE4
 #  include <KStandardDirs>
 #endif
 
+#include "chatviewsettings.h"
 #include "client.h"
 #include "cliparser.h"
 #include "mainwin.h"
@@ -86,10 +87,7 @@ QtUiApplication::QtUiApplication(int &argc, char **argv)
 
     Quassel::setRunMode(Quassel::ClientOnly);
 
-#if QT_VERSION < 0x050000
-    qInstallMsgHandler(Client::logMessage);
-#else
-    qInstallMessageHandler(Client::logMessage);
+#if QT_VERSION >= 0x050000
     connect(this, &QGuiApplication::commitDataRequest, this, &QtUiApplication::commitData, Qt::DirectConnection);
     connect(this, &QGuiApplication::saveStateRequest, this, &QtUiApplication::saveState, Qt::DirectConnection);
 #endif
@@ -109,30 +107,6 @@ bool QtUiApplication::init()
             return false;
         }
 
-        // Checking if settings Icon Theme is valid
-        QString savedIcontheme = QtUiSettings().value("IconTheme", QVariant("")).toString();
-#ifndef WITH_OXYGEN
-        if (savedIcontheme == "oxygen")
-            QtUiSettings().remove("IconTheme");
-#endif
-#ifndef WITH_BREEZE
-        if (savedIcontheme == "breeze")
-            QtUiSettings().remove("IconTheme");
-#endif
-#ifndef WITH_BREEZE_DARK
-        if (savedIcontheme == "breezedark")
-            QtUiSettings().remove("IconTheme");
-#endif
-
-        // Set the icon theme
-        if (Quassel::isOptionSet("icontheme"))
-            QIcon::setThemeName(Quassel::optionValue("icontheme"));
-        else if (QtUiSettings().value("IconTheme", QVariant("")).toString() != "")
-            QIcon::setThemeName(QtUiSettings().value("IconTheme").toString());
-        else if (QIcon::themeName().isEmpty())
-            // Some platforms don't set a default icon theme; chances are we can find our bundled theme though
-            QIcon::setThemeName("breeze");
-
         Client::init(new QtUi());
 
         // Init UI only after the event loop has started
@@ -143,7 +117,6 @@ bool QtUiApplication::init()
             QtUi::mainWindow()->quit();
         });
 
-
         return true;
     }
     return false;
@@ -183,7 +156,7 @@ bool QtUiApplication::migrateSettings()
     //
     // NOTE:  If you increase the minor version, you MUST ALSO add new version upgrade logic in
     // applySettingsMigration()!  Otherwise, settings upgrades will fail.
-    const uint VERSION_MINOR_CURRENT = 8;
+    const uint VERSION_MINOR_CURRENT = 9;
     // Stored minor version
     uint versionMinor = s.versionMinor();
 
@@ -248,6 +221,25 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n
     // saved.  Exceptions will be noted below.
     // NOTE:  If you add new upgrade logic here, you MUST ALSO increase VERSION_MINOR_CURRENT in
     // migrateSettings()!  Otherwise, your upgrade logic won't ever be called.
+    case 9:
+    {
+        // New default changes: show highest sender prefix mode, if available
+
+        // --------
+        // ChatView settings
+        ChatViewSettings chatViewSettings;
+        const QString senderPrefixModeId = "SenderPrefixMode";
+        if (!chatViewSettings.valueExists(senderPrefixModeId)) {
+            // New default is HighestMode, preserve previous behavior by setting to NoModes
+            chatViewSettings.setValue(senderPrefixModeId,
+                                      static_cast<int>(UiStyle::SenderPrefixMode::NoModes));
+        }
+        // --------
+
+        // Migration complete!
+        return true;
+    }
+
     case 8:
     {
         // New default changes: RegEx checkbox now toggles Channel regular expressions, too
@@ -295,6 +287,7 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n
         // --------
 
         // Migration complete!
+        return true;
     }
     case 7:
     {