#include "buffermodel.h"
#include "chatlinemodel.h"
#include "contextmenuactionprovider.h"
+#include "icon.h"
#include "mainwin.h"
#include "qtuimessageprocessor.h"
#include "qtuisettings.h"
#include "types.h"
#include "util.h"
-QtUi *QtUi::_instance = nullptr;
MainWin *QtUi::_mainWin = nullptr;
QList<AbstractNotificationBackend *> QtUi::_notificationBackends;
QList<AbstractNotificationBackend::Notification> QtUi::_notifications;
+namespace {
+
+QtUi *_instance{nullptr};
+
+}
+
+
+QtUi *QtUi::instance()
+{
+ if (!_instance) {
+ _instance = new QtUi();
+ }
+ return _instance;
+}
+
+
QtUi::QtUi()
: GraphicalUi()
, _systemIconTheme{QIcon::themeName()}
{
- if (_instance != nullptr) {
- qWarning() << "QtUi has been instantiated again!";
- return;
- }
- _instance = this;
-
if (Quassel::isOptionSet("icontheme")) {
_systemIconTheme = Quassel::optionValue("icontheme");
QIcon::setThemeName(_systemIconTheme);
setupIconTheme();
- QApplication::setWindowIcon(QIcon::fromTheme("quassel"));
+ QApplication::setWindowIcon(icon::get("quassel"));
setContextMenuActionProvider(new ContextMenuActionProvider(this));
setToolBarActionProvider(new ToolBarActionProvider(this));
static const std::vector<std::pair<QString, QString>> supported {
{ "breeze", tr("Breeze") },
{ "breeze-dark", tr("Breeze Dark") },
+#ifdef WITH_OXYGEN_ICONS
{ "oxygen", tr("Oxygen") }
+#endif
};
std::vector<std::pair<QString, QString>> result;
}
+QString QtUi::systemIconTheme() const
+{
+ return _systemIconTheme;
+}
+
+
void QtUi::setupIconTheme()
{
// Add paths to our own icon sets to the theme search paths
}
}
- 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 (!_dummyThemeDir->isValid() || !QDir{_dummyThemeDir->path()}.mkpath("icons/quassel-icon-proxy/apps/32")) {
qWarning() << "Could not create temporary directory for proxying the system icon theme, using fallback";
QIcon::setThemeName(fallbackTheme);
+ emit iconThemeRefreshed();
return;
}
// Add this to XDG_DATA_DIRS, otherwise KIconLoader complains
if (!indexFile.open(QFile::WriteOnly|QFile::Truncate)) {
qWarning() << "Could not create index file for proxying the system icon theme, using fallback";
QIcon::setThemeName(fallbackTheme);
+ emit iconThemeRefreshed();
return;
}
if (indexFile.write(indexContents.toLatin1()) < 0) {
qWarning() << "Could not write index file for proxying the system icon theme, using fallback";
QIcon::setThemeName(fallbackTheme);
+ emit iconThemeRefreshed();
return;
}
indexFile.close();
// 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
}