X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtui.cpp;h=9bd81577c45ccb6bb9bc21a3f21b286108279858;hb=1a45f16a9734820fba42fe1db3f38dd1eee49df6;hp=d849fc5597e003c301f15b25fe0ba08ffb5dcfa0;hpb=470591c38960f9107d4808a81b0cae95cfe9c3e8;p=quassel.git diff --git a/src/qtui/qtui.cpp b/src/qtui/qtui.cpp index d849fc55..9bd81577 100644 --- a/src/qtui/qtui.cpp +++ b/src/qtui/qtui.cpp @@ -40,59 +40,54 @@ #include "types.h" #include "util.h" -QtUi *QtUi::_instance = nullptr; -MainWin *QtUi::_mainWin = nullptr; QList QtUi::_notificationBackends; QList QtUi::_notifications; + +QtUi *QtUi::instance() +{ + return static_cast(GraphicalUi::instance()); +} + + QtUi::QtUi() : GraphicalUi() , _systemIconTheme{QIcon::themeName()} { - if (_instance != nullptr) { - qWarning() << "QtUi has been instantiated again!"; - return; - } - _instance = this; + QtUiSettings uiSettings; + Quassel::loadTranslation(uiSettings.value("Locale", QLocale::system()).value()); if (Quassel::isOptionSet("icontheme")) { _systemIconTheme = Quassel::optionValue("icontheme"); QIcon::setThemeName(_systemIconTheme); } - - QtUiSettings uiSettings; - Quassel::loadTranslation(uiSettings.value("Locale", QLocale::system()).value()); - setupIconTheme(); - QApplication::setWindowIcon(icon::get("quassel")); - setContextMenuActionProvider(new ContextMenuActionProvider(this)); - setToolBarActionProvider(new ToolBarActionProvider(this)); - setUiStyle(new QtUiStyle(this)); - _mainWin = new MainWin(); - - setMainWidget(_mainWin); - - connect(_mainWin, SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &))); - connect(_mainWin, SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore())); - connect(Client::instance(), SIGNAL(bufferMarkedAsRead(BufferId)), SLOT(closeNotifications(BufferId))); } QtUi::~QtUi() { unregisterAllNotificationBackends(); - delete _mainWin; - _mainWin = nullptr; - _instance = nullptr; } void QtUi::init() { + setContextMenuActionProvider(new ContextMenuActionProvider(this)); + setToolBarActionProvider(new ToolBarActionProvider(this)); + + _mainWin.reset(new MainWin()); // TODO C++14: std::make_unique + setMainWidget(_mainWin.get()); + + connect(_mainWin.get(), SIGNAL(connectToCore(const QVariantMap &)), this, SIGNAL(connectToCore(const QVariantMap &))); + connect(_mainWin.get(), SIGNAL(disconnectFromCore()), this, SIGNAL(disconnectFromCore())); + connect(Client::instance(), SIGNAL(bufferMarkedAsRead(BufferId)), SLOT(closeNotifications(BufferId))); + _mainWin->init(); + QtUiSettings uiSettings; uiSettings.initAndNotify("UseSystemTrayIcon", this, SLOT(useSystemTrayChanged(QVariant)), true); @@ -274,7 +269,7 @@ std::vector> QtUi::availableIconThemes() const static const std::vector> supported { { "breeze", tr("Breeze") }, { "breeze-dark", tr("Breeze Dark") }, -#ifdef WITH_OYGEN_ICONS +#ifdef WITH_OXYGEN_ICONS { "oxygen", tr("Oxygen") } #endif }; @@ -345,14 +340,13 @@ void QtUi::refreshIconTheme() } } - if (_systemIconTheme.isEmpty() || _systemIconTheme == fallbackTheme || s.value("Icons/OverrideSystemTheme", false).toBool()) { + if (_systemIconTheme.isEmpty() || _systemIconTheme == fallbackTheme || s.value("Icons/OverrideSystemTheme", true).toBool()) { // We have a valid fallback theme and want to override the system theme (if it's even defined), so we're basically done QIcon::setThemeName(fallbackTheme); emit iconThemeRefreshed(); return; } -#if QT_VERSION >= 0x050000 // At this point, we have a system theme that we don't want to override, but that may not contain all // required icons. // We create a dummy theme that inherits first from the system theme, then from the supported fallback. @@ -402,10 +396,4 @@ void QtUi::refreshIconTheme() } indexFile.close(); QIcon::setThemeName("quassel-icon-proxy"); -#else - // Qt4 doesn't support QTemporaryDir. Since it's deprecated and slated to be removed soon anyway, we don't bother - // writing a replacement and simply don't support not overriding the system theme. - QIcon::setThemeName(fallbackTheme); - emit iconThemeRefreshed(); -#endif }