From 83ff66e0b120bdd35945432aee63b666237d4e6c Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 1 Jan 2011 13:05:28 +0000 Subject: [PATCH] Use of system icon theme can now be disabled --- src/deletionconfirmationdlg.h | 6 +- src/executionlog.cpp | 6 +- src/iconprovider.cpp | 89 ++++++++++++++++++++++++ src/iconprovider.h | 60 ++++++++++++++++ src/mainwindow.cpp | 53 ++++++++------ src/misc.h | 27 ------- src/preferences/advancedsettings.h | 20 ++++++ src/preferences/options_imp.cpp | 17 ++--- src/preferences/preferences.h | 10 +++ src/properties/peerlistwidget.cpp | 7 +- src/properties/propertieswidget.cpp | 11 +-- src/properties/proptabbar.cpp | 12 ++-- src/properties/trackerlist.cpp | 9 +-- src/properties/trackersadditiondlg.h | 3 +- src/rss/automatedrssdownloader.cpp | 16 ++--- src/rss/cookiesdlg.cpp | 6 +- src/rss/feedlistwidget.cpp | 4 +- src/searchengine/engineselectdlg.cpp | 3 +- src/searchengine/searchengine.cpp | 21 +++--- src/src.pro | 6 +- src/torrentadditiondlg.cpp | 8 +-- src/torrentcreator/torrentcreatordlg.cpp | 9 +-- src/torrentfilesmodel.h | 6 +- src/torrentimportdlg.cpp | 6 +- src/transferlistfilterswidget.h | 23 +++--- src/transferlistwidget.cpp | 33 ++++----- src/webui/httpconnection.cpp | 9 ++- 27 files changed, 329 insertions(+), 151 deletions(-) create mode 100644 src/iconprovider.cpp create mode 100644 src/iconprovider.h diff --git a/src/deletionconfirmationdlg.h b/src/deletionconfirmationdlg.h index 140ef6f38..186ebc0fc 100644 --- a/src/deletionconfirmationdlg.h +++ b/src/deletionconfirmationdlg.h @@ -34,7 +34,7 @@ #include #include "ui_confirmdeletiondlg.h" #include "preferences.h" -#include "misc.h" +#include "iconprovider.h" class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { Q_OBJECT @@ -43,9 +43,9 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { DeletionConfirmationDlg(QWidget *parent=0): QDialog(parent) { setupUi(this); // Icons - lbl_warn->setPixmap(misc::getIcon("dialog-warning").pixmap(lbl_warn->height())); + lbl_warn->setPixmap(IconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height())); lbl_warn->setFixedWidth(lbl_warn->height()); - rememberBtn->setIcon(misc::getIcon("object-locked")); + rememberBtn->setIcon(IconProvider::instance()->getIcon("object-locked")); move(misc::screenCenter(this)); checkPermDelete->setChecked(Preferences().deleteTorrentFilesAsDefault()); diff --git a/src/executionlog.cpp b/src/executionlog.cpp index 8430133a6..c175c44dc 100644 --- a/src/executionlog.cpp +++ b/src/executionlog.cpp @@ -1,15 +1,15 @@ #include "executionlog.h" #include "ui_executionlog.h" #include "qbtsession.h" -#include "misc.h" +#include "iconprovider.h" ExecutionLog::ExecutionLog(QWidget *parent) : QWidget(parent), ui(new Ui::ExecutionLog) { ui->setupUi(this); - ui->tabConsole->setTabIcon(0, misc::getIcon("view-calendar-journal")); - ui->tabConsole->setTabIcon(1, misc::getIcon("view-filter")); + ui->tabConsole->setTabIcon(0, IconProvider::instance()->getIcon("view-calendar-journal")); + ui->tabConsole->setTabIcon(1, IconProvider::instance()->getIcon("view-filter")); ui->textConsole->setHtml(QBtSession::instance()->getConsoleMessages().join("
")); connect(QBtSession::instance(), SIGNAL(newConsoleMessage(QString)), SLOT(addLogMessage(QString))); ui->textBannedPeers->setHtml(QBtSession::instance()->getPeerBanMessages().join("
")); diff --git a/src/iconprovider.cpp b/src/iconprovider.cpp new file mode 100644 index 000000000..cd068ea39 --- /dev/null +++ b/src/iconprovider.cpp @@ -0,0 +1,89 @@ +/* + * Bittorrent Client using Qt4 and libtorrent. + * Copyright (C) 2011 Christophe Dumez + * + * 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) any later version. + * + * 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. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + * + * Contact : chris@qbittorrent.org + */ + +#include "iconprovider.h" +#include "preferences.h" + +IconProvider* IconProvider::m_instance = 0; + +IconProvider::IconProvider() +{ +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + m_useSystemTheme = Preferences().useSystemIconTheme(); +#endif +} + +IconProvider * IconProvider::instance() +{ + if(!m_instance) + m_instance = new IconProvider; + return m_instance; +} + +void IconProvider::drop() +{ + if(m_instance) { + delete m_instance; + m_instance = 0; + } +} + +QIcon IconProvider::getIcon(const QString &iconId) +{ +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + if(m_useSystemTheme) + return QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png")); +#endif + return QIcon(":/Icons/oxygen/"+iconId+".png"); +} + +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) +void IconProvider::useSystemIconTheme(bool enable) +{ + m_useSystemTheme = enable; +} +#endif + +QString IconProvider::getIconPath(const QString &iconId) +{ +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + if(m_useSystemTheme) { + QString path = QDir::temp().absoluteFilePath(iconId+".png"); + if(!QFile::exists(path)) { + const QIcon icon = QIcon::fromTheme(iconId); + if(icon.isNull()) return ":/Icons/oxygen/"+iconId+".png"; + QPixmap px = icon.pixmap(32); + px.save(path); + } + return path; + } +#endif + return ":/Icons/oxygen/"+iconId+".png"; +} diff --git a/src/iconprovider.h b/src/iconprovider.h new file mode 100644 index 000000000..c897b6eb8 --- /dev/null +++ b/src/iconprovider.h @@ -0,0 +1,60 @@ +/* + * Bittorrent Client using Qt4 and libtorrent. + * Copyright (C) 2011 Christophe Dumez + * + * 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) any later version. + * + * 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. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + * + * Contact : chris@qbittorrent.org + */ + +#ifndef ICONPROVIDER_H +#define ICONPROVIDER_H + +#include +#include + +class IconProvider +{ + Q_DISABLE_COPY(IconProvider); + +private: + explicit IconProvider(); + static IconProvider* m_instance; + +public: + static IconProvider* instance(); + static void drop(); + QIcon getIcon(const QString& iconId); + QString getIconPath(const QString &iconId); + +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) +public: + void useSystemIconTheme(bool enable); + +private: + bool m_useSystemTheme; +#endif +}; + +#endif // ICONPROVIDER_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f94b0607a..0ecffa99f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -70,6 +70,7 @@ #include "rsssettings.h" #include "torrentmodel.h" #include "executionlog.h" +#include "iconprovider.h" #ifdef Q_WS_MAC #include "qmacapplication.h" void qt_mac_set_dock_menu(QMenu *menu); @@ -102,29 +103,29 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo connect(static_cast(qApp), SIGNAL(sessionIsShuttingDown()), this, SLOT(deleteBTSession())); // Setting icons this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))); - actionOpen->setIcon(misc::getIcon("list-add")); - actionDownload_from_URL->setIcon(misc::getIcon("insert-link")); + actionOpen->setIcon(IconProvider::instance()->getIcon("list-add")); + actionDownload_from_URL->setIcon(IconProvider::instance()->getIcon("insert-link")); actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/download.png"))); actionSet_global_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); actionSet_global_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/download.png"))); - actionCreate_torrent->setIcon(misc::getIcon("document-edit")); - actionAbout->setIcon(misc::getIcon("help-about")); - actionBugReport->setIcon(misc::getIcon("tools-report-bug")); - actionDecreasePriority->setIcon(misc::getIcon("go-down")); - actionDelete->setIcon(misc::getIcon("list-remove")); - actionDocumentation->setIcon(misc::getIcon("help-contents")); - actionDonate_money->setIcon(misc::getIcon("wallet-open")); - actionExit->setIcon(misc::getIcon("application-exit")); - actionIncreasePriority->setIcon(misc::getIcon("go-up")); - actionLock_qBittorrent->setIcon(misc::getIcon("object-locked")); - actionOptions->setIcon(misc::getIcon("preferences-system")); - actionPause->setIcon(misc::getIcon("media-playback-pause")); - actionPause_All->setIcon(misc::getIcon("media-playback-pause")); - actionStart->setIcon(misc::getIcon("media-playback-start")); - actionStart_All->setIcon(misc::getIcon("media-playback-start")); - action_Import_Torrent->setIcon(misc::getIcon("document-import")); - menuAuto_Shutdown_on_downloads_completion->setIcon(misc::getIcon("application-exit")); + actionCreate_torrent->setIcon(IconProvider::instance()->getIcon("document-edit")); + actionAbout->setIcon(IconProvider::instance()->getIcon("help-about")); + actionBugReport->setIcon(IconProvider::instance()->getIcon("tools-report-bug")); + actionDecreasePriority->setIcon(IconProvider::instance()->getIcon("go-down")); + actionDelete->setIcon(IconProvider::instance()->getIcon("list-remove")); + actionDocumentation->setIcon(IconProvider::instance()->getIcon("help-contents")); + actionDonate_money->setIcon(IconProvider::instance()->getIcon("wallet-open")); + actionExit->setIcon(IconProvider::instance()->getIcon("application-exit")); + actionIncreasePriority->setIcon(IconProvider::instance()->getIcon("go-up")); + actionLock_qBittorrent->setIcon(IconProvider::instance()->getIcon("object-locked")); + actionOptions->setIcon(IconProvider::instance()->getIcon("preferences-system")); + actionPause->setIcon(IconProvider::instance()->getIcon("media-playback-pause")); + actionPause_All->setIcon(IconProvider::instance()->getIcon("media-playback-pause")); + actionStart->setIcon(IconProvider::instance()->getIcon("media-playback-start")); + actionStart_All->setIcon(IconProvider::instance()->getIcon("media-playback-start")); + action_Import_Torrent->setIcon(IconProvider::instance()->getIcon("document-import")); + menuAuto_Shutdown_on_downloads_completion->setIcon(IconProvider::instance()->getIcon("application-exit")); QMenu *startAllMenu = new QMenu(this); startAllMenu->addAction(actionStart_All); @@ -168,7 +169,7 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo vSplitter->addWidget(hSplitter); vSplitter->setCollapsible(0, true); vSplitter->setCollapsible(1, false); - tabs->addTab(vSplitter, misc::getIcon("folder-remote"), tr("Transfers")); + tabs->addTab(vSplitter, IconProvider::instance()->getIcon("folder-remote"), tr("Transfers")); vboxLayout->addWidget(tabs); // Name filter @@ -355,6 +356,7 @@ MainWindow::~MainWindow() { delete switchSearchShortcut2; delete switchTransferShortcut; delete switchRSSShortcut; + IconProvider::drop(); // Delete QBtSession::instance() object qDebug("Deleting QBtSession::instance()"); QBtSession::drop(); @@ -397,7 +399,7 @@ void MainWindow::displayRSSTab(bool enable) { if(!rssWidget) { rssWidget = new RSSImp(tabs); int index_tab = tabs->addTab(rssWidget, tr("RSS")); - tabs->setTabIcon(index_tab, misc::getIcon("application-rss+xml")); + tabs->setTabIcon(index_tab, IconProvider::instance()->getIcon("application-rss+xml")); } } else { if(rssWidget) { @@ -411,7 +413,7 @@ void MainWindow::displaySearchTab(bool enable) { // RSS tab if(!searchEngine) { searchEngine = new SearchEngine(this); - tabs->insertTab(1, searchEngine, misc::getIcon("edit-find"), tr("Search")); + tabs->insertTab(1, searchEngine, IconProvider::instance()->getIcon("edit-find"), tr("Search")); } } else { if(searchEngine) { @@ -1004,6 +1006,11 @@ void MainWindow::loadPreferences(bool configure_session) { // Torrent properties properties->reloadPreferences(); + // Icon provider +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + IconProvider::instance()->useSystemIconTheme(pref.useSystemIconTheme()); +#endif + if(configure_session) QBtSession::instance()->configureSession(); @@ -1274,7 +1281,7 @@ void MainWindow::on_actionExecution_Logs_triggered(bool checked) Q_ASSERT(!m_executionLog); m_executionLog = new ExecutionLog(tabs); int index_tab = tabs->addTab(m_executionLog, tr("Execution Log")); - tabs->setTabIcon(index_tab, misc::getIcon("view-calendar-journal")); + tabs->setTabIcon(index_tab, IconProvider::instance()->getIcon("view-calendar-journal")); } else { if(m_executionLog) delete m_executionLog; diff --git a/src/misc.h b/src/misc.h index 00b5aff88..5d3072dd2 100644 --- a/src/misc.h +++ b/src/misc.h @@ -84,33 +84,6 @@ public: return libtorrent::sha1_hash(qPrintable(hash)); } -#ifndef DISABLE_GUI - static inline QIcon getIcon(const QString& iconId) { -#if (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) - const QIcon icon = QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png")); -#else - const QIcon icon(":/Icons/oxygen/"+iconId+".png"); -#endif - Q_ASSERT(!icon.isNull()); - return icon; - } -#endif - - static QString getIconPath(const QString &iconId) { -#if !defined(DISABLE_GUI) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) - QString path = QDir::temp().absoluteFilePath(iconId+".png"); - if(!QFile::exists(path)) { - const QIcon icon = QIcon::fromTheme(iconId); - if(icon.isNull()) return ":/Icons/oxygen/"+iconId+".png"; - QPixmap px = icon.pixmap(32); - px.save(path); - } - return path; -#else - return ":/Icons/oxygen/"+iconId+".png"; -#endif - } - static void chmod644(const QDir& folder); static inline QString removeLastPathPart(QString path) { diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index 362fdc61c..0620dc0d5 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -14,6 +14,9 @@ enum AdvSettingsCols {PROPERTY, VALUE}; enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, #if defined(Q_WS_WIN) || defined(Q_WS_MAC) UPDATE_CHECK, + #endif + #if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + USE_ICON_THEME, #endif ROW_COUNT }; @@ -27,6 +30,9 @@ private: #if defined(Q_WS_WIN) || defined(Q_WS_MAC) QCheckBox *cb_update_check; #endif +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + QCheckBox *cb_use_icon_theme; +#endif public: AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { @@ -63,6 +69,9 @@ public: delete cb_tracker_status; #if defined(Q_WS_WIN) || defined(Q_WS_MAC) delete cb_update_check; +#endif +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + delete cb_use_icon_theme; #endif } @@ -105,6 +114,10 @@ public slots: pref.setTrackerPort(spin_tracker_port->value()); #if defined(Q_WS_WIN) || defined(Q_WS_MAC) pref.setUpdateCheckEnabled(cb_update_check->isChecked()); +#endif + // Icon theme +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + pref.useSystemIconTheme(cb_use_icon_theme->isChecked()); #endif } @@ -234,6 +247,13 @@ protected slots: connect(cb_update_check, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); cb_update_check->setChecked(pref.isUpdateCheckEnabled()); setCellWidget(UPDATE_CHECK, VALUE, cb_update_check); +#endif +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + setItem(USE_ICON_THEME, PROPERTY, new QTableWidgetItem(tr("Use system icon theme"))); + cb_use_icon_theme = new QCheckBox(); + connect(cb_use_icon_theme, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_use_icon_theme->setChecked(pref.useSystemIconTheme()); + setCellWidget(USE_ICON_THEME, VALUE, cb_use_icon_theme); #endif } diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index 74a51ac2f..354341eed 100644 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -50,6 +50,7 @@ #include "scannedfoldersmodel.h" #include "qinisettings.h" #include "qbtsession.h" +#include "iconprovider.h" using namespace libtorrent; @@ -61,14 +62,14 @@ options_imp::options_imp(QWidget *parent): setAttribute(Qt::WA_DeleteOnClose); setModal(true); // Icons - tabSelection->item(TAB_UI)->setIcon(misc::getIcon("preferences-desktop")); - tabSelection->item(TAB_BITTORRENT)->setIcon(misc::getIcon("preferences-system-network")); - tabSelection->item(TAB_CONNECTION)->setIcon(misc::getIcon("network-wired")); - tabSelection->item(TAB_DOWNLOADS)->setIcon(misc::getIcon("download")); - tabSelection->item(TAB_SPEED)->setIcon(misc::getIcon("chronometer")); - tabSelection->item(TAB_WEBUI)->setIcon(misc::getIcon("network-server")); - tabSelection->item(TAB_ADVANCED)->setIcon(misc::getIcon("preferences-other")); - IpFilterRefreshBtn->setIcon(misc::getIcon("view-refresh")); + tabSelection->item(TAB_UI)->setIcon(IconProvider::instance()->getIcon("preferences-desktop")); + tabSelection->item(TAB_BITTORRENT)->setIcon(IconProvider::instance()->getIcon("preferences-system-network")); + tabSelection->item(TAB_CONNECTION)->setIcon(IconProvider::instance()->getIcon("network-wired")); + tabSelection->item(TAB_DOWNLOADS)->setIcon(IconProvider::instance()->getIcon("download")); + tabSelection->item(TAB_SPEED)->setIcon(IconProvider::instance()->getIcon("chronometer")); + tabSelection->item(TAB_WEBUI)->setIcon(IconProvider::instance()->getIcon("network-server")); + tabSelection->item(TAB_ADVANCED)->setIcon(IconProvider::instance()->getIcon("preferences-other")); + IpFilterRefreshBtn->setIcon(IconProvider::instance()->getIcon("view-refresh")); hsplitter->setCollapsible(0, false); hsplitter->setCollapsible(1, false); diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index 26cc47524..2b0e60301 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -856,6 +856,16 @@ public: } #endif +#if defined(Q_WS_X11) && (QT_VERSION >= QT_VERSION_CHECK(4,6,0)) + bool useSystemIconTheme() const { + return value(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), true).toBool(); + } + + void useSystemIconTheme(bool enabled) { + setValue(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), enabled); + } +#endif + QStringList getTorrentLabels() const { return value("TransferListFilters/customLabels").toStringList(); } diff --git a/src/properties/peerlistwidget.cpp b/src/properties/peerlistwidget.cpp index e37370162..d03b5ee3d 100644 --- a/src/properties/peerlistwidget.cpp +++ b/src/properties/peerlistwidget.cpp @@ -36,6 +36,7 @@ #include "geoipmanager.h" #include "peeraddition.h" #include "speedlimitdlg.h" +#include "iconprovider.h" #include #include #include @@ -134,7 +135,7 @@ void PeerListWidget::showPeerListMenu(QPoint) { // Add Peer Action QAction *addPeerAct = 0; if(!h.is_queued() && !h.is_checking()) { - addPeerAct = menu.addAction(misc::getIcon("user-group-new"), tr("Add a new peer...")); + addPeerAct = menu.addAction(IconProvider::instance()->getIcon("user-group-new"), tr("Add a new peer...")); empty_menu = false; } // Per Peer Speed limiting actions @@ -143,12 +144,12 @@ void PeerListWidget::showPeerListMenu(QPoint) { QAction *banAct = 0; QAction *copyIPAct = 0; if(!selectedPeerIPs.isEmpty()) { - copyIPAct = menu.addAction(misc::getIcon("edit-copy"), tr("Copy IP")); + copyIPAct = menu.addAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy IP")); menu.addSeparator(); dlLimitAct = menu.addAction(QIcon(":/Icons/skin/download.png"), tr("Limit download rate...")); upLimitAct = menu.addAction(QIcon(":/Icons/skin/seeding.png"), tr("Limit upload rate...")); menu.addSeparator(); - banAct = menu.addAction(misc::getIcon("user-group-delete"), tr("Ban peer permanently")); + banAct = menu.addAction(IconProvider::instance()->getIcon("user-group-delete"), tr("Ban peer permanently")); empty_menu = false; } if(empty_menu) return; diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index c0cca1283..7a4b232a4 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -54,6 +54,7 @@ #include "pieceavailabilitybar.h" #include "qinisettings.h" #include "proptabbar.h" +#include "iconprovider.h" using namespace libtorrent; @@ -62,10 +63,10 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra setupUi(this); // Icons - deleteWS_button->setIcon(misc::getIcon("list-remove")); - addWS_button->setIcon(misc::getIcon("list-add")); - trackerUpButton->setIcon(misc::getIcon("go-up")); - trackerDownButton->setIcon(misc::getIcon("go-down")); + deleteWS_button->setIcon(IconProvider::instance()->getIcon("list-remove")); + addWS_button->setIcon(IconProvider::instance()->getIcon("list-add")); + trackerUpButton->setIcon(IconProvider::instance()->getIcon("go-up")); + trackerDownButton->setIcon(IconProvider::instance()->getIcon("go-down")); state = VISIBLE; setEnabled(false); @@ -485,7 +486,7 @@ void PropertiesWidget::displayFilesListMenu(const QPoint&){ QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0); QAction *actRename = 0; if(selectedRows.size() == 1) { - actRename = myFilesLlistMenu.addAction(misc::getIcon("edit-rename"), tr("Rename...")); + actRename = myFilesLlistMenu.addAction(IconProvider::instance()->getIcon("edit-rename"), tr("Rename...")); myFilesLlistMenu.addSeparator(); } QMenu subMenu; diff --git a/src/properties/proptabbar.cpp b/src/properties/proptabbar.cpp index 44b469ce3..8998f7205 100644 --- a/src/properties/proptabbar.cpp +++ b/src/properties/proptabbar.cpp @@ -34,7 +34,7 @@ #include #include "proptabbar.h" -#include "misc.h" +#include "iconprovider.h" #ifdef Q_WS_MAC #define DEFAULT_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px; margin-left: 8px; margin-right: 8px;}" @@ -52,32 +52,32 @@ PropTabBar::PropTabBar(QWidget *parent) : m_btnGroup = new QButtonGroup(this); setContentsMargins(5, 4, 5, 2); // General tab - QPushButton *main_infos_button = new QPushButton(misc::getIcon("document-properties"), tr("General"), parent); + QPushButton *main_infos_button = new QPushButton(IconProvider::instance()->getIcon("document-properties"), tr("General"), parent); main_infos_button->setShortcut(QKeySequence(QString::fromUtf8("Alt+P"))); main_infos_button->setStyleSheet(DEFAULT_BUTTON_CSS); main_infos_button->setIconSize(QSize(BTN_ICON_SIZE, BTN_ICON_SIZE)); addWidget(main_infos_button); m_btnGroup->addButton(main_infos_button, MAIN_TAB); // Trackers tab - QPushButton *trackers_button = new QPushButton(misc::getIcon("network-server"), tr("Trackers"), parent); + QPushButton *trackers_button = new QPushButton(IconProvider::instance()->getIcon("network-server"), tr("Trackers"), parent); trackers_button->setStyleSheet(DEFAULT_BUTTON_CSS); trackers_button->setIconSize(QSize(BTN_ICON_SIZE, BTN_ICON_SIZE)); addWidget(trackers_button); m_btnGroup->addButton(trackers_button, TRACKERS_TAB); // Peers tab - QPushButton *peers_button = new QPushButton(misc::getIcon("edit-find-user"), tr("Peers"), parent); + QPushButton *peers_button = new QPushButton(IconProvider::instance()->getIcon("edit-find-user"), tr("Peers"), parent); peers_button->setStyleSheet(DEFAULT_BUTTON_CSS); peers_button->setIconSize(QSize(BTN_ICON_SIZE, BTN_ICON_SIZE)); addWidget(peers_button); m_btnGroup->addButton(peers_button, PEERS_TAB); // URL seeds tab - QPushButton *urlseeds_button = new QPushButton(misc::getIcon("network-server"), tr("HTTP Sources"), parent); + QPushButton *urlseeds_button = new QPushButton(IconProvider::instance()->getIcon("network-server"), tr("HTTP Sources"), parent); urlseeds_button->setStyleSheet(DEFAULT_BUTTON_CSS); urlseeds_button->setIconSize(QSize(BTN_ICON_SIZE, BTN_ICON_SIZE)); addWidget(urlseeds_button); m_btnGroup->addButton(urlseeds_button, URLSEEDS_TAB); // Files tab - QPushButton *files_button = new QPushButton(misc::getIcon("inode-directory"), tr("Content"), parent); + QPushButton *files_button = new QPushButton(IconProvider::instance()->getIcon("inode-directory"), tr("Content"), parent); files_button->setStyleSheet(DEFAULT_BUTTON_CSS); files_button->setIconSize(QSize(BTN_ICON_SIZE, BTN_ICON_SIZE)); addWidget(files_button); diff --git a/src/properties/trackerlist.cpp b/src/properties/trackerlist.cpp index 74084c40e..cf240348f 100644 --- a/src/properties/trackerlist.cpp +++ b/src/properties/trackerlist.cpp @@ -39,9 +39,10 @@ #include "trackerlist.h" #include "propertieswidget.h" #include "trackersadditiondlg.h" -#include "misc.h" +#include "iconprovider.h" #include "qbtsession.h" #include "qinisettings.h" +#include "misc.h" using namespace libtorrent; @@ -341,13 +342,13 @@ void TrackerList::showTrackerListMenu(QPoint) { //QList selected_items = getSelectedTrackerItems(); QMenu menu; // Add actions - QAction *addAct = menu.addAction(misc::getIcon("list-add"), tr("Add a new tracker...")); + QAction *addAct = menu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add a new tracker...")); QAction *delAct = 0; if(!getSelectedTrackerItems().isEmpty()) { - delAct = menu.addAction(misc::getIcon("list-remove"), tr("Remove tracker")); + delAct = menu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove tracker")); } menu.addSeparator(); - QAction *reannounceAct = menu.addAction(misc::getIcon("view-refresh"), tr("Force reannounce")); + QAction *reannounceAct = menu.addAction(IconProvider::instance()->getIcon("view-refresh"), tr("Force reannounce")); QAction *act = menu.exec(QCursor::pos()); if(act == 0) return; if(act == addAct) { diff --git a/src/properties/trackersadditiondlg.h b/src/properties/trackersadditiondlg.h index 7fa2f53eb..56bef79cf 100644 --- a/src/properties/trackersadditiondlg.h +++ b/src/properties/trackersadditiondlg.h @@ -36,6 +36,7 @@ #include #include #include +#include "iconprovider.h" #include "misc.h" #include "ui_trackersadditiondlg.h" #include "downloadthread.h" @@ -51,7 +52,7 @@ public: TrackersAdditionDlg(QTorrentHandle h, QWidget *parent=0): QDialog(parent), h(h) { setupUi(this); // Icons - uTorrentListButton->setIcon(misc::getIcon("download")); + uTorrentListButton->setIcon(IconProvider::instance()->getIcon("download")); // As a default, use torrentz.com link list_url->setText("http://www.torrentz.com/announce_"+h.hash()); list_url->setCursorPosition(0); diff --git a/src/rss/automatedrssdownloader.cpp b/src/rss/automatedrssdownloader.cpp index 585bcce5e..30a2bd1bf 100644 --- a/src/rss/automatedrssdownloader.cpp +++ b/src/rss/automatedrssdownloader.cpp @@ -43,7 +43,7 @@ #include "qinisettings.h" #include "rssmanager.h" #include "rssfeed.h" -#include "misc.h" +#include "iconprovider.h" AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) : QDialog(parent), @@ -52,8 +52,8 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) : { ui->setupUi(this); // Icons - ui->removeRuleBtn->setIcon(misc::getIcon("list-remove")); - ui->addRuleBtn->setIcon(misc::getIcon("list-add")); + ui->removeRuleBtn->setIcon(IconProvider::instance()->getIcon("list-remove")); + ui->addRuleBtn->setIcon(IconProvider::instance()->getIcon("list-add")); // Ui Settings ui->listRules->setSortingEnabled(true); @@ -361,17 +361,17 @@ void AutomatedRssDownloader::displayRulesListMenu(const QPoint &pos) { Q_UNUSED(pos); QMenu menu; - QAction *addAct = menu.addAction(misc::getIcon("list-add"), tr("Add new rule...")); + QAction *addAct = menu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add new rule...")); QAction *delAct = 0; QAction *renameAct = 0; const QList selection = ui->listRules->selectedItems(); if(!selection.isEmpty()) { if(selection.count() == 1) { - delAct = menu.addAction(misc::getIcon("list-remove"), tr("Delete rule")); + delAct = menu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Delete rule")); menu.addSeparator(); - renameAct = menu.addAction(misc::getIcon("edit-rename"), tr("Rename rule...")); + renameAct = menu.addAction(IconProvider::instance()->getIcon("edit-rename"), tr("Rename rule...")); } else { - delAct = menu.addAction(misc::getIcon("list-remove"), tr("Delete selected rules")); + delAct = menu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Delete selected rules")); } } QAction *act = menu.exec(QCursor::pos()); @@ -480,7 +480,7 @@ void AutomatedRssDownloader::addFeedArticlesToTree(const RssFeed *feed, const QS QFont f = treeFeedItem->font(0); f.setBold(true); treeFeedItem->setFont(0, f); - treeFeedItem->setData(0, Qt::DecorationRole, misc::getIcon("inode-directory")); + treeFeedItem->setData(0, Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory")); treeFeedItem->setData(0, Qt::UserRole, feed->getUrl()); ui->treeMatchingArticles->addTopLevelItem(treeFeedItem); } diff --git a/src/rss/cookiesdlg.cpp b/src/rss/cookiesdlg.cpp index 9f755d3b6..b1a092e69 100644 --- a/src/rss/cookiesdlg.cpp +++ b/src/rss/cookiesdlg.cpp @@ -30,7 +30,7 @@ #include "cookiesdlg.h" #include "ui_cookiesdlg.h" -#include "misc.h" +#include "iconprovider.h" #include @@ -42,8 +42,8 @@ CookiesDlg::CookiesDlg(QWidget *parent, const QList &raw_cookies) : { ui->setupUi(this); // Icons - ui->add_btn->setIcon(misc::getIcon("list-add")); - ui->del_btn->setIcon(misc::getIcon("list-remove")); + ui->add_btn->setIcon(IconProvider::instance()->getIcon("list-add")); + ui->del_btn->setIcon(IconProvider::instance()->getIcon("list-remove")); ui->infos_lbl->setText(tr("Common keys for cookies are : '%1', '%2'.\nYou should get this information from your Web browser preferences.").arg("uid").arg("pass")); foreach(const QByteArray &raw_cookie, raw_cookies) { diff --git a/src/rss/feedlistwidget.cpp b/src/rss/feedlistwidget.cpp index 156887377..7c87d7992 100644 --- a/src/rss/feedlistwidget.cpp +++ b/src/rss/feedlistwidget.cpp @@ -31,7 +31,7 @@ #include "feedlistwidget.h" #include "rssmanager.h" #include "rssfeed.h" -#include "misc.h" +#include "iconprovider.h" FeedListWidget::FeedListWidget(QWidget *parent, RssManager *rssmanager): QTreeWidget(parent), rssmanager(rssmanager) { setContextMenuPolicy(Qt::CustomContextMenu); @@ -41,7 +41,7 @@ FeedListWidget::FeedListWidget(QWidget *parent, RssManager *rssmanager): QTreeWi headerItem()->setText(0, tr("RSS feeds")); unread_item = new QTreeWidgetItem(this); unread_item->setText(0, tr("Unread") + QString::fromUtf8(" (") + QString::number(rssmanager->getNbUnRead(), 10)+ QString(")")); - unread_item->setData(0,Qt::DecorationRole, misc::getIcon("mail-folder-inbox")); + unread_item->setData(0,Qt::DecorationRole, IconProvider::instance()->getIcon("mail-folder-inbox")); itemAdded(unread_item, rssmanager); connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateCurrentFeed(QTreeWidgetItem*))); setCurrentItem(unread_item); diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 5b6693db0..6ec2e97be 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -34,6 +34,7 @@ #include "ico.h" #include "searchengine.h" #include "pluginsource.h" +#include "iconprovider.h" #include #include #include @@ -52,7 +53,7 @@ engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_en pluginsTree->header()->resizeSection(0, 170); pluginsTree->header()->resizeSection(1, 220); pluginsTree->hideColumn(ENGINE_ID); - actionUninstall->setIcon(misc::getIcon("list-remove")); + actionUninstall->setIcon(IconProvider::instance()->getIcon("list-remove")); connect(actionEnable, SIGNAL(toggled(bool)), this, SLOT(enableSelection(bool))); connect(pluginsTree, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayContextMenu(const QPoint&))); downloader = new downloadThread(this); diff --git a/src/searchengine/searchengine.cpp b/src/searchengine/searchengine.cpp index 4c99d4335..69d816fd6 100644 --- a/src/searchengine/searchengine.cpp +++ b/src/searchengine/searchengine.cpp @@ -56,6 +56,7 @@ #include "searchlistdelegate.h" #include "qinisettings.h" #include "mainwindow.h" +#include "iconprovider.h" #define SEARCHHISTORY_MAXSIZE 50 @@ -63,10 +64,10 @@ SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow(parent) { setupUi(this); // Icons - search_button->setIcon(misc::getIcon("edit-find")); - download_button->setIcon(misc::getIcon("download")); - goToDescBtn->setIcon(misc::getIcon("application-x-mswinurl")); - enginesButton->setIcon(misc::getIcon("preferences-system-network")); + search_button->setIcon(IconProvider::instance()->getIcon("edit-find")); + download_button->setIcon(IconProvider::instance()->getIcon("download")); + goToDescBtn->setIcon(IconProvider::instance()->getIcon("application-x-mswinurl")); + enginesButton->setIcon(IconProvider::instance()->getIcon("preferences-system-network")); // new qCompleter to the search pattern startSearchHistory(); createCompleter(); @@ -76,7 +77,7 @@ SearchEngine::SearchEngine(MainWindow *parent) : QWidget(parent), mp_mainWindow( #else // Add close tab button closeTab_button = new QPushButton(); - closeTab_button->setIcon(misc::getIcon("tab-close")); + closeTab_button->setIcon(IconProvider::instance()->getIcon("tab-close")); closeTab_button->setFlat(true); tabWidget->setCornerWidget(closeTab_button); connect(closeTab_button, SIGNAL(clicked()), this, SLOT(closeTab_button_clicked())); @@ -205,11 +206,11 @@ SearchEngine::~SearchEngine(){ void SearchEngine::displayPatternContextMenu(QPoint) { QMenu myMenu(this); - QAction cutAct(misc::getIcon("edit-cut"), tr("Cut"), &myMenu); - QAction copyAct(misc::getIcon("edit-copy"), tr("Copy"), &myMenu); - QAction pasteAct(misc::getIcon("edit-paste"), tr("Paste"), &myMenu); - QAction clearAct(misc::getIcon("edit-clear"), tr("Clear field"), &myMenu); - QAction clearHistoryAct(misc::getIcon("edit-clear-history"), tr("Clear completion history"), &myMenu); + QAction cutAct(IconProvider::instance()->getIcon("edit-cut"), tr("Cut"), &myMenu); + QAction copyAct(IconProvider::instance()->getIcon("edit-copy"), tr("Copy"), &myMenu); + QAction pasteAct(IconProvider::instance()->getIcon("edit-paste"), tr("Paste"), &myMenu); + QAction clearAct(IconProvider::instance()->getIcon("edit-clear"), tr("Clear field"), &myMenu); + QAction clearHistoryAct(IconProvider::instance()->getIcon("edit-clear-history"), tr("Clear completion history"), &myMenu); bool hasCopyAct = false; if(search_pattern->hasSelectedText()) { myMenu.addAction(&cutAct); diff --git a/src/src.pro b/src/src.pro index ec68b2a28..7c84f2977 100644 --- a/src/src.pro +++ b/src/src.pro @@ -131,7 +131,8 @@ nox { hidabletabwidget.h \ sessionapplication.h \ torrentimportdlg.h \ - executionlog.h + executionlog.h \ + iconprovider.h SOURCES += mainwindow.cpp \ ico.cpp \ @@ -140,7 +141,8 @@ nox { sessionapplication.cpp \ torrentimportdlg.cpp \ executionlog.cpp \ - previewselect.cpp + previewselect.cpp \ + iconprovider.cpp win32 { HEADERS += programupdater.h diff --git a/src/torrentadditiondlg.cpp b/src/torrentadditiondlg.cpp index 3cb3db34e..a09c6beb9 100644 --- a/src/torrentadditiondlg.cpp +++ b/src/torrentadditiondlg.cpp @@ -52,7 +52,7 @@ #include "misc.h" #include "proplistdelegate.h" #include "torrentpersistentdata.h" - +#include "iconprovider.h" #include "torrentadditiondlg.h" using namespace libtorrent; @@ -63,8 +63,8 @@ torrentAdditionDialog::torrentAdditionDialog(QWidget *parent) : setupUi(this); setAttribute(Qt::WA_DeleteOnClose); // Icons - CancelButton->setIcon(misc::getIcon("dialog-cancel")); - OkButton->setIcon(misc::getIcon("list-add")); + CancelButton->setIcon(IconProvider::instance()->getIcon("dialog-cancel")); + OkButton->setIcon(IconProvider::instance()->getIcon("list-add")); // Set Properties list model PropListModel = new TorrentFilesModel(); connect(PropListModel, SIGNAL(filteredFilesChanged()), SLOT(updateDiskSpaceLabels())); @@ -326,7 +326,7 @@ void torrentAdditionDialog::displayContentListMenu(const QPoint&) { const QModelIndexList selectedRows = torrentContentList->selectionModel()->selectedRows(0); QAction *actRename = 0; if(selectedRows.size() == 1 && t->num_files() > 1) { - actRename = myFilesLlistMenu.addAction(misc::getIcon("edit-rename"), tr("Rename...")); + actRename = myFilesLlistMenu.addAction(IconProvider::instance()->getIcon("edit-rename"), tr("Rename...")); myFilesLlistMenu.addSeparator(); } QMenu subMenu; diff --git a/src/torrentcreator/torrentcreatordlg.cpp b/src/torrentcreator/torrentcreatordlg.cpp index 04be6077c..6c53b7b82 100644 --- a/src/torrentcreator/torrentcreatordlg.cpp +++ b/src/torrentcreator/torrentcreatordlg.cpp @@ -37,6 +37,7 @@ #include "misc.h" #include "qinisettings.h" #include "torrentcreatorthread.h" +#include "iconprovider.h" const uint NB_PIECES_MIN = 1200; const uint NB_PIECES_MAX = 2200; @@ -46,10 +47,10 @@ using namespace libtorrent; TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent): QDialog(parent), creatorThread(0) { setupUi(this); // Icons - addFile_button->setIcon(misc::getIcon("document-new")); - addFolder_button->setIcon(misc::getIcon("folder-new")); - createButton->setIcon(misc::getIcon("document-save")); - cancelButton->setIcon(misc::getIcon("dialog-cancel")); + addFile_button->setIcon(IconProvider::instance()->getIcon("document-new")); + addFolder_button->setIcon(IconProvider::instance()->getIcon("folder-new")); + createButton->setIcon(IconProvider::instance()->getIcon("document-save")); + cancelButton->setIcon(IconProvider::instance()->getIcon("dialog-cancel")); setAttribute(Qt::WA_DeleteOnClose); setModal(true); diff --git a/src/torrentfilesmodel.h b/src/torrentfilesmodel.h index 3f592a645..c4de7cde9 100644 --- a/src/torrentfilesmodel.h +++ b/src/torrentfilesmodel.h @@ -39,7 +39,7 @@ #include #include #include "proplistdelegate.h" -#include "misc.h" +#include "iconprovider.h" enum FilePriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7, PARTIAL=-1}; enum TreeItemType {TFILE, FOLDER, ROOT}; @@ -434,9 +434,9 @@ public: TreeItem *item = static_cast(index.internalPointer()); if(index.column() == 0 && role == Qt::DecorationRole) { if(item->isFolder()) - return misc::getIcon("inode-directory"); + return IconProvider::instance()->getIcon("inode-directory"); else - return misc::getIcon("text-plain"); + return IconProvider::instance()->getIcon("text-plain"); } if(index.column() == 0 && role == Qt::CheckStateRole) { if(item->data(TreeItem::COL_PRIO).toInt() == IGNORED) diff --git a/src/torrentimportdlg.cpp b/src/torrentimportdlg.cpp index 29e256d8b..d0e9ffbb6 100644 --- a/src/torrentimportdlg.cpp +++ b/src/torrentimportdlg.cpp @@ -37,7 +37,7 @@ #include "qinisettings.h" #include "qbtsession.h" #include "torrentpersistentdata.h" -#include "misc.h" +#include "iconprovider.h" using namespace libtorrent; @@ -47,9 +47,9 @@ TorrentImportDlg::TorrentImportDlg(QWidget *parent) : { ui->setupUi(this); // Icons - ui->lbl_info->setPixmap(misc::getIcon("dialog-information").pixmap(ui->lbl_info->height())); + ui->lbl_info->setPixmap(IconProvider::instance()->getIcon("dialog-information").pixmap(ui->lbl_info->height())); ui->lbl_info->setFixedWidth(ui->lbl_info->height()); - ui->importBtn->setIcon(misc::getIcon("document-import")); + ui->importBtn->setIcon(IconProvider::instance()->getIcon("document-import")); // Libtorrent < 0.15 does not support skipping file checking #if LIBTORRENT_VERSION_MINOR < 15 ui->checkSkipCheck->setVisible(false); diff --git a/src/transferlistfilterswidget.h b/src/transferlistfilterswidget.h index 7ac486556..6b1dfc309 100644 --- a/src/transferlistfilterswidget.h +++ b/src/transferlistfilterswidget.h @@ -48,6 +48,7 @@ #include "preferences.h" #include "qinisettings.h" #include "torrentmodel.h" +#include "iconprovider.h" class LabelFiltersList: public QListWidget { Q_OBJECT @@ -137,11 +138,11 @@ protected: void setItemHover(bool hover) { Q_ASSERT(itemHover); if(hover) { - itemHover->setData(Qt::DecorationRole, misc::getIcon("folder-documents.png")); + itemHover->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("folder-documents.png")); itemHover->setSelected(true); //setCurrentItem(itemHover); } else { - itemHover->setData(Qt::DecorationRole, misc::getIcon("inode-directory.png")); + itemHover->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory.png")); //itemHover->setSelected(false); itemHover = 0; } @@ -247,10 +248,10 @@ public: // Add Label filters QListWidgetItem *allLabels = new QListWidgetItem(labelFilters); allLabels->setData(Qt::DisplayRole, QVariant(tr("All labels") + " (0)")); - allLabels->setData(Qt::DecorationRole, misc::getIcon("inode-directory")); + allLabels->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory")); QListWidgetItem *noLabel = new QListWidgetItem(labelFilters); noLabel->setData(Qt::DisplayRole, QVariant(tr("Unlabeled") + " (0)")); - noLabel->setData(Qt::DecorationRole, misc::getIcon("inode-directory")); + noLabel->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory")); // Load settings loadSettings(); @@ -291,7 +292,7 @@ public: qDebug("Creating label QListWidgetItem: %s", qPrintable(label)); QListWidgetItem *newLabel = new QListWidgetItem(); newLabel->setText(label + " (0)"); - newLabel->setData(Qt::DecorationRole, misc::getIcon("inode-directory")); + newLabel->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory")); labelFilters->addItem(newLabel); } } @@ -321,7 +322,7 @@ protected slots: if(label.isEmpty() || customLabels.contains(label)) return; QListWidgetItem *newLabel = new QListWidgetItem(); newLabel->setText(label + " (0)"); - newLabel->setData(Qt::DecorationRole, misc::getIcon("inode-directory")); + newLabel->setData(Qt::DecorationRole, IconProvider::instance()->getIcon("inode-directory")); labelFilters->addItem(newLabel); customLabels.insert(label, 0); Preferences().addTorrentLabel(label); @@ -331,12 +332,12 @@ protected slots: QMenu labelMenu(labelFilters); QAction *removeAct = 0; if(!labelFilters->selectedItems().empty() && labelFilters->row(labelFilters->selectedItems().first()) > 1) - removeAct = labelMenu.addAction(misc::getIcon("list-remove"), tr("Remove label")); - QAction *addAct = labelMenu.addAction(misc::getIcon("list-add"), tr("Add label...")); + removeAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove label")); + QAction *addAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add label...")); labelMenu.addSeparator(); - QAction *startAct = labelMenu.addAction(misc::getIcon("media-playback-start"), tr("Resume torrents")); - QAction *pauseAct = labelMenu.addAction(misc::getIcon("media-playback-pause"), tr("Pause torrents")); - QAction *deleteTorrentsAct = labelMenu.addAction(misc::getIcon("edit-delete"), tr("Delete torrents")); + QAction *startAct = labelMenu.addAction(IconProvider::instance()->getIcon("media-playback-start"), tr("Resume torrents")); + QAction *pauseAct = labelMenu.addAction(IconProvider::instance()->getIcon("media-playback-pause"), tr("Pause torrents")); + QAction *deleteTorrentsAct = labelMenu.addAction(IconProvider::instance()->getIcon("edit-delete"), tr("Delete torrents")); QAction *act = 0; act = labelMenu.exec(QCursor::pos()); if(act) { diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 0f9187b69..7f632816f 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -58,6 +58,7 @@ #include "deletionconfirmationdlg.h" #include "propertieswidget.h" #include "qinisettings.h" +#include "iconprovider.h" using namespace libtorrent; @@ -617,31 +618,31 @@ void TransferListWidget::removeLabelFromRows(QString label) { void TransferListWidget::displayListMenu(const QPoint&) { // Create actions - QAction actionStart(misc::getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), 0); + QAction actionStart(IconProvider::instance()->getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), 0); connect(&actionStart, SIGNAL(triggered()), this, SLOT(startSelectedTorrents())); - QAction actionPause(misc::getIcon("media-playback-pause"), tr("Pause", "Pause the torrent"), 0); + QAction actionPause(IconProvider::instance()->getIcon("media-playback-pause"), tr("Pause", "Pause the torrent"), 0); connect(&actionPause, SIGNAL(triggered()), this, SLOT(pauseSelectedTorrents())); - QAction actionDelete(misc::getIcon("edit-delete"), tr("Delete", "Delete the torrent"), 0); + QAction actionDelete(IconProvider::instance()->getIcon("edit-delete"), tr("Delete", "Delete the torrent"), 0); connect(&actionDelete, SIGNAL(triggered()), this, SLOT(deleteSelectedTorrents())); - QAction actionPreview_file(misc::getIcon("view-preview"), tr("Preview file..."), 0); + QAction actionPreview_file(IconProvider::instance()->getIcon("view-preview"), tr("Preview file..."), 0); connect(&actionPreview_file, SIGNAL(triggered()), this, SLOT(previewSelectedTorrents())); QAction actionSet_upload_limit(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")), tr("Limit upload rate..."), 0); connect(&actionSet_upload_limit, SIGNAL(triggered()), this, SLOT(setUpLimitSelectedTorrents())); QAction actionSet_download_limit(QIcon(QString::fromUtf8(":/Icons/skin/download.png")), tr("Limit download rate..."), 0); connect(&actionSet_download_limit, SIGNAL(triggered()), this, SLOT(setDlLimitSelectedTorrents())); - QAction actionOpen_destination_folder(misc::getIcon("inode-directory"), tr("Open destination folder"), 0); + QAction actionOpen_destination_folder(IconProvider::instance()->getIcon("inode-directory"), tr("Open destination folder"), 0); connect(&actionOpen_destination_folder, SIGNAL(triggered()), this, SLOT(openSelectedTorrentsFolder())); - QAction actionIncreasePriority(misc::getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), 0); + QAction actionIncreasePriority(IconProvider::instance()->getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), 0); connect(&actionIncreasePriority, SIGNAL(triggered()), this, SLOT(increasePrioSelectedTorrents())); - QAction actionDecreasePriority(misc::getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), 0); + QAction actionDecreasePriority(IconProvider::instance()->getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), 0); connect(&actionDecreasePriority, SIGNAL(triggered()), this, SLOT(decreasePrioSelectedTorrents())); - QAction actionTopPriority(misc::getIcon("go-top"), tr("Move to top", "i.e. Move to top of the queue"), 0); + QAction actionTopPriority(IconProvider::instance()->getIcon("go-top"), tr("Move to top", "i.e. Move to top of the queue"), 0); connect(&actionTopPriority, SIGNAL(triggered()), this, SLOT(topPrioSelectedTorrents())); - QAction actionBottomPriority(misc::getIcon("go-bottom"), tr("Move to bottom", "i.e. Move to bottom of the queue"), 0); + QAction actionBottomPriority(IconProvider::instance()->getIcon("go-bottom"), tr("Move to bottom", "i.e. Move to bottom of the queue"), 0); connect(&actionBottomPriority, SIGNAL(triggered()), this, SLOT(bottomPrioSelectedTorrents())); - QAction actionSetTorrentPath(misc::getIcon("inode-directory"), tr("Set location..."), 0); + QAction actionSetTorrentPath(IconProvider::instance()->getIcon("inode-directory"), tr("Set location..."), 0); connect(&actionSetTorrentPath, SIGNAL(triggered()), this, SLOT(setSelectedTorrentsLocation())); - QAction actionForce_recheck(misc::getIcon("document-edit-verify"), tr("Force recheck"), 0); + QAction actionForce_recheck(IconProvider::instance()->getIcon("document-edit-verify"), tr("Force recheck"), 0); connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents())); QAction actionCopy_magnet_link(QIcon(":/Icons/magnet.png"), tr("Copy magnet link"), 0); connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs())); @@ -650,7 +651,7 @@ void TransferListWidget::displayListMenu(const QPoint&) { actionSuper_seeding_mode.setCheckable(true); connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding())); #endif - QAction actionRename(misc::getIcon("edit-rename"), tr("Rename..."), 0); + QAction actionRename(IconProvider::instance()->getIcon("edit-rename"), tr("Rename..."), 0); connect(&actionRename, SIGNAL(triggered()), this, SLOT(renameSelectedTorrent())); QAction actionSequential_download(tr("Download in sequential order"), 0); actionSequential_download.setCheckable(true); @@ -737,12 +738,12 @@ void TransferListWidget::displayListMenu(const QPoint&) { QStringList customLabels = getCustomLabels(); customLabels.sort(); QList labelActions; - QMenu *labelMenu = listMenu.addMenu(misc::getIcon("view-categories"), tr("Label")); - labelActions << labelMenu->addAction(misc::getIcon("list-add"), tr("New...", "New label...")); - labelActions << labelMenu->addAction(misc::getIcon("edit-clear"), tr("Reset", "Reset label")); + QMenu *labelMenu = listMenu.addMenu(IconProvider::instance()->getIcon("view-categories"), tr("Label")); + labelActions << labelMenu->addAction(IconProvider::instance()->getIcon("list-add"), tr("New...", "New label...")); + labelActions << labelMenu->addAction(IconProvider::instance()->getIcon("edit-clear"), tr("Reset", "Reset label")); labelMenu->addSeparator(); foreach(const QString &label, customLabels) { - labelActions << labelMenu->addAction(misc::getIcon("inode-directory"), label); + labelActions << labelMenu->addAction(IconProvider::instance()->getIcon("inode-directory"), label); } listMenu.addSeparator(); if(one_not_seed) diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 7e6e1d959..b7bd0142a 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -36,6 +36,9 @@ #include "json.h" #include "qbtsession.h" #include "misc.h" +#ifndef DISABLE_GUI +#include "iconprovider.h" +#endif #include #include #include @@ -240,7 +243,11 @@ void HttpConnection::respond() { // Icons from theme qDebug() << "list[0]" << list[0]; if(list[0] == "theme" && list.size() == 2) { - url = misc::getIconPath(list[1]); +#ifdef DISABLE_GUI + url = ":/Icons/oxygen/"+list[1]+".png"; +#else + url = IconProvider::instance()->getIconPath(list[1]); +#endif qDebug() << "There icon:" << url; } else { if (list[0] == "images") {