From faf1b2fbdfd7e25cf177daa993b141431c18270c Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Fri, 12 Dec 2014 21:47:22 +0000 Subject: [PATCH] #5848: Use theme-provided icons in Qt client (patch by equeim + small additions) --- qt/about.cc | 4 +++- qt/app.cc | 13 ++++++++----- qt/mainwin.cc | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/qt/about.cc b/qt/about.cc index e4c56b5d0..9650e36d8 100644 --- a/qt/about.cc +++ b/qt/about.cc @@ -7,8 +7,10 @@ * $Id$ */ +#include #include #include +#include #include #include #include @@ -34,7 +36,7 @@ AboutDialog :: AboutDialog (QWidget * parent): QVBoxLayout * v = new QVBoxLayout (this); l = new QLabel; - l->setPixmap (QPixmap (QString::fromUtf8 (":/icons/transmission-48.png"))); + l->setPixmap (QApplication::windowIcon ().pixmap (48)); l->setAlignment (Qt::AlignCenter); v->addWidget (l); diff --git a/qt/app.cc b/qt/app.cc index c301cefd7..2ade621e2 100644 --- a/qt/app.cc +++ b/qt/app.cc @@ -106,11 +106,14 @@ MyApp :: MyApp (int& argc, char ** argv): Formatter::initUnits (); // set the default icon - QIcon icon; - QList sizes; - sizes << 16 << 22 << 24 << 32 << 48 << 64 << 72 << 96 << 128 << 192 << 256; - foreach (int size, sizes) - icon.addPixmap (QPixmap (QString::fromUtf8 (":/icons/transmission-%1.png").arg (size))); + QIcon icon = QIcon::fromTheme ("transmission"); + if (icon.isNull ()) + { + QList sizes; + sizes << 16 << 22 << 24 << 32 << 48 << 64 << 72 << 96 << 128 << 192 << 256; + foreach (int size, sizes) + icon.addPixmap (QPixmap (QString::fromUtf8 (":/icons/transmission-%1.png").arg (size))); + } setWindowIcon (icon); // parse the command-line arguments diff --git a/qt/mainwin.cc b/qt/mainwin.cc index 6ca305840..5dc619dee 100644 --- a/qt/mainwin.cc +++ b/qt/mainwin.cc @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -233,7 +234,7 @@ TrMainWindow :: TrMainWindow (Session& session, Prefs& prefs, TorrentModel& mode menu->addSeparator (); menu->addAction (ui.action_Quit); myTrayIcon.setContextMenu (menu); - myTrayIcon.setIcon (QApplication::windowIcon ()); + myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", QApplication::windowIcon ())); connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (int))); connect (ui.action_ShowMainWindow, SIGNAL (triggered (bool)), this, SLOT (toggleWindows (bool))); -- 2.40.0