X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtuiapplication.cpp;h=2438d9ccbdc61d48eb68cecfe26aca65d55bddae;hb=61f33c7895e324f6e95034d86897ad2e963653f1;hp=74be5b499f2deaba3617eb498d47e388cc1694a4;hpb=ab7ef4d24f62b5848b628482b7762ebfc0b53e1a;p=quassel.git diff --git a/src/qtui/qtuiapplication.cpp b/src/qtui/qtuiapplication.cpp index 74be5b49..2438d9cc 100644 --- a/src/qtui/qtuiapplication.cpp +++ b/src/qtui/qtuiapplication.cpp @@ -25,7 +25,6 @@ #include #include "chatviewsettings.h" -#include "cliparser.h" #include "logmessage.h" #include "mainwin.h" #include "qtui.h" @@ -35,12 +34,6 @@ QtUiApplication::QtUiApplication(int &argc, char **argv) : QApplication(argc, argv) { - Quassel::setDataDirPaths(Quassel::findDataDirPaths()); - Quassel::setRunMode(Quassel::ClientOnly); - - connect(this, &QGuiApplication::commitDataRequest, this, &QtUiApplication::commitData, Qt::DirectConnection); - connect(this, &QGuiApplication::saveStateRequest, this, &QtUiApplication::saveState, Qt::DirectConnection); - #if QT_VERSION >= 0x050600 QGuiApplication::setFallbackSessionManagementEnabled(false); #endif @@ -49,31 +42,24 @@ QtUiApplication::QtUiApplication(int &argc, char **argv) void QtUiApplication::init() { - if (!Quassel::init()) { - throw ExitException{EXIT_FAILURE, tr("Could not initialize Quassel!")}; - } - // Settings upgrade/downgrade handling if (!migrateSettings()) { throw ExitException{EXIT_FAILURE, tr("Could not load or upgrade client settings!")}; } - _client.reset(new Client(std::unique_ptr(new QtUi()))); // TODO C++14: std::make_unique + _client = std::make_unique(std::make_unique()); // Init UI only after the event loop has started - // TODO Qt5: Make this a lambda - QTimer::singleShot(0, this, SLOT(initUi())); -} - - -void QtUiApplication::initUi() -{ - QtUi::instance()->init(); + QTimer::singleShot(0, this, [this]() { + QtUi::instance()->init(); + connect(this, &QGuiApplication::commitDataRequest, this, &QtUiApplication::commitData, Qt::DirectConnection); + connect(this, &QGuiApplication::saveStateRequest, this, &QtUiApplication::saveState, Qt::DirectConnection); - // Needs to happen after UI init, so the MainWin quit handler is registered first - Quassel::registerQuitHandler(quitHandler()); + // Needs to happen after UI init, so the MainWin quit handler is registered first + Quassel::registerQuitHandler(quitHandler()); - resumeSessionIfPossible(); + resumeSessionIfPossible(); + }); } @@ -82,7 +68,7 @@ Quassel::QuitHandler QtUiApplication::quitHandler() // Wait until the Client instance is destroyed before quitting the event loop return [this]() { quInfo() << "Client shutting down..."; - connect(_client.get(), SIGNAL(destroyed()), QCoreApplication::instance(), SLOT(quit())); + connect(_client.get(), &QObject::destroyed, QCoreApplication::instance(), &QCoreApplication::quit); _client.release()->deleteLater(); }; }