X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtuiapplication.cpp;h=974a28d31d4632f1ee7b4cc4abc0f96ed6a9b9d6;hb=092e6b212637ffbf68800584b7c1f32d1931b602;hp=2b6b58c8c0f73a0d26d0a86eecbcf7a7c812f213;hpb=5f13dd167785d830a851b134863dce231ec450dd;p=quassel.git diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 2b6b58c8..974a28d3 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -21,6 +21,7 @@ #include "qtuiapplication.h" #include +#include #include #ifdef HAVE_KDE4 @@ -35,12 +36,10 @@ QtUiApplication::QtUiApplication(int &argc, char **argv) #ifdef HAVE_KDE4 - : KApplication(), // KApplication is deprecated in KF5 + : KApplication() // KApplication is deprecated in KF5 #else - : QApplication(argc, argv), + : QApplication(argc, argv) #endif - Quassel(), - _aboutToQuit(false) { #ifdef HAVE_KDE4 Q_UNUSED(argc); Q_UNUSED(argv); @@ -73,18 +72,19 @@ QtUiApplication::QtUiApplication(int &argc, char **argv) } dataDirs.removeDuplicates(); - setDataDirPaths(dataDirs); + Quassel::setDataDirPaths(dataDirs); #else /* HAVE_KDE4 */ - setDataDirPaths(findDataDirPaths()); + Quassel::setDataDirPaths(Quassel::findDataDirPaths()); #endif /* HAVE_KDE4 */ #if defined(HAVE_KDE4) || defined(Q_OS_MAC) - disableCrashhandler(); + Quassel::disableCrashHandler(); #endif /* HAVE_KDE4 || Q_OS_MAC */ - setRunMode(Quassel::ClientOnly); + + Quassel::setRunMode(Quassel::ClientOnly); #if QT_VERSION < 0x050000 qInstallMsgHandler(Client::logMessage); @@ -169,13 +169,17 @@ bool QtUiApplication::init() // Some platforms don't set a default icon theme; chances are we can find our bundled theme though QIcon::setThemeName("breeze"); - // session resume - QtUi *gui = new QtUi(); - Client::init(gui); - // init gui only after the event loop has started - // QTimer::singleShot(0, gui, SLOT(init())); - gui->init(); - resumeSessionIfPossible(); + Client::init(new QtUi()); + + // Init UI only after the event loop has started + // TODO Qt5: Make this a lambda + QTimer::singleShot(0, this, SLOT(initUi())); + + Quassel::registerQuitHandler([]() { + QtUi::mainWindow()->quit(); + }); + + return true; } return false; @@ -185,12 +189,14 @@ bool QtUiApplication::init() QtUiApplication::~QtUiApplication() { Client::destroy(); + Quassel::destroy(); } -void QtUiApplication::quit() +void QtUiApplication::initUi() { - QtUi::mainWindow()->quit(); + QtUi::instance()->init(); + resumeSessionIfPossible(); } @@ -210,7 +216,10 @@ bool QtUiApplication::migrateSettings() // -------- // Check minor settings version, handling upgrades/downgrades as needed // Current minor version - const uint VERSION_MINOR_CURRENT = 6; + // + // 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 = 7; // Stored minor version uint versionMinor = s.versionMinor(); @@ -273,6 +282,24 @@ bool QtUiApplication::applySettingsMigration(QtUiSettings settings, const uint n // // In most cases, the goal is to preserve the older default values for keys that haven't been // 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 7: + { + // New default changes: UseProxy is no longer used in CoreAccountSettings + CoreAccountSettings s; + for (auto &&accountId : s.knownAccounts()) { + auto map = s.retrieveAccountData(accountId); + if (!map.value("UseProxy", false).toBool()) { + map["ProxyType"] = static_cast(QNetworkProxy::ProxyType::NoProxy); + } + map.remove("UseProxy"); + s.storeAccountData(accountId, map); + } + + // Migration complete! + return true; + } case 6: { // New default changes: sender colors switched around to Tango-ish theme