icons: Warn on missing icons
authorManuel Nickschas <sputnick@quassel-irc.org>
Sun, 17 Jun 2018 11:39:25 +0000 (13:39 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 17 Jun 2018 17:20:09 +0000 (19:20 +0200)
Provide new helper functions icon::get() that replace the uses of
QIcon::fromTheme. These functions still use fromTheme() internally,
but log a warning if an icon could not be found. This should make
it easier to detect problems with icons.

Replace all uses of QIcon::fromTheme() with icon::get(), remove
useless fallbacks as that should be taken care of by the normal
icon loader mechanism.

Update the icon import script accordingly.

51 files changed:
icons/import/import_theme.pl
src/qtui/aboutdlg.cpp
src/qtui/bufferwidget.cpp
src/qtui/channellistdlg.cpp
src/qtui/chatitem.cpp
src/qtui/chatmonitorview.cpp
src/qtui/chatscene.cpp
src/qtui/chatviewsearchbar.cpp
src/qtui/coreconfigwizard.cpp
src/qtui/coreconnectdlg.cpp
src/qtui/coreconnectionstatuswidget.cpp
src/qtui/coreinfodlg.cpp
src/qtui/indicatornotificationbackend.cpp
src/qtui/inputwidget.cpp
src/qtui/inputwidget.h
src/qtui/knotificationbackend.cpp
src/qtui/legacysystemtray.cpp
src/qtui/mainpage.cpp
src/qtui/mainwin.cpp
src/qtui/phononnotificationbackend.cpp
src/qtui/qtmultimedianotificationbackend.cpp
src/qtui/qtui.cpp
src/qtui/settingsdlg.cpp
src/qtui/settingspagedlg.cpp
src/qtui/settingspages/aliasessettingspage.cpp
src/qtui/settingspages/bufferviewsettingspage.cpp
src/qtui/settingspages/chatmonitorsettingspage.cpp
src/qtui/settingspages/coreaccountsettingspage.cpp
src/qtui/settingspages/corehighlightsettingspage.cpp
src/qtui/settingspages/highlightsettingspage.cpp
src/qtui/settingspages/identitiessettingspage.cpp
src/qtui/settingspages/identityeditwidget.cpp
src/qtui/settingspages/ignorelistsettingspage.cpp
src/qtui/settingspages/keysequencewidget.cpp
src/qtui/settingspages/networkssettingspage.cpp
src/qtui/simplenetworkeditor.cpp
src/qtui/snorenotificationbackend.cpp
src/qtui/statusnotifieritem.cpp
src/qtui/systemtray.cpp
src/qtui/systrayanimationnotificationbackend.cpp
src/qtui/systraynotificationbackend.cpp
src/qtui/taskbarnotificationbackend.cpp
src/qtui/topicwidget.cpp
src/uisupport/CMakeLists.txt
src/uisupport/clearablelineedit.cpp
src/uisupport/contextmenuactionprovider.cpp
src/uisupport/icon.cpp [new file with mode: 0644]
src/uisupport/icon.h [new file with mode: 0644]
src/uisupport/networkmodelcontroller.cpp
src/uisupport/toolbaractionprovider.cpp
src/uisupport/uistyle.cpp

index 6ac923b..42f60bb 100755 (executable)
@@ -62,13 +62,14 @@ while(<BLACKLIST>) {
 }
 close BLACKLIST;
 
-# We now grep the source for QIcon::fromTheme("fubar") to find required icons
+# We now grep the source for icon::get() to find required icons
 print "Grepping $srcdir for required icons...\n";
-my @results = `grep -r QIcon::fromTheme\\(\\" $srcdir`;
+my @results = `grep -r icon::get $srcdir`;
 foreach(@results) {
-  next unless my ($name) = /\W+QIcon::fromTheme\(\"([-\w]+)/;
-  $req_icons{$name} = 1
-    unless exists $blacklist{$name};
+  next unless my (@names) = /\W+icon::get\((?:\"([-\w]+)\")|(?:\{\s*\"([-\w]+)\"(?:,\s*\"([-\w]+)\")*\s*\})/;
+  foreach(@names) {
+    $req_icons{$_} = 1 unless not defined or exists $blacklist{$_};
+  }
 }
 
 # Clean old output dir
index 02f2a6a..2fc3d6e 100644 (file)
 #include "aboutdlg.h"
 
 #include <QDateTime>
-#include <QIcon>
+#include <QPixmap>
 
 #include "aboutdata.h"
+#include "icon.h"
 #include "quassel.h"
 
 AboutDlg::AboutDlg(QWidget *parent)
@@ -44,7 +45,7 @@ AboutDlg::AboutDlg(QWidget *parent)
     ui.contributorTextBrowser->setHtml(contributors());
     ui.thanksToTextBrowser->setHtml(thanksTo());
 
-    setWindowIcon(QIcon::fromTheme("quassel", QIcon(":/icons/quassel.png")));
+    setWindowIcon(icon::get("quassel"));
 }
 
 
index cb3c33e..825bc23 100644 (file)
@@ -18,7 +18,6 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QIcon>
 #include <QLayout>
 #include <QKeyEvent>
 #include <QMenu>
@@ -33,6 +32,7 @@
 #include "chatviewsearchcontroller.h"
 #include "chatviewsettings.h"
 #include "client.h"
+#include "icon.h"
 #include "multilineedit.h"
 #include "qtui.h"
 #include "settings.h"
@@ -77,16 +77,16 @@ BufferWidget::BufferWidget(QWidget *parent)
 
     Action *zoomInChatview = coll->add<Action>("ZoomInChatView", this, SLOT(zoomIn()));
     zoomInChatview->setText(tr("Zoom In"));
-    zoomInChatview->setIcon(QIcon::fromTheme("zoom-in"));
+    zoomInChatview->setIcon(icon::get("zoom-in"));
     zoomInChatview->setShortcut(QKeySequence::ZoomIn);
 
     Action *zoomOutChatview = coll->add<Action>("ZoomOutChatView", this, SLOT(zoomOut()));
-    zoomOutChatview->setIcon(QIcon::fromTheme("zoom-out"));
+    zoomOutChatview->setIcon(icon::get("zoom-out"));
     zoomOutChatview->setText(tr("Zoom Out"));
     zoomOutChatview->setShortcut(QKeySequence::ZoomOut);
 
     Action *zoomOriginalChatview = coll->add<Action>("ZoomOriginalChatView", this, SLOT(zoomOriginal()));
-    zoomOriginalChatview->setIcon(QIcon::fromTheme("zoom-original"));
+    zoomOriginalChatview->setIcon(icon::get("zoom-original"));
     zoomOriginalChatview->setText(tr("Actual Size"));
     //zoomOriginalChatview->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0)); // used for RTS switching
 
index d64ac81..76b81bb 100644 (file)
 
 #include <QHeaderView>
 #include <QHBoxLayout>
-#include <QIcon>
 #include <QSpacerItem>
 
 #include "client.h"
 #include "clientirclisthelper.h"
+#include "icon.h"
 
 ChannelListDlg::ChannelListDlg(QWidget *parent)
     : QDialog(parent),
@@ -41,7 +41,7 @@ ChannelListDlg::ChannelListDlg(QWidget *parent)
     _sortFilter.setFilterKeyColumn(-1);
 
     ui.setupUi(this);
-    ui.advancedModeLabel->setPixmap(QIcon::fromTheme("edit-rename").pixmap(22));
+    ui.advancedModeLabel->setPixmap(icon::get("edit-rename").pixmap(22));
 
     ui.channelListView->setSelectionBehavior(QAbstractItemView::SelectRows);
     ui.channelListView->setSelectionMode(QAbstractItemView::SingleSelection);
@@ -54,7 +54,7 @@ ChannelListDlg::ChannelListDlg(QWidget *parent)
 
     ui.searchChannelsButton->setAutoDefault(false);
 
-    setWindowIcon(QIcon::fromTheme("format-list-unordered"));
+    setWindowIcon(icon::get("format-list-unordered"));
 
     connect(ui.advancedModeLabel, SIGNAL(clicked()), this, SLOT(toggleMode()));
     connect(ui.searchChannelsButton, SIGNAL(clicked()), this, SLOT(requestSearch()));
@@ -132,14 +132,14 @@ void ChannelListDlg::setAdvancedMode(bool advanced)
             delete _simpleModeSpacer;
             _simpleModeSpacer = 0;
         }
-        ui.advancedModeLabel->setPixmap(QIcon::fromTheme("edit-clear-locationbar-rtl", QIcon::fromTheme("edit-clear")).pixmap(16));
+        ui.advancedModeLabel->setPixmap(icon::get("edit-clear-locationbar-rtl").pixmap(16));
     }
     else {
         if (!_simpleModeSpacer) {
             _simpleModeSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
             ui.searchLayout->insertSpacerItem(0, _simpleModeSpacer);
         }
-        ui.advancedModeLabel->setPixmap(QIcon::fromTheme("edit-rename").pixmap(16));
+        ui.advancedModeLabel->setPixmap(icon::get("edit-rename").pixmap(16));
     }
 
     ui.channelNameLineEdit->clear();
index fb5d6fa..4da2bb4 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "chatitem.h"
+
 #include <QApplication>
 #include <QClipboard>
 #include <QDesktopServices>
 #include <QFontMetrics>
 #include <QGraphicsSceneMouseEvent>
-#include <QIcon>
 #include <QPainter>
 #include <QPalette>
 #include <QTextLayout>
 
 #include "buffermodel.h"
 #include "bufferview.h"
-#include "chatitem.h"
 #include "chatline.h"
 #include "chatlinemodel.h"
 #include "chatview.h"
 #include "contextmenuactionprovider.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "qtui.h"
 #include "qtuistyle.h"
@@ -798,7 +799,7 @@ void ContentsChatItem::addActionsToMenu(QMenu *menu, const QPointF &pos)
         switch (click.type()) {
         case Clickable::Url:
             privateData()->activeClickable = click;
-            menu->addAction(QIcon::fromTheme("edit-copy"), tr("Copy Link Address"),
+            menu->addAction(icon::get("edit-copy"), tr("Copy Link Address"),
                 &_actionProxy, SLOT(copyLinkToClipboard()))->setData(QVariant::fromValue<void *>(this));
             break;
         case Clickable::Channel:
index 50e5b1f..932e2ab 100644 (file)
 #include "chatmonitorview.h"
 
 #include <QAction>
-#include <QIcon>
 #include <QMenu>
 #include <QContextMenuEvent>
 
+#include "buffermodel.h"
 #include "chatmonitorfilter.h"
 #include "chatlinemodel.h"
 #include "chatitem.h"
 #include "chatscene.h"
 #include "client.h"
+#include "clientignorelistmanager.h"
+#include "icon.h"
 #include "networkmodel.h"
-#include "buffermodel.h"
 #include "messagemodel.h"
 #include "qtuisettings.h"
 #include "settingspagedlg.h"
 #include "settingspages/chatmonitorsettingspage.h"
-#include "clientignorelistmanager.h"
 
 ChatMonitorView::ChatMonitorView(ChatMonitorFilter *filter, QWidget *parent)
     : ChatView(filter, parent),
@@ -73,7 +73,7 @@ void ChatMonitorView::addActionsToMenu(QMenu *menu, const QPointF &pos)
     }
 
     menu->addSeparator();
-    menu->addAction(QIcon::fromTheme("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
+    menu->addAction(icon::get("configure"), tr("Configure..."), this, SLOT(showSettingsPage()));
 }
 
 
index 5ece1ff..6027569 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "chatscene.h"
+
 #include <QApplication>
 #include <QClipboard>
 #include <QDesktopServices>
 #include <QDrag>
 #include <QGraphicsSceneMouseEvent>
-#include <QIcon>
 #include <QMenu>
 #include <QMenuBar>
 #include <QMimeData>
 #include "chatitem.h"
 #include "chatline.h"
 #include "chatlinemodelitem.h"
-#include "chatscene.h"
 #include "chatview.h"
+#include "chatviewsettings.h"
 #include "client.h"
 #include "clientbacklogmanager.h"
 #include "columnhandleitem.h"
 #include "contextmenuactionprovider.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "markerlineitem.h"
 #include "messagefilter.h"
 #include "qtui.h"
 #include "qtuistyle.h"
-#include "chatviewsettings.h"
 #include "webpreviewitem.h"
 
 const qreal minContentsWidth = 200;
@@ -836,7 +837,7 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
     // If we have text selected, insert the Copy Selection as first item
     if (isPosOverSelection(pos)) {
         QAction *sep = menu.insertSeparator(menu.actions().first());
-        QAction *act = new Action(QIcon::fromTheme("edit-copy"), tr("Copy Selection"), &menu, this,
+        QAction *act = new Action(icon::get("edit-copy"), tr("Copy Selection"), &menu, this,
             SLOT(selectionToClipboard()), QKeySequence::Copy);
         menu.insertAction(sep, act);
 
@@ -845,7 +846,7 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
             searchSelectionText = searchSelectionText.left(_webSearchSelectionTextMaxVisible).append(QString::fromUtf8("…"));
         searchSelectionText = tr("Search '%1'").arg(searchSelectionText);
 
-        QAction *webSearchAction = new Action(QIcon::fromTheme("edit-find"), searchSelectionText, &menu, this, SLOT(webSearchOnSelection()));
+        QAction *webSearchAction = new Action(icon::get("edit-find"), searchSelectionText, &menu, this, SLOT(webSearchOnSelection()));
         menu.insertAction(sep, webSearchAction);
     }
 
index a55c19d..279e0e4 100644 (file)
 
 #include "chatviewsearchbar.h"
 
-#include <QIcon>
-
 #include "action.h"
 #include "actioncollection.h"
+#include "icon.h"
 #include "qtui.h"
 
 ChatViewSearchBar::ChatViewSearchBar(QWidget *parent)
     : QWidget(parent)
 {
     ui.setupUi(this);
-    ui.hideButton->setIcon(QIcon::fromTheme("dialog-close"));
-    ui.searchUpButton->setIcon(QIcon::fromTheme("go-up"));
-    ui.searchDownButton->setIcon(QIcon::fromTheme("go-down"));
+    ui.hideButton->setIcon(icon::get("dialog-close"));
+    ui.searchUpButton->setIcon(icon::get("go-up"));
+    ui.searchDownButton->setIcon(icon::get("go-down"));
     _searchDelayTimer.setSingleShot(true);
 
     layout()->setContentsMargins(0, 0, 0, 0);
index 7a06778..471837b 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "coreconfigwizard.h"
+
 #include <QDebug>
 #include <QAbstractButton>
 #include <QCoreApplication>
 #include <QFormLayout>
-#include <QIcon>
 #include <QSpinBox>
 
-#include "coreconfigwizard.h"
-#include "coreconnection.h"
-
 #include "client.h"
+#include "coreconnection.h"
+#include "icon.h"
 
 namespace {
 
@@ -159,7 +159,7 @@ CoreConfigWizard::CoreConfigWizard(CoreConnection *connection, const QVariantLis
     setModal(true);
 
     setWindowTitle(CoreConfigWizard::tr("Core Configuration Wizard"));
-    setPixmap(QWizard::LogoPixmap, QIcon::fromTheme("quassel", QIcon(":/icons/quassel.png")).pixmap(48));
+    setPixmap(QWizard::LogoPixmap, icon::get("quassel").pixmap(48));
 
     connect(connection, SIGNAL(coreSetupSuccess()), SLOT(coreSetupSuccess()));
     connect(connection, SIGNAL(coreSetupFailed(QString)), SLOT(coreSetupFailed(QString)));
index 02b504b..7bbcfd9 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "coreconnectdlg.h"
+
 #include <QDialogButtonBox>
-#include <QIcon>
 #include <QVBoxLayout>
 
-#include "coreconnectdlg.h"
-
 #include "clientsettings.h"
 #include "coreaccountsettingspage.h"
+#include "icon.h"
 
 CoreConnectDlg::CoreConnectDlg(QWidget *parent) : QDialog(parent)
 {
@@ -39,7 +39,7 @@ CoreConnectDlg::CoreConnectDlg(QWidget *parent) : QDialog(parent)
         _settingsPage->setSelectedAccount(lastAccount);
 
     setWindowTitle(tr("Connect to Core"));
-    setWindowIcon(QIcon::fromTheme("network-disconnect"));
+    setWindowIcon(icon::get("network-disconnect"));
 
     QVBoxLayout *layout = new QVBoxLayout(this);
     layout->addWidget(_settingsPage);
index 976feb3..844b0e2 100644 (file)
@@ -20,9 +20,8 @@
 
 #include "coreconnectionstatuswidget.h"
 
-#include <QIcon>
-
 #include "client.h"
+#include "icon.h"
 #include "signalproxy.h"
 
 CoreConnectionStatusWidget::CoreConnectionStatusWidget(CoreConnection *connection, QWidget *parent)
@@ -80,11 +79,11 @@ void CoreConnectionStatusWidget::connectionStateChanged(CoreConnection::Connecti
 {
     if (state >= CoreConnection::Connected) {
         if (coreConnection()->isEncrypted()) {
-            ui.sslLabel->setPixmap(QIcon::fromTheme("security-high").pixmap(16));
+            ui.sslLabel->setPixmap(icon::get("security-high").pixmap(16));
             ui.sslLabel->setToolTip(tr("The connection to your core is encrypted with SSL."));
         }
         else {
-            ui.sslLabel->setPixmap(QIcon::fromTheme("security-low").pixmap(16));
+            ui.sslLabel->setPixmap(icon::get("security-low").pixmap(16));
             ui.sslLabel->setToolTip(tr("The connection to your core is not encrypted."));
         }
         ui.sslLabel->show();
index 299a94f..e80450f 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QMessageBox>
-
 #include "coreinfodlg.h"
 
-#include "client.h"
+#include <QMessageBox>
+
 #include "bufferwidget.h"
+#include "client.h"
+#include "icon.h"
 
 CoreInfoDlg::CoreInfoDlg(QWidget *parent) : QDialog(parent) {
     ui.setupUi(this);
@@ -33,7 +34,7 @@ CoreInfoDlg::CoreInfoDlg(QWidget *parent) : QDialog(parent) {
     coreInfoChanged(coreInfo->coreData());
 
     // Warning icon
-    ui.coreUnsupportedIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16));
+    ui.coreUnsupportedIcon->setPixmap(icon::get("dialog-warning").pixmap(16));
 
     updateUptime();
     startTimer(1000);
index e3cb0e3..15e765b 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "client.h"
 #include "clientsettings.h"
+#include "icon"
 #include "mainwin.h"
 #include "networkmodel.h"
 #include "qtui.h"
@@ -177,7 +178,7 @@ IndicatorNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent)
 {
     ui.setupUi(this);
     // FIXME find proper icon (this one is used by the plasmoid as well)
-    ui.enabled->setIcon(QIcon::fromTheme("mail-message-new"));
+    ui.enabled->setIcon(icon::get("mail-message-new"));
 
     connect(ui.enabled, SIGNAL(toggled(bool)), SLOT(widgetChanged()));
 }
index 756d064..8d84233 100644 (file)
 #include "inputwidget.h"
 
 #include <QIcon>
+#include <QPainter>
+#include <QPixmap>
+#include <QRect>
 
 #include "action.h"
 #include "actioncollection.h"
 #include "bufferview.h"
 #include "client.h"
+#include "icon.h"
 #include "ircuser.h"
 #include "networkmodel.h"
 #include "qtui.h"
 #include "qtuisettings.h"
 #include "tabcompleter.h"
-#include <QPainter>
 
 const int leftMargin = 3;
 
@@ -61,10 +64,10 @@ InputWidget::InputWidget(QWidget *parent)
     ui.inputEdit->setMode(MultiLineEdit::MultiLine);
     ui.inputEdit->setPasteProtectionEnabled(true);
 
-    ui.boldButton->setIcon(QIcon::fromTheme("format-text-bold"));
-    ui.italicButton->setIcon(QIcon::fromTheme("format-text-italic"));
-    ui.underlineButton->setIcon(QIcon::fromTheme("format-text-underline"));
-    ui.clearButton->setIcon(QIcon::fromTheme("edit-clear"));
+    ui.boldButton->setIcon(icon::get("format-text-bold"));
+    ui.italicButton->setIcon(icon::get("format-text-italic"));
+    ui.underlineButton->setIcon(icon::get("format-text-underline"));
+    ui.clearButton->setIcon(icon::get("edit-clear"));
     ui.encryptionIconLabel->hide();
 
     _colorMenu = new QMenu();
@@ -96,8 +99,8 @@ InputWidget::InputWidget(QWidget *parent)
     connect(_colorFillMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorHighlightChosen(QAction *)));
 
     // Needs to be done after adding the menu, otherwise the icon mysteriously vanishes until clicked
-    ui.textcolorButton->setIcon(QIcon::fromTheme("format-text-color"));
-    ui.highlightcolorButton->setIcon(QIcon::fromTheme("format-fill-color"));
+    ui.textcolorButton->setIcon(icon::get("format-text-color"));
+    ui.highlightcolorButton->setIcon(icon::get("format-fill-color"));
 
     // Show/hide style button
     connect(ui.showStyleButton, SIGNAL(toggled(bool)), this, SLOT(setStyleOptionsExpanded(bool)));
@@ -529,7 +532,7 @@ void InputWidget::updateNickSelector() const
     ui.ownNick->addItems(nicks);
 
     if (me && me->isAway())
-        ui.ownNick->setItemData(nickIdx, QIcon::fromTheme("user-away"), Qt::DecorationRole);
+        ui.ownNick->setItemData(nickIdx, icon::get({"im-user-away", "user-away"}), Qt::DecorationRole);
 
     ui.ownNick->setCurrentIndex(nickIdx);
 }
@@ -683,7 +686,7 @@ void InputWidget::colorChosen(QAction *action)
         mergeFormatOnSelection(fmt);
     }
     ui.textcolorButton->setDefaultAction(action);
-    ui.textcolorButton->setIcon(createColorToolButtonIcon(QIcon::fromTheme("format-text-color"), color));
+    ui.textcolorButton->setIcon(createColorToolButtonIcon(icon::get("format-text-color"), color));
 }
 
 
@@ -703,7 +706,7 @@ void InputWidget::colorHighlightChosen(QAction *action)
         mergeFormatOnSelection(fmt);
     }
     ui.highlightcolorButton->setDefaultAction(action);
-    ui.highlightcolorButton->setIcon(createColorToolButtonIcon(QIcon::fromTheme("format-fill-color"), color));
+    ui.highlightcolorButton->setIcon(createColorToolButtonIcon(icon::get("format-fill-color"), color));
 }
 
 
index dcf3b5a..b4aaf0f 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#ifndef INPUTWIDGET_H
-#define INPUTWIDGET_H
+#pragma once
 
-#include "ui_inputwidget.h"
+#include <QHash>
+#include <QIcon>
+#include <QMap>
+#include <QTextCharFormat>
 
 #include "abstractitemview.h"
+#include "action.h"
 #include "buffermodel.h"
 #include "bufferinfo.h"
 #include "identity.h"
 #include "network.h"
-#include <action.h>
+
+#include "ui_inputwidget.h"
 
 class MultiLineEdit;
 
@@ -197,6 +201,3 @@ public:
     MouseWheelFilter(QObject *parent = 0);
     virtual bool eventFilter(QObject *obj, QEvent *event);
 };
-
-
-#endif // INPUTWIDGET_H
index c23a83b..e7ba2d4 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "knotificationbackend.h"
 
-#include <QIcon>
 #include <QTextDocument>
 #include <QVBoxLayout>
 
@@ -33,6 +32,7 @@
 #endif
 
 #include "client.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "networkmodel.h"
 #include "qtui.h"
@@ -66,7 +66,7 @@ void KNotificationBackend::notify(const Notification &n)
 #else
     QString message = QString("<b>&lt;%1&gt;</b> %2").arg(n.sender, n.message.toHtmlEscaped());
 #endif
-    KNotification *notification = KNotification::event(type, message, QIcon::fromTheme("dialog-information").pixmap(48), QtUi::mainWindow(),
+    KNotification *notification = KNotification::event(type, message, icon::get("dialog-information").pixmap(48), QtUi::mainWindow(),
         KNotification::RaiseWidgetOnActivation
         |KNotification::CloseWhenWidgetActivated
         |KNotification::CloseOnTimeout);
index 0f1135a..40cd2ed 100644 (file)
@@ -20,9 +20,9 @@
 
 #ifndef QT_NO_SYSTEMTRAYICON
 
-#include <QIcon>
-
 #include "legacysystemtray.h"
+
+#include "icon.h"
 #include "mainwin.h"
 #include "qtui.h"
 
@@ -90,7 +90,7 @@ void LegacySystemTray::onModeChanged(Mode mode)
 void LegacySystemTray::updateIcon()
 {
     QString iconName = (state() == NeedsAttention) ? currentAttentionIconName() : currentIconName();
-    _trayIcon->setIcon(QIcon::fromTheme(iconName, QIcon{QString{":/icons/hicolor/24x24/status/%1.svg"}.arg(iconName)}));
+    _trayIcon->setIcon(icon::get(iconName, QString{":/icons/hicolor/24x24/status/%1.svg"}.arg(iconName)));
 }
 
 
index 9f4b9b8..9ebda87 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "mainpage.h"
+
 #include <QPushButton>
 #include <QImage>
 #include <QLabel>
 #include <QLayout>
 #include <QPainter>
 
-#include "mainpage.h"
-#include "coreconnectdlg.h"
 #include "client.h"
+#include "coreconnectdlg.h"
+#include "icon.h"
 
 MainPage::MainPage(QWidget *parent) : QWidget(parent)
 {
@@ -37,7 +39,7 @@ MainPage::MainPage(QWidget *parent) : QWidget(parent)
     layout->addWidget(label);
 
     if (Quassel::runMode() != Quassel::Monolithic) {
-        _connectButton = new QPushButton(QIcon::fromTheme("network-connect"), tr("Connect to Core..."));
+        _connectButton = new QPushButton(icon::get("network-connect"), tr("Connect to Core..."));
         _connectButton->setEnabled(Client::coreConnection()->state() == CoreConnection::Disconnected);
 
         connect(Client::coreConnection(), SIGNAL(stateChanged(CoreConnection::ConnectionState)), this, SLOT(coreConnectionStateChanged()));
index 00f8372..a7e50d2 100644 (file)
@@ -82,6 +82,7 @@
 #include "debuglogwidget.h"
 #include "debugmessagemodelfilter.h"
 #include "flatproxymodel.h"
+#include "icon.h"
 #include "inputwidget.h"
 #include "irclistmodel.h"
 #include "ircconnectionwizard.h"
@@ -194,7 +195,7 @@ MainWin::MainWin(QWidget *parent)
     setWindowTitle("Quassel IRC");
     setWindowIconText("Quassel IRC");
     // Set the default icon for all windows
-    QApplication::setWindowIcon(QIcon::fromTheme("quassel"));
+    QApplication::setWindowIcon(icon::get("quassel"));
     updateIcon();
 }
 
@@ -383,9 +384,9 @@ void MainWin::updateIcon()
 {
     QIcon icon;
     if (Client::isConnected())
-        icon = QIcon::fromTheme("quassel", QIcon(":/icons/quassel-128.png"));
+        icon = icon::get("quassel");
     else
-        icon = QIcon::fromTheme("inactive-quassel", QIcon(":/icons/inactive-quassel.png"));
+        icon = icon::get("inactive-quassel");
     setWindowIcon(icon);
 }
 
@@ -394,22 +395,22 @@ void MainWin::setupActions()
 {
     ActionCollection *coll = QtUi::actionCollection("General", tr("General"));
     // File
-    coll->addAction("ConnectCore", new Action(QIcon::fromTheme("connect-quassel", QIcon(":/icons/connect-quassel.png")), tr("&Connect to Core..."), coll,
+    coll->addAction("ConnectCore", new Action(icon::get("connect-quassel"), tr("&Connect to Core..."), coll,
             this, SLOT(showCoreConnectionDlg())));
-    coll->addAction("DisconnectCore", new Action(QIcon::fromTheme("disconnect-quassel", QIcon(":/icons/disconnect-quassel.png")), tr("&Disconnect from Core"), coll,
+    coll->addAction("DisconnectCore", new Action(icon::get("disconnect-quassel", ":/pics/quassel-eye.png"), tr("&Disconnect from Core"), coll,
             Client::instance(), SLOT(disconnectFromCore())));
-    coll->addAction("ChangePassword", new Action(QIcon::fromTheme("dialog-password"), tr("Change &Password..."), coll,
+    coll->addAction("ChangePassword", new Action(icon::get("dialog-password"), tr("Change &Password..."), coll,
             this, SLOT(showPasswordChangeDlg())));
-    coll->addAction("CoreInfo", new Action(QIcon::fromTheme("help-about"), tr("Core &Info..."), coll,
+    coll->addAction("CoreInfo", new Action(icon::get("help-about"), tr("Core &Info..."), coll,
             this, SLOT(showCoreInfoDlg())));
-    coll->addAction("ConfigureNetworks", new Action(QIcon::fromTheme("configure"), tr("Configure &Networks..."), coll,
+    coll->addAction("ConfigureNetworks", new Action(icon::get("configure"), tr("Configure &Networks..."), coll,
             this, SLOT(on_actionConfigureNetworks_triggered())));
     // QKeySequence::Quit was added in Qt 4.6, and could be used instead.  However, that key
     // sequence is empty by default on Windows, which would remove Ctrl-Q to quit.  It may be best
     // to just keep it this way.
     //
     // See https://doc.qt.io/qt-5/qkeysequence.html
-    coll->addAction("Quit", new Action(QIcon::fromTheme("application-exit"), tr("&Quit"), coll,
+    coll->addAction("Quit", new Action(icon::get("application-exit"), tr("&Quit"), coll,
             this, SLOT(quit()), Qt::CTRL + Qt::Key_Q));
 
     // View
@@ -420,11 +421,11 @@ void MainWin::setupActions()
     lockAct->setCheckable(true);
     connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool)));
 
-    coll->addAction("ToggleSearchBar", new Action(QIcon::fromTheme("edit-find"), tr("Show &Search Bar"), coll,
+    coll->addAction("ToggleSearchBar", new Action(icon::get("edit-find"), tr("Show &Search Bar"), coll,
             0, 0, QKeySequence::Find))->setCheckable(true);
     coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
             this, SLOT(showAwayLog())));
-    coll->addAction("ToggleMenuBar", new Action(QIcon::fromTheme("show-menu"), tr("Show &Menubar"), coll,
+    coll->addAction("ToggleMenuBar", new Action(icon::get("show-menu"), tr("Show &Menubar"), coll,
             0, 0))->setCheckable(true);
 
     coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
@@ -433,30 +434,30 @@ void MainWin::setupActions()
 #ifdef HAVE_KDE
     _fullScreenAction = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
 #else
-    _fullScreenAction = new Action(QIcon::fromTheme("view-fullscreen"), tr("&Full Screen Mode"), coll,
+    _fullScreenAction = new Action(icon::get("view-fullscreen"), tr("&Full Screen Mode"), coll,
         this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11));
     _fullScreenAction->setCheckable(true);
     coll->addAction("ToggleFullScreen", _fullScreenAction);
 #endif
 
     // Settings
-    QAction *configureShortcutsAct = new Action(QIcon::fromTheme("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
+    QAction *configureShortcutsAct = new Action(icon::get("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
         this, SLOT(showShortcutsDlg()));
     configureShortcutsAct->setMenuRole(QAction::NoRole);
     coll->addAction("ConfigureShortcuts", configureShortcutsAct);
 
 #ifdef Q_OS_MAC
-    QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
+    QAction *configureQuasselAct = new Action(icon::get("configure"), tr("&Configure Quassel..."), coll,
         this, SLOT(showSettingsDlg()));
     configureQuasselAct->setMenuRole(QAction::PreferencesRole);
 #else
-    QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
+    QAction *configureQuasselAct = new Action(icon::get("configure"), tr("&Configure Quassel..."), coll,
         this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7));
 #endif
     coll->addAction("ConfigureQuassel", configureQuasselAct);
 
     // Help
-    QAction *aboutQuasselAct = new Action(QIcon::fromTheme("quassel"), tr("&About Quassel"), coll,
+    QAction *aboutQuasselAct = new Action(icon::get("quassel"), tr("&About Quassel"), coll,
         this, SLOT(showAboutDlg()));
     aboutQuasselAct->setMenuRole(QAction::AboutRole);
     coll->addAction("AboutQuassel", aboutQuasselAct);
@@ -465,17 +466,17 @@ void MainWin::setupActions()
         qApp, SLOT(aboutQt()));
     aboutQtAct->setMenuRole(QAction::AboutQtRole);
     coll->addAction("AboutQt", aboutQtAct);
-    coll->addAction("DebugNetworkModel", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &NetworkModel"), coll,
+    coll->addAction("DebugNetworkModel", new Action(icon::get("tools-report-bug"), tr("Debug &NetworkModel"), coll,
             this, SLOT(on_actionDebugNetworkModel_triggered())));
-    coll->addAction("DebugBufferViewOverlay", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll,
+    coll->addAction("DebugBufferViewOverlay", new Action(icon::get("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll,
             this, SLOT(on_actionDebugBufferViewOverlay_triggered())));
-    coll->addAction("DebugMessageModel", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &MessageModel"), coll,
+    coll->addAction("DebugMessageModel", new Action(icon::get("tools-report-bug"), tr("Debug &MessageModel"), coll,
             this, SLOT(on_actionDebugMessageModel_triggered())));
-    coll->addAction("DebugHotList", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &HotList"), coll,
+    coll->addAction("DebugHotList", new Action(icon::get("tools-report-bug"), tr("Debug &HotList"), coll,
             this, SLOT(on_actionDebugHotList_triggered())));
-    coll->addAction("DebugLog", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &Log"), coll,
+    coll->addAction("DebugLog", new Action(icon::get("tools-report-bug"), tr("Debug &Log"), coll,
             this, SLOT(on_actionDebugLog_triggered())));
-    coll->addAction("ReloadStyle", new Action(QIcon::fromTheme("view-refresh"), tr("Reload Stylesheet"), coll,
+    coll->addAction("ReloadStyle", new Action(icon::get("view-refresh"), tr("Reload Stylesheet"), coll,
             QtUi::style(), SLOT(reload()), QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R)));
 
     coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll,
@@ -485,32 +486,32 @@ void MainWin::setupActions()
     coll = QtUi::actionCollection("TextFormat", tr("Text formatting"));
 
     coll->addAction("FormatApplyColor", new Action(
-                        QIcon::fromTheme("format-text-color"), tr("Apply foreground color"), coll,
+                        icon::get("format-text-color"), tr("Apply foreground color"), coll,
                         this, SLOT(on_inputFormatApplyColor_triggered()),
                         QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G)));
 
     coll->addAction("FormatApplyColorFill", new Action(
-                        QIcon::fromTheme("format-fill-color"), tr("Apply background color"), coll,
+                        icon::get("format-fill-color"), tr("Apply background color"), coll,
                         this, SLOT(on_inputFormatApplyColorFill_triggered()),
                         QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_B)));
 
     coll->addAction("FormatClear", new Action(
-                        QIcon::fromTheme("edit-clear"), tr("Clear formatting"), coll,
+                        icon::get("edit-clear"), tr("Clear formatting"), coll,
                         this, SLOT(on_inputFormatClear_triggered()),
                         QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C)));
 
     coll->addAction("FormatBold", new Action(
-                        QIcon::fromTheme("format-text-bold"), tr("Toggle bold"), coll,
+                        icon::get("format-text-bold"), tr("Toggle bold"), coll,
                         this, SLOT(on_inputFormatBold_triggered()),
                         QKeySequence::Bold));
 
     coll->addAction("FormatItalic", new Action(
-                        QIcon::fromTheme("format-text-italic"), tr("Toggle italics"), coll,
+                        icon::get("format-text-italic"), tr("Toggle italics"), coll,
                         this, SLOT(on_inputFormatItalic_triggered()),
                         QKeySequence::Italic));
 
     coll->addAction("FormatUnderline", new Action(
-                        QIcon::fromTheme("format-text-underline"), tr("Toggle underline"), coll,
+                        icon::get("format-text-underline"), tr("Toggle underline"), coll,
                         this, SLOT(on_inputFormatUnderline_triggered()), QKeySequence::Underline));
 
     // Navigation
@@ -574,13 +575,13 @@ void MainWin::setupActions()
             QKeySequence(jumpModifier + Qt::Key_9)))->setProperty("Index", 9);
 
     // Buffer navigation
-    coll->addAction("NextBufferView", new Action(QIcon::fromTheme("go-next-view"), tr("Activate Next Chat List"), coll,
+    coll->addAction("NextBufferView", new Action(icon::get("go-next-view"), tr("Activate Next Chat List"), coll,
             this, SLOT(nextBufferView()), QKeySequence(QKeySequence::Forward)));
-    coll->addAction("PreviousBufferView", new Action(QIcon::fromTheme("go-previous-view"), tr("Activate Previous Chat List"), coll,
+    coll->addAction("PreviousBufferView", new Action(icon::get("go-previous-view"), tr("Activate Previous Chat List"), coll,
             this, SLOT(previousBufferView()), QKeySequence::Back));
-    coll->addAction("NextBuffer", new Action(QIcon::fromTheme("go-down"), tr("Go to Next Chat"), coll,
+    coll->addAction("NextBuffer", new Action(icon::get("go-down"), tr("Go to Next Chat"), coll,
             this, SLOT(nextBuffer()), QKeySequence(Qt::ALT + Qt::Key_Down)));
-    coll->addAction("PreviousBuffer", new Action(QIcon::fromTheme("go-up"), tr("Go to Previous Chat"), coll,
+    coll->addAction("PreviousBuffer", new Action(icon::get("go-up"), tr("Go to Previous Chat"), coll,
             this, SLOT(previousBuffer()), QKeySequence(Qt::ALT + Qt::Key_Up)));
 }
 
@@ -644,7 +645,7 @@ void MainWin::setupMenus()
     _helpMenu->addAction(KStandardAction::aboutKDE(_kHelpMenu, SLOT(aboutKDE()), this));
 #endif
     _helpMenu->addSeparator();
-    _helpDebugMenu = _helpMenu->addMenu(QIcon::fromTheme("tools-report-bug"), tr("Debug"));
+    _helpDebugMenu = _helpMenu->addMenu(icon::get("tools-report-bug"), tr("Debug"));
     _helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
     _helpDebugMenu->addAction(coll->action("DebugBufferViewOverlay"));
     _helpDebugMenu->addAction(coll->action("DebugMessageModel"));
@@ -1069,7 +1070,7 @@ void MainWin::setupTransferWidget()
 
     auto action = dock->toggleViewAction();
     action->setText(tr("Show File Transfers"));
-    action->setIcon(QIcon::fromTheme("download"));
+    action->setIcon(icon::get("download"));
     action->setShortcut(QKeySequence(Qt::Key_F6));
     QtUi::actionCollection("General")->addAction("ShowTransferWidget", action);
     _viewMenu->addAction(action);
@@ -1780,7 +1781,7 @@ void MainWin::clientNetworkUpdated()
 
     switch (net->connectionState()) {
     case Network::Initialized:
-        action->setIcon(QIcon::fromTheme("network-connect"));
+        action->setIcon(icon::get("network-connect"));
         // if we have no currently selected buffer, jump to the first connecting statusbuffer
         if (!bufferWidget()->currentBuffer().isValid()) {
             QModelIndex idx = Client::networkModel()->networkIndex(net->networkId());
@@ -1791,10 +1792,10 @@ void MainWin::clientNetworkUpdated()
         }
         break;
     case Network::Disconnected:
-        action->setIcon(QIcon::fromTheme("network-disconnect"));
+        action->setIcon(icon::get("network-disconnect"));
         break;
     default:
-        action->setIcon(QIcon::fromTheme("network-wired"));
+        action->setIcon(icon::get("network-wired"));
     }
 }
 
index d48a576..7de23b1 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "phononnotificationbackend.h"
+
 #include <QFileDialog>
-#include <QIcon>
 #include <QUrl>
 
 #include <phonon/mediaobject.h>
 #include <phonon/backendcapabilities.h>
 
-#include "phononnotificationbackend.h"
-
 #include "clientsettings.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "qtui.h"
 
@@ -112,9 +112,9 @@ PhononNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent)
 {
     ui.setupUi(this);
     _audioAvailable = !Phonon::BackendCapabilities::availableAudioOutputDevices().isEmpty();
-    ui.enabled->setIcon(QIcon::fromTheme("media-playback-start"));
-    ui.play->setIcon(QIcon::fromTheme("media-playback-start"));
-    ui.open->setIcon(QIcon::fromTheme("document-open"));
+    ui.enabled->setIcon(icon::get("media-playback-start"));
+    ui.play->setIcon(icon::get("media-playback-start"));
+    ui.open->setIcon(icon::get("document-open"));
 
     connect(ui.enabled, SIGNAL(toggled(bool)), SLOT(widgetChanged()));
     connect(ui.filename, SIGNAL(textChanged(const QString &)), SLOT(widgetChanged()));
index 612c91c..afffd04 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "qtmultimedianotificationbackend.h"
+
 #include <QFileDialog>
-#include <QIcon>
 #include <QUrl>
 
-#include "qtmultimedianotificationbackend.h"
-
 #include "clientsettings.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "qtui.h"
 
@@ -96,9 +96,9 @@ QtMultimediaNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent)
     : SettingsPage("Internal", "QtMultimediaNotification", parent)
 {
     ui.setupUi(this);
-    ui.enabled->setIcon(QIcon::fromTheme("media-playback-start"));
-    ui.play->setIcon(QIcon::fromTheme("media-playback-start"));
-    ui.open->setIcon(QIcon::fromTheme("document-open"));
+    ui.enabled->setIcon(icon::get("media-playback-start"));
+    ui.play->setIcon(icon::get("media-playback-start"));
+    ui.open->setIcon(icon::get("document-open"));
 
     _audioAvailable = (QMediaPlayer().availability() == QMultimedia::Available);
 
index 7b658b9..3ef3201 100644 (file)
@@ -30,6 +30,7 @@
 #include "buffermodel.h"
 #include "chatlinemodel.h"
 #include "contextmenuactionprovider.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "qtuimessageprocessor.h"
 #include "qtuisettings.h"
@@ -64,7 +65,7 @@ QtUi::QtUi()
 
     setupIconTheme();
 
-    QApplication::setWindowIcon(QIcon::fromTheme("quassel"));
+    QApplication::setWindowIcon(icon::get("quassel"));
 
     setContextMenuActionProvider(new ContextMenuActionProvider(this));
     setToolBarActionProvider(new ToolBarActionProvider(this));
index d049286..5e9ea6e 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QIcon>
+#include "settingsdlg.h"
+
 #include <QMessageBox>
 #include <QPushButton>
 
-#include "settingsdlg.h"
-
 #include "client.h"
+#include "icon.h"
 
 SettingsDlg::SettingsDlg(QWidget *parent)
     : QDialog(parent),
@@ -33,7 +33,7 @@ SettingsDlg::SettingsDlg(QWidget *parent)
     ui.setupUi(this);
     setModal(true);
     setAttribute(Qt::WA_DeleteOnClose, true);
-    setWindowIcon(QIcon::fromTheme("configure"));
+    setWindowIcon(icon::get("configure"));
 
     updateGeometry();
 
index 90fa3e1..fd4cb54 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QIcon>
+#include "settingspagedlg.h"
+
 #include <QMessageBox>
 #include <QPushButton>
 
-#include "settingspagedlg.h"
+#include "icon.h"
 
 SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent)
     : QDialog(parent)
@@ -36,7 +37,7 @@ SettingsPageDlg::SettingsPageDlg(SettingsPage *page, QWidget *parent)
 
     ui.pageTitle->setText(page->title());
     setWindowTitle(tr("Configure %1").arg(page->title()));
-    setWindowIcon(QIcon::fromTheme("configure"));
+    setWindowIcon(icon::get("configure"));
 
     // make the scrollarea behave sanely
     ui.settingsFrame->setWidgetResizable(true);
index 1abe146..c817b45 100644 (file)
 #include "aliasessettingspage.h"
 
 #include <QHeaderView>
-#include <QIcon>
 #include <QItemSelectionModel>
 
+#include "icon.h"
+
 AliasesSettingsPage::AliasesSettingsPage(QWidget *parent)
     : SettingsPage(tr("IRC"), tr("Aliases"), parent)
 {
     ui.setupUi(this);
-    ui.newAliasButton->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteAliasButton->setIcon(QIcon::fromTheme("edit-delete"));
+    ui.newAliasButton->setIcon(icon::get("list-add"));
+    ui.deleteAliasButton->setIcon(icon::get("edit-delete"));
 
     ui.aliasesView->setSelectionBehavior(QAbstractItemView::SelectRows);
     ui.aliasesView->setSelectionMode(QAbstractItemView::SingleSelection);
index 3079213..fff7b1e 100644 (file)
 
 #include "bufferviewsettingspage.h"
 
-#include <QIcon>
 #include <QMessageBox>
 
-#include "client.h"
-#include "network.h"
+#include "buffermodel.h"
 #include "bufferviewconfig.h"
 #include "bufferviewfilter.h"
-#include "buffermodel.h"
+#include "client.h"
 #include "clientbufferviewmanager.h"
+#include "icon.h"
+#include "network.h"
 #include "networkmodel.h"
 #include "util.h"
 
@@ -43,9 +43,9 @@ BufferViewSettingsPage::BufferViewSettingsPage(QWidget *parent)
     if (!Client::isCoreFeatureEnabled(Quassel::Feature::HideInactiveNetworks))
         ui.hideInactiveNetworks->hide();
 
-    ui.renameBufferView->setIcon(QIcon::fromTheme("edit-rename"));
-    ui.addBufferView->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteBufferView->setIcon(QIcon::fromTheme("edit-delete"));
+    ui.renameBufferView->setIcon(icon::get("edit-rename"));
+    ui.addBufferView->setIcon(icon::get("list-add"));
+    ui.deleteBufferView->setIcon(icon::get("edit-delete"));
 
     reset();
 
index 490a1a9..1690722 100644 (file)
@@ -20,9 +20,8 @@
 
 #include "chatmonitorsettingspage.h"
 
-#include <QIcon>
-
 #include "client.h"
+#include "icon.h"
 #include "networkmodel.h"
 #include "bufferviewconfig.h"
 #include "buffermodel.h"
@@ -37,8 +36,8 @@ ChatMonitorSettingsPage::ChatMonitorSettingsPage(QWidget *parent)
 {
     ui.setupUi(this);
 
-    ui.activateBuffer->setIcon(QIcon::fromTheme("go-next"));
-    ui.deactivateBuffer->setIcon(QIcon::fromTheme("go-previous"));
+    ui.activateBuffer->setIcon(icon::get("go-next"));
+    ui.deactivateBuffer->setIcon(icon::get("go-previous"));
 
     // setup available buffers config (for the bufferview on the left)
     _configAvailable = new BufferViewConfig(-667, this);
index c1d0391..870f78c 100644 (file)
 
 #include "coreaccountsettingspage.h"
 
-#include <QIcon>
-
 #include "client.h"
 #include "clientsettings.h"
 #include "coreaccountmodel.h"
+#include "icon.h"
 
 CoreAccountSettingsPage::CoreAccountSettingsPage(QWidget *parent)
     : SettingsPage(tr("Remote Cores"), QString(), parent),
@@ -34,9 +33,9 @@ CoreAccountSettingsPage::CoreAccountSettingsPage(QWidget *parent)
 {
     ui.setupUi(this);
     initAutoWidgets();
-    ui.addAccountButton->setIcon(QIcon::fromTheme("list-add"));
-    ui.editAccountButton->setIcon(QIcon::fromTheme("document-edit"));
-    ui.deleteAccountButton->setIcon(QIcon::fromTheme("edit-delete"));
+    ui.addAccountButton->setIcon(icon::get("list-add"));
+    ui.editAccountButton->setIcon(icon::get("document-edit"));
+    ui.deleteAccountButton->setIcon(icon::get("edit-delete"));
 
     _model = new CoreAccountModel(Client::coreAccountModel(), this);
     _filteredModel = new FilteredCoreAccountModel(_model, this);
index 8368953..70cc84f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "client.h"
 #include "corehighlightsettingspage.h"
+#include "icon.h"
 #include "qtui.h"
 
 CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent)
@@ -90,7 +91,7 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent)
     connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
 
     // Warning icon
-    ui.coreUnsupportedIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16));
+    ui.coreUnsupportedIcon->setPixmap(icon::get("dialog-warning").pixmap(16));
 
     // Set up client/monolithic remote highlights information
     if (Quassel::runMode() == Quassel::Monolithic) {
index 443bde1..4485b4f 100644 (file)
 
 #include "highlightsettingspage.h"
 
+#include <QHeaderView>
+#include <QMessageBox>
+
 #include "client.h"
+#include "icon.h"
 #include "qtui.h"
 #include "uisettings.h"
 
-#include <QHeaderView>
-#include <QMessageBox>
 
 HighlightSettingsPage::HighlightSettingsPage(QWidget *parent)
     : SettingsPage(tr("Interface"),
@@ -92,7 +94,7 @@ HighlightSettingsPage::HighlightSettingsPage(QWidget *parent)
 #endif
 
     // Information icon
-    ui.localHighlightsIcon->setPixmap(QIcon::fromTheme("dialog-information").pixmap(16));
+    ui.localHighlightsIcon->setPixmap(icon::get("dialog-information").pixmap(16));
 
     // Set up client/monolithic local highlights information
     if (Quassel::runMode() == Quassel::Monolithic) {
index ac10682..cf5ebc1 100644 (file)
 
 #include "identitiessettingspage.h"
 
-#include <QIcon>
 #include <QInputDialog>
 #include <QMessageBox>
 
 #include "client.h"
+#include "icon.h"
 #include "signalproxy.h"
 
 IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent)
@@ -32,9 +32,9 @@ IdentitiesSettingsPage::IdentitiesSettingsPage(QWidget *parent)
     _editSsl(false)
 {
     ui.setupUi(this);
-    ui.renameIdentity->setIcon(QIcon::fromTheme("edit-rename"));
-    ui.addIdentity->setIcon(QIcon::fromTheme("list-add-user"));
-    ui.deleteIdentity->setIcon(QIcon::fromTheme("list-remove-user"));
+    ui.renameIdentity->setIcon(icon::get("edit-rename"));
+    ui.addIdentity->setIcon(icon::get("list-add-user"));
+    ui.deleteIdentity->setIcon(icon::get("list-remove-user"));
 
     coreConnectionStateChanged(Client::isConnected()); // need a core connection!
     connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
@@ -417,7 +417,7 @@ SaveIdentitiesDlg::SaveIdentitiesDlg(const QList<CertIdentity *> &toCreate, cons
     : QDialog(parent)
 {
     ui.setupUi(this);
-    ui.abort->setIcon(QIcon::fromTheme("dialog-cancel"));
+    ui.abort->setIcon(icon::get("dialog-cancel"));
 
     numevents = toCreate.count() + toUpdate.count() + toRemove.count();
     rcvevents = 0;
index d31020a..684dc61 100644 (file)
@@ -23,7 +23,6 @@
 #include <QDragEnterEvent>
 #include <QDropEvent>
 #include <QFileDialog>
-#include <QIcon>
 #include <QMimeData>
 #include <QUrl>
 #include <QMessageBox>
 #endif
 
 #include "client.h"
+#include "icon.h"
 
 IdentityEditWidget::IdentityEditWidget(QWidget *parent)
     : QWidget(parent)
 {
     ui.setupUi(this);
 
-    ui.addNick->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteNick->setIcon(QIcon::fromTheme("edit-delete"));
-    ui.renameNick->setIcon(QIcon::fromTheme("edit-rename"));
-    ui.nickUp->setIcon(QIcon::fromTheme("go-up"));
-    ui.nickDown->setIcon(QIcon::fromTheme("go-down"));
+    ui.addNick->setIcon(icon::get("list-add"));
+    ui.deleteNick->setIcon(icon::get("edit-delete"));
+    ui.renameNick->setIcon(icon::get("edit-rename"));
+    ui.nickUp->setIcon(icon::get("go-up"));
+    ui.nickDown->setIcon(icon::get("go-down"));
 
     // We need to know whenever the state of input widgets changes...
     connect(ui.realName, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged()));
index f8cb952..dcf59a2 100644 (file)
@@ -21,7 +21,6 @@
 #include "ignorelistsettingspage.h"
 
 #include <QHeaderView>
-#include <QIcon>
 #include <QItemSelectionModel>
 #include <QModelIndex>
 #include <QPainter>
 #include <QEvent>
 #include <QDebug>
 
+#include "icon.h"
+
 IgnoreListSettingsPage::IgnoreListSettingsPage(QWidget *parent)
     : SettingsPage(tr("IRC"), tr("Ignore List"), parent)
 {
     ui.setupUi(this);
     _delegate = new IgnoreListDelegate(ui.ignoreListView);
-    ui.newIgnoreRuleButton->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteIgnoreRuleButton->setIcon(QIcon::fromTheme("edit-delete"));
-    ui.editIgnoreRuleButton->setIcon(QIcon::fromTheme("configure"));
+    ui.newIgnoreRuleButton->setIcon(icon::get("list-add"));
+    ui.deleteIgnoreRuleButton->setIcon(icon::get("edit-delete"));
+    ui.editIgnoreRuleButton->setIcon(icon::get("configure"));
 
     ui.ignoreListView->setSelectionBehavior(QAbstractItemView::SelectRows);
     ui.ignoreListView->setSelectionMode(QAbstractItemView::SingleSelection);
index bbbb6b8..e65302f 100644 (file)
@@ -29,7 +29,6 @@
 #include <QDebug>
 #include <QKeyEvent>
 #include <QHBoxLayout>
-#include <QIcon>
 #include <QMessageBox>
 #include <QToolButton>
 
@@ -40,6 +39,7 @@
 
 #include "action.h"
 #include "actioncollection.h"
+#include "icon.h"
 #include "keysequencewidget.h"
 
 KeySequenceButton::KeySequenceButton(KeySequenceWidget *d_, QWidget *parent)
@@ -172,7 +172,7 @@ KeySequenceWidget::KeySequenceWidget(QWidget *parent)
 
     _keyButton = new KeySequenceButton(this, this);
     _keyButton->setFocusPolicy(Qt::StrongFocus);
-    _keyButton->setIcon(QIcon::fromTheme("configure"));
+    _keyButton->setIcon(icon::get("configure"));
     _keyButton->setToolTip(tr("Click on the button, then enter the shortcut like you would in the program.\nExample for Ctrl+a: hold the Ctrl key and press a."));
     layout->addWidget(_keyButton);
 
@@ -180,9 +180,9 @@ KeySequenceWidget::KeySequenceWidget(QWidget *parent)
     layout->addWidget(_clearButton);
 
     if (qApp->isLeftToRight())
-        _clearButton->setIcon(QIcon::fromTheme("edit-clear-locationbar-rtl", QIcon::fromTheme("edit-clear")));
+        _clearButton->setIcon(icon::get("edit-clear-locationbar-rtl"));
     else
-        _clearButton->setIcon(QIcon::fromTheme("edit-clear-locationbar-ltr", QIcon::fromTheme("edit-clear")));
+        _clearButton->setIcon(icon::get("edit-clear-locationbar-ltr"));
 
     setLayout(layout);
 
index f0aeac1..d8309ad 100644 (file)
  ***************************************************************************/
 
 #include <QHeaderView>
-#include <QIcon>
 #include <QMessageBox>
 #include <QTextCodec>
 
 #include "networkssettingspage.h"
 
 #include "client.h"
+#include "icon.h"
 #include "identity.h"
 #include "network.h"
 #include "presetnetworks.h"
@@ -55,25 +55,25 @@ NetworksSettingsPage::NetworksSettingsPage(QWidget *parent)
 #endif
 
     // set up icons
-    ui.renameNetwork->setIcon(QIcon::fromTheme("edit-rename"));
-    ui.addNetwork->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteNetwork->setIcon(QIcon::fromTheme("edit-delete"));
-    ui.addServer->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteServer->setIcon(QIcon::fromTheme("edit-delete"));
-    ui.editServer->setIcon(QIcon::fromTheme("configure"));
-    ui.upServer->setIcon(QIcon::fromTheme("go-up"));
-    ui.downServer->setIcon(QIcon::fromTheme("go-down"));
-    ui.editIdentities->setIcon(QIcon::fromTheme("configure"));
+    ui.renameNetwork->setIcon(icon::get("edit-rename"));
+    ui.addNetwork->setIcon(icon::get("list-add"));
+    ui.deleteNetwork->setIcon(icon::get("edit-delete"));
+    ui.addServer->setIcon(icon::get("list-add"));
+    ui.deleteServer->setIcon(icon::get("edit-delete"));
+    ui.editServer->setIcon(icon::get("configure"));
+    ui.upServer->setIcon(icon::get("go-up"));
+    ui.downServer->setIcon(icon::get("go-down"));
+    ui.editIdentities->setIcon(icon::get("configure"));
 
     _ignoreWidgetChanges = false;
 
-    connectedIcon = QIcon::fromTheme("network-connect");
-    connectingIcon = QIcon::fromTheme("network-wired"); // FIXME network-connecting
-    disconnectedIcon = QIcon::fromTheme("network-disconnect");
+    connectedIcon = icon::get("network-connect");
+    connectingIcon = icon::get("network-wired"); // FIXME network-connecting
+    disconnectedIcon = icon::get("network-disconnect");
 
     // Status icons
-    infoIcon = QIcon::fromTheme("dialog-information");
-    warningIcon = QIcon::fromTheme("dialog-warning");
+    infoIcon = icon::get("dialog-information");
+    warningIcon = icon::get("dialog-warning");
 
     foreach(int mib, QTextCodec::availableMibs()) {
         QByteArray codec = QTextCodec::codecForMib(mib)->name();
@@ -599,7 +599,7 @@ void NetworksSettingsPage::displayNetwork(NetworkId id)
         foreach(Network::Server server, info.serverList) {
             QListWidgetItem *item = new QListWidgetItem(QString("%1:%2").arg(server.host).arg(server.port));
             if (server.useSsl)
-                item->setIcon(QIcon::fromTheme("document-encrypt"));
+                item->setIcon(icon::get("document-encrypt"));
             ui.serverList->addItem(item);
         }
         //setItemState(id);
@@ -1022,7 +1022,7 @@ IdentityId NetworksSettingsPage::defaultIdentity() const
 NetworkAddDlg::NetworkAddDlg(const QStringList &exist, QWidget *parent) : QDialog(parent), existing(exist)
 {
     ui.setupUi(this);
-    ui.useSSL->setIcon(QIcon::fromTheme("document-encrypt"));
+    ui.useSSL->setIcon(icon::get("document-encrypt"));
 
     // Whenever useSSL is toggled, update the port number if not changed from the default
     connect(ui.useSSL, SIGNAL(toggled(bool)), SLOT(updateSslPort(bool)));
@@ -1140,7 +1140,7 @@ void NetworkEditDlg::on_networkEdit_textChanged(const QString &text)
 ServerEditDlg::ServerEditDlg(const Network::Server &server, QWidget *parent) : QDialog(parent)
 {
     ui.setupUi(this);
-    ui.useSSL->setIcon(QIcon::fromTheme("document-encrypt"));
+    ui.useSSL->setIcon(icon::get("document-encrypt"));
     ui.host->setText(server.host);
     ui.host->setFocus();
     ui.port->setValue(server.port);
index 655f3fc..00aef3d 100644 (file)
@@ -20,8 +20,7 @@
 
 #include "simplenetworkeditor.h"
 
-#include <QIcon>
-
+#include "icon.h"
 #include "networkssettingspage.h"
 
 SimpleNetworkEditor::SimpleNetworkEditor(QWidget *parent)
@@ -29,11 +28,11 @@ SimpleNetworkEditor::SimpleNetworkEditor(QWidget *parent)
 {
     ui.setupUi(this);
 
-    ui.addServer->setIcon(QIcon::fromTheme("list-add"));
-    ui.deleteServer->setIcon(QIcon::fromTheme("edit-delete"));
-    ui.editServer->setIcon(QIcon::fromTheme("configure"));
-    ui.upServer->setIcon(QIcon::fromTheme("go-up"));
-    ui.downServer->setIcon(QIcon::fromTheme("go-down"));
+    ui.addServer->setIcon(icon::get("list-add"));
+    ui.deleteServer->setIcon(icon::get("edit-delete"));
+    ui.editServer->setIcon(icon::get("configure"));
+    ui.upServer->setIcon(icon::get("go-up"));
+    ui.downServer->setIcon(icon::get("go-down"));
 
     connect(ui.networkNameEdit, SIGNAL(textEdited(const QString &)), this, SIGNAL(widgetHasChanged()));
     connect(ui.channelList, SIGNAL(textChanged()), this, SIGNAL(widgetHasChanged()));
@@ -65,7 +64,7 @@ void SimpleNetworkEditor::displayNetworkInfo(const NetworkInfo &networkInfo)
     foreach(Network::Server server, _networkInfo.serverList) {
         QListWidgetItem *item = new QListWidgetItem(QString("%1:%2").arg(server.host).arg(server.port));
         if (server.useSsl)
-            item->setIcon(QIcon::fromTheme("document-encrypt"));
+            item->setIcon(icon::get("document-encrypt"));
         ui.serverList->addItem(item);
     }
 
index 21bcee6..07c6a9a 100644 (file)
 
 #include "snorenotificationbackend.h"
 
+#include <iostream>
+
 #include <QtGui>
 #include <QtGlobal>
 #include <QMetaObject>
 
+#include <libsnore/snore.h>
+#include <libsnore/notification/notification.h>
+
 #include "client.h"
+#include "icon.h"
 #include "networkmodel.h"
 #include "systraynotificationbackend.h"
 #include "qtui.h"
 
-#include <iostream>
-
-
-#include <libsnore/snore.h>
-#include <libsnore/notification/notification.h>
-
 
 SnoreNotificationBackend::SnoreNotificationBackend (QObject *parent)
-    : AbstractNotificationBackend(parent),
-      m_icon(QIcon::fromTheme("quassel", QIcon(":/icons/quassel.png")))
+    : AbstractNotificationBackend(parent)
+    , m_icon(icon::get("quassel"))
 {
 
     Snore::SnoreCore::instance().loadPlugins(
index 5932746..48c747e 100644 (file)
 
 #ifdef HAVE_DBUS
 
+#include "statusnotifieritem.h"
+
 #include <QApplication>
 #include <QDir>
 #include <QFile>
+#include <QIcon>
 #include <QMenu>
 #include <QMouseEvent>
 #include <QTextDocument>
 
+#include "icon.h"
 #include "qtui.h"
 #include "quassel.h"
-#include "statusnotifieritem.h"
 #include "statusnotifieritemdbus.h"
 
 constexpr int kProtocolVersion {0};
@@ -198,7 +201,7 @@ void StatusNotifierItem::refreshIcons()
         baseDir.removeRecursively();
         for (auto &&trayState : { State::Active, State::Passive, State::NeedsAttention }) {
             auto iconName = SystemTray::iconName(trayState);
-            QIcon icon = QIcon::fromTheme(iconName);
+            QIcon icon = icon::get(iconName);
             if (!icon.isNull()) {
                 for (auto &&size : icon.availableSizes()) {
                     auto pixDir = QString{"%1/%2x%3/status"}.arg(baseDir.absolutePath()).arg(size.width()).arg(size.height());
index c840550..7e38a6a 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QApplication>
-#include <QMenu>
-
 #include "systemtray.h"
 
-#include "action.h"
-#include "actioncollection.h"
-#include "client.h"
-#include "qtui.h"
+#include <QApplication>
+#include <QMenu>
 
 #ifdef HAVE_KDE4
 #  include <KMenu>
 #  include <KWindowSystem>
 #endif
 
+#include "action.h"
+#include "actioncollection.h"
+#include "client.h"
+#include "icon.h"
+#include "qtui.h"
+
 SystemTray::SystemTray(QWidget *parent)
     : QObject(parent),
     _associatedWidget(parent)
@@ -50,7 +51,7 @@ SystemTray::SystemTray(QWidget *parent)
 #ifdef HAVE_KDE4
     KMenu *kmenu;
     _trayMenu = kmenu = new KMenu();
-    kmenu->addTitle(QIcon::fromTheme(iconName(State::Active)), "Quassel IRC");
+    kmenu->addTitle(icon::get(iconName(State::Active)), "Quassel IRC");
 #else
     _trayMenu = new QMenu(associatedWidget());
 #endif
index 4af9109..b565180 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QIcon>
-
 #include "systrayanimationnotificationbackend.h"
 
 #include "clientsettings.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "qtui.h"
 #include "systemtray.h"
@@ -69,7 +68,7 @@ SettingsPage *SystrayAnimationNotificationBackend::createConfigWidget() const
 SystrayAnimationNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayAnimation", parent)
 {
     ui.setupUi(this);
-    ui.enableAlert->setIcon(QIcon::fromTheme("dialog-information"));
+    ui.enableAlert->setIcon(icon::get("dialog-information"));
 
     ui.attentionBehavior->setEnabled(ui.enableAlert->isChecked());
 
index a0f00d8..deb4927 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "systraynotificationbackend.h"
+
 #include <QApplication>
 #include <QCheckBox>
 #include <QGroupBox>
-#include <QIcon>
 #include <QHBoxLayout>
 
-#include "systraynotificationbackend.h"
-
 #include "client.h"
 #include "clientsettings.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "networkmodel.h"
 #include "qtui.h"
@@ -144,7 +144,7 @@ SettingsPage *SystrayNotificationBackend::createConfigWidget() const
 SystrayNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : SettingsPage("Internal", "SystrayNotification", parent)
 {
     _showBubbleBox = new QCheckBox(tr("Show a message in a popup"));
-    _showBubbleBox->setIcon(QIcon::fromTheme("dialog-information"));
+    _showBubbleBox->setIcon(icon::get("dialog-information"));
     connect(_showBubbleBox, SIGNAL(toggled(bool)), this, SLOT(widgetChanged()));
     QHBoxLayout *layout = new QHBoxLayout(this);
     layout->addWidget(_showBubbleBox);
index 9a292c2..ef9736f 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "taskbarnotificationbackend.h"
+
 #include <QApplication>
 #include <QCheckBox>
 #include <QHBoxLayout>
-#include <QIcon>
 #include <QSpinBox>
 
-#include "taskbarnotificationbackend.h"
-
 #include "clientsettings.h"
+#include "icon.h"
 #include "mainwin.h"
 #include "qtui.h"
 
@@ -84,7 +84,7 @@ TaskbarNotificationBackend::ConfigWidget::ConfigWidget(QWidget *parent) : Settin
 #else
     layout->addWidget(enabledBox = new QCheckBox(tr("Mark taskbar entry, timeout:"), this));
 #endif
-    enabledBox->setIcon(QIcon::fromTheme("flag-blue"));
+    enabledBox->setIcon(icon::get("flag-blue"));
     enabledBox->setEnabled(true);
 
     timeoutBox = new QSpinBox(this);
index 33c17f8..9e6435d 100644 (file)
@@ -20,9 +20,8 @@
 
 #include "topicwidget.h"
 
-#include <QIcon>
-
 #include "client.h"
+#include "icon.h"
 #include "networkmodel.h"
 #include "uisettings.h"
 #include "graphicalui.h"
@@ -32,7 +31,7 @@ TopicWidget::TopicWidget(QWidget *parent)
     : AbstractItemView(parent)
 {
     ui.setupUi(this);
-    ui.topicEditButton->setIcon(QIcon::fromTheme("edit-rename"));
+    ui.topicEditButton->setIcon(icon::get("edit-rename"));
     ui.topicLineEdit->setLineWrapEnabled(true);
     ui.topicLineEdit->installEventFilter(this);
 
index baa49fe..1a9dcf3 100644 (file)
@@ -18,6 +18,7 @@ set(SOURCES
     flatproxymodel.cpp
     fontselector.cpp
     graphicalui.cpp
+    icon.cpp
     multilineedit.cpp
     networkmodelcontroller.cpp
     nickview.cpp
index 2f2f8b3..1c8e0c7 100644 (file)
 
 #include "clearablelineedit.h"
 
-#include <QIcon>
 #include <QToolButton>
 #include <QStyle>
 
+#include "icon.h"
+
 ClearableLineEdit::ClearableLineEdit(QWidget *parent)
     : QLineEdit(parent)
 {
     clearButton = new QToolButton(this);
-    clearButton->setIcon(QIcon::fromTheme("edit-clear-locationbar-rtl", QIcon::fromTheme("edit-clear")));
+    clearButton->setIcon(icon::get("edit-clear-locationbar-rtl"));
     clearButton->setCursor(Qt::ArrowCursor);
     clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
     clearButton->hide();
index 8a0ca82..3bd7b3d 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QIcon>
+#include "contextmenuactionprovider.h"
+
 #include <QInputDialog>
 #include <QMenu>
 #include <QMessageBox>
 #include <QMap>
 
-#include "contextmenuactionprovider.h"
-
 #include "buffermodel.h"
 #include "buffersettings.h"
-#include "clientidentity.h"
-#include "network.h"
-#include "util.h"
 #include "client.h"
 #include "clientignorelistmanager.h"
+#include "icon.h"
+#include "network.h"
+#include "util.h"
 
 ContextMenuActionProvider::ContextMenuActionProvider(QObject *parent) : NetworkModelController(parent)
 {
-    registerAction(NetworkConnect, QIcon::fromTheme("network-connect"), tr("Connect"));
-    registerAction(NetworkDisconnect, QIcon::fromTheme("network-disconnect"), tr("Disconnect"));
+    registerAction(NetworkConnect, icon::get("network-connect"), tr("Connect"));
+    registerAction(NetworkDisconnect, icon::get("network-disconnect"), tr("Disconnect"));
 
-    registerAction(BufferJoin, QIcon::fromTheme("irc-join-channel"), tr("Join"));
-    registerAction(BufferPart, QIcon::fromTheme("irc-close-channel"), tr("Part"));
+    registerAction(BufferJoin, icon::get("irc-join-channel"), tr("Join"));
+    registerAction(BufferPart, icon::get("irc-close-channel"), tr("Part"));
     registerAction(BufferRemove, tr("Delete Chat(s)..."));
     registerAction(BufferSwitchTo, tr("Go to Chat"));
 
@@ -55,7 +54,7 @@ ContextMenuActionProvider::ContextMenuActionProvider(QObject *parent) : NetworkM
     registerAction(HideApplyToAll, tr("Set as Default..."));
     registerAction(HideUseDefaults, tr("Use Defaults..."));
 
-    registerAction(JoinChannel, QIcon::fromTheme("irc-join-channel"), tr("Join Channel..."));
+    registerAction(JoinChannel, icon::get("irc-join-channel"), tr("Join Channel..."));
 
     registerAction(NickQuery, tr("Start Query"));
     registerAction(NickSwitchTo, tr("Show Query"));
@@ -77,15 +76,15 @@ ContextMenuActionProvider::ContextMenuActionProvider(QObject *parent) : NetworkM
     registerAction(NickIgnoreToggleEnabled3, "Enable", true);
     registerAction(NickIgnoreToggleEnabled4, "Enable", true);
 
-    registerAction(NickOp, QIcon::fromTheme("irc-operator"), tr("Give Operator Status"));
-    registerAction(NickDeop, QIcon::fromTheme("irc-remove-operator"), tr("Take Operator Status"));
-    registerAction(NickHalfop, QIcon::fromTheme("irc-voice"), tr("Give Half-Operator Status"));
-    registerAction(NickDehalfop, QIcon::fromTheme("irc-unvoice"), tr("Take Half-Operator Status"));
-    registerAction(NickVoice, QIcon::fromTheme("irc-voice"), tr("Give Voice"));
-    registerAction(NickDevoice, QIcon::fromTheme("irc-unvoice"), tr("Take Voice"));
-    registerAction(NickKick, QIcon::fromTheme("im-kick-user"), tr("Kick From Channel"));
-    registerAction(NickBan, QIcon::fromTheme("im-ban-user"), tr("Ban From Channel"));
-    registerAction(NickKickBan, QIcon::fromTheme("im-ban-kick-user"), tr("Kick && Ban"));
+    registerAction(NickOp, icon::get("irc-operator"), tr("Give Operator Status"));
+    registerAction(NickDeop, icon::get("irc-remove-operator"), tr("Take Operator Status"));
+    registerAction(NickHalfop, icon::get("irc-voice"), tr("Give Half-Operator Status"));
+    registerAction(NickDehalfop, icon::get("irc-unvoice"), tr("Take Half-Operator Status"));
+    registerAction(NickVoice, icon::get("irc-voice"), tr("Give Voice"));
+    registerAction(NickDevoice, icon::get("irc-unvoice"), tr("Take Voice"));
+    registerAction(NickKick, icon::get("im-kick-user"), tr("Kick From Channel"));
+    registerAction(NickBan, icon::get("im-ban-user"), tr("Ban From Channel"));
+    registerAction(NickKickBan, icon::get("im-ban-kick-user"), tr("Kick && Ban"));
 
     registerAction(HideBufferTemporarily, tr("Hide Chat(s) Temporarily"));
     registerAction(HideBufferPermanently, tr("Hide Chat(s) Permanently"));
diff --git a/src/uisupport/icon.cpp b/src/uisupport/icon.cpp
new file mode 100644 (file)
index 0000000..9a6a528
--- /dev/null
@@ -0,0 +1,87 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+ ***************************************************************************/
+
+#include "icon.h"
+
+#include <set>
+
+#include <QDebug>
+
+namespace icon {
+
+namespace {
+
+void printWarning(const QString &iconName, const QString &extra = {})
+{
+    static std::set<QString> warnedAbout;
+    if (warnedAbout.insert(iconName).second) {
+        qWarning() << "Missing icon:" << iconName << qPrintable(extra);
+    }
+}
+
+}
+
+
+QIcon get(const QString &iconName, const QString &fallbackPath)
+{
+    return get(std::vector<QString>{iconName}, fallbackPath);
+}
+
+
+QIcon get(const std::vector<QString> &iconNames, const QString &fallbackPath)
+{
+    for (auto &&iconName : iconNames) {
+        // Exact match
+        if (QIcon::hasThemeIcon(iconName)) {
+            return QIcon::fromTheme(iconName);
+        }
+    }
+
+    for (auto &&iconName : iconNames) {
+        // Try to get something from the theme anyway (i.e. a more generic fallback)
+        QIcon fallback = QIcon::fromTheme(iconName);
+        if (!fallback.availableSizes().isEmpty()) {
+            printWarning(iconName, QString{"(using fallback: \"%1\")"}.arg(fallback.name()));
+            return fallback;
+        }
+    }
+
+    // Build error string
+    QStringList requested;
+    for (auto &&iconName : iconNames) {
+        requested << iconName;
+    }
+    QString missing = "{" + requested.join(", ") + "}";
+
+    // Nothing from the theme, so try to load from path if given
+    if (!fallbackPath.isEmpty()) {
+        QIcon fallback{fallbackPath};
+        if (!fallback.availableSizes().isEmpty()) {
+            printWarning(missing, QString{"(using fallback: \"%1\")"}.arg(fallbackPath));
+            return fallback;
+        }
+    }
+
+    // Meh.
+    printWarning(missing);
+    return {};
+}
+
+}
diff --git a/src/uisupport/icon.h b/src/uisupport/icon.h
new file mode 100644 (file)
index 0000000..18ec665
--- /dev/null
@@ -0,0 +1,58 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
+ ***************************************************************************/
+
+#pragma once
+
+#include <vector>
+
+#include <QIcon>
+#include <QString>
+
+namespace icon {
+
+/**
+ * Gets an icon from the current icon theme.
+ *
+ * If the theme does not provide the icon, tries to load the icon from the
+ * fallback path, if given.
+ *
+ * If no icon can be found, a warning is displayed and a null icon returned.
+ *
+ * @param iconName     Icon name
+ * @param fallbackPath Full path to a fallback icon
+ * @returns The requested icon, if available
+ */
+QIcon get(const QString &iconName, const QString &fallbackPath = {});
+
+/**
+ * Gets an icon from the current icon theme.
+ *
+ * If the theme does not provide any of the given icon names, tries to load the
+ * icon from the fallback path, if given.
+ *
+ * If no icon can be found, a warning is displayed and a null icon returned.
+ *
+ * @param iconNames    List of icon names (first match wins)
+ * @param fallbackPath Full path to a fallback icon
+ * @returns The requested icon, if available
+ */
+QIcon get(const std::vector<QString> &iconNames, const QString &fallbackPath = {});
+
+}
index 10807d9..6a96ba6 100644 (file)
@@ -18,6 +18,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
+#include "networkmodelcontroller.h"
+
 #include <QComboBox>
 #include <QDialogButtonBox>
 #include <QGridLayout>
 #include <QMessageBox>
 #include <QPushButton>
 
-#include "networkmodelcontroller.h"
-
 #include "buffermodel.h"
 #include "buffersettings.h"
+#include "client.h"
 #include "clientidentity.h"
+#include "clientignorelistmanager.h"
+#include "icon.h"
 #include "network.h"
 #include "util.h"
-#include "clientignorelistmanager.h"
-#include "client.h"
 
 NetworkModelController::NetworkModelController(QObject *parent)
     : QObject(parent),
@@ -549,7 +550,7 @@ void NetworkModelController::handleNickAction(ActionType type, QAction *action)
 
 NetworkModelController::JoinDlg::JoinDlg(const QModelIndex &index, QWidget *parent) : QDialog(parent)
 {
-    setWindowIcon(QIcon::fromTheme("irc-join-channel"));
+    setWindowIcon(icon::get("irc-join-channel"));
     setWindowTitle(tr("Join Channel"));
 
     QGridLayout *layout = new QGridLayout(this);
index 7456509..0ae1078 100644 (file)
  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
-#include <QIcon>
+#include "toolbaractionprovider.h"
+
 #include <QMenu>
 #include <QToolBar>
 
-#include "toolbaractionprovider.h"
+#include "icon.h"
 
 ToolBarActionProvider::ToolBarActionProvider(QObject *parent)
     : NetworkModelController(parent)
 {
-    registerAction(NetworkConnectAllWithDropdown, QIcon::fromTheme("network-connect"), tr("Connect"))->setToolTip(tr("Connect to IRC"));
-    registerAction(NetworkDisconnectAllWithDropdown, QIcon::fromTheme("network-disconnect"), tr("Disconnect"))->setToolTip(tr("Disconnect from IRC"));
+    registerAction(NetworkConnectAllWithDropdown, icon::get("network-connect"), tr("Connect"))->setToolTip(tr("Connect to IRC"));
+    registerAction(NetworkDisconnectAllWithDropdown, icon::get("network-disconnect"), tr("Disconnect"))->setToolTip(tr("Disconnect from IRC"));
     registerAction(NetworkConnectAll, tr("Connect to all"));
     registerAction(NetworkDisconnectAll, tr("Disconnect from all"));
 
-    registerAction(BufferPart, QIcon::fromTheme("irc-close-channel"), tr("Part"))->setToolTip(tr("Leave currently selected channel"));
-    registerAction(JoinChannel, QIcon::fromTheme("irc-join-channel"), tr("Join"))->setToolTip(tr("Join a channel"));
+    registerAction(BufferPart, icon::get("irc-close-channel"), tr("Part"))->setToolTip(tr("Leave currently selected channel"));
+    registerAction(JoinChannel, icon::get("irc-join-channel"), tr("Join"))->setToolTip(tr("Join a channel"));
 
-    registerAction(NickQuery, QIcon::fromTheme("mail-message-new"), tr("Query"))->setToolTip(tr("Start a private conversation")); // fix icon
-    registerAction(NickWhois, QIcon::fromTheme("im-user"), tr("Whois"))->setToolTip(tr("Request user information")); // fix icon
+    registerAction(NickQuery, icon::get("mail-message-new"), tr("Query"))->setToolTip(tr("Start a private conversation")); // fix icon
+    registerAction(NickWhois, icon::get("im-user"), tr("Whois"))->setToolTip(tr("Request user information")); // fix icon
 
-    registerAction(NickOp, QIcon::fromTheme("irc-operator"), tr("Op"))->setToolTip(tr("Give operator privileges to user"));
-    registerAction(NickDeop, QIcon::fromTheme("irc-remove-operator"), tr("Deop"))->setToolTip(tr("Take operator privileges from user"));
-    registerAction(NickVoice, QIcon::fromTheme("irc-voice"), tr("Voice"))->setToolTip(tr("Give voice to user"));
-    registerAction(NickDevoice, QIcon::fromTheme("irc-unvoice"), tr("Devoice"))->setToolTip(tr("Take voice from user"));
-    registerAction(NickKick, QIcon::fromTheme("im-kick-user"), tr("Kick"))->setToolTip(tr("Remove user from channel"));
-    registerAction(NickBan, QIcon::fromTheme("im-ban-user"), tr("Ban"))->setToolTip(tr("Ban user from channel"));
-    registerAction(NickKickBan, QIcon::fromTheme("im-ban-kick-user"), tr("Kick/Ban"))->setToolTip(tr("Remove and ban user from channel"));
+    registerAction(NickOp, icon::get("irc-operator"), tr("Op"))->setToolTip(tr("Give operator privileges to user"));
+    registerAction(NickDeop, icon::get("irc-remove-operator"), tr("Deop"))->setToolTip(tr("Take operator privileges from user"));
+    registerAction(NickVoice, icon::get("irc-voice"), tr("Voice"))->setToolTip(tr("Give voice to user"));
+    registerAction(NickDevoice, icon::get("irc-unvoice"), tr("Devoice"))->setToolTip(tr("Take voice from user"));
+    registerAction(NickKick, icon::get("im-kick-user"), tr("Kick"))->setToolTip(tr("Remove user from channel"));
+    registerAction(NickBan, icon::get("im-ban-user"), tr("Ban"))->setToolTip(tr("Ban user from channel"));
+    registerAction(NickKickBan, icon::get("im-ban-kick-user"), tr("Kick/Ban"))->setToolTip(tr("Remove and ban user from channel"));
 
     _networksConnectMenu = new QMenu();
     _networksConnectMenu->setSeparatorsCollapsible(false);
index d1c78cd..879fc35 100644 (file)
@@ -23,9 +23,9 @@
 
 #include <QApplication>
 #include <QColor>
-#include <QIcon>
 
 #include "buffersettings.h"
+#include "icon.h"
 #include "qssparser.h"
 #include "quassel.h"
 #include "uistyle.h"
@@ -62,16 +62,16 @@ QColor extendedMircColor(int number)
 }
 
 UiStyle::UiStyle(QObject *parent)
-    : QObject(parent),
-    _channelJoinedIcon(QIcon::fromTheme("irc-channel-active", QIcon(":/icons/irc-channel-active.png"))),
-    _channelPartedIcon(QIcon::fromTheme("irc-channel-inactive", QIcon(":/icons/irc-channel-inactive.png"))),
-    _userOfflineIcon(QIcon::fromTheme("im-user-offline", QIcon::fromTheme("user-offline", QIcon(":/icons/im-user-offline.png")))),
-    _userOnlineIcon(QIcon::fromTheme("im-user", QIcon::fromTheme("user-available", QIcon(":/icons/im-user.png")))), // im-user-* are non-standard oxygen extensions
-    _userAwayIcon(QIcon::fromTheme("im-user-away", QIcon::fromTheme("user-away", QIcon(":/icons/im-user-away.png")))),
-    _categoryOpIcon(QIcon::fromTheme("irc-operator")),
-    _categoryVoiceIcon(QIcon::fromTheme("irc-voice")),
-    _opIconLimit(UserCategoryItem::categoryFromModes("o")),
-    _voiceIconLimit(UserCategoryItem::categoryFromModes("v"))
+    : QObject(parent)
+    , _channelJoinedIcon{icon::get("irc-channel-active")}
+    , _channelPartedIcon{icon::get("irc-channel-inactive")}
+    , _userOfflineIcon{icon::get({"im-user-offline", "user-offline"})}
+    , _userOnlineIcon{icon::get({"im-user-online", "im-user", "user-available"})}
+    , _userAwayIcon{icon::get({"im-user-away", "user-away"})}
+    , _categoryOpIcon{icon::get("irc-operator")}
+    , _categoryVoiceIcon{icon::get("irc-voice")}
+    , _opIconLimit{UserCategoryItem::categoryFromModes("o")}
+    , _voiceIconLimit{UserCategoryItem::categoryFromModes("v")}
 {
     static bool registered = []() {
         qRegisterMetaType<FormatList>();