diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 3acd98297..db123eca4 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -1,10 +1,13 @@ add_executable(qBittorrent +# headers application.h applicationinstancemanager.h cmdoptions.h filelogger.h qtlocalpeer/qtlocalpeer.h upgrade.h + +# sources application.cpp applicationinstancemanager.cpp cmdoptions.cpp diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 8ed310686..304bfd96a 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -4,7 +4,6 @@ set(CMAKE_AUTOUIC True) add_library(qbt_gui_headers INTERFACE) target_include_directories(qbt_gui_headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -add_subdirectory(lineedit) add_subdirectory(properties) add_subdirectory(powermanagement) add_subdirectory(rss) @@ -30,6 +29,7 @@ fspathedit_p.h guiiconprovider.h hidabletabwidget.h ipsubnetwhitelistoptionsdialog.h +lineedit.h loglistwidget.h mainwindow.h optionsdialog.h @@ -80,6 +80,7 @@ fspathedit.cpp fspathedit_p.cpp guiiconprovider.cpp ipsubnetwhitelistoptionsdialog.cpp +lineedit.cpp loglistwidget.cpp mainwindow.cpp optionsdialog.cpp @@ -137,7 +138,7 @@ updownratiodialog.ui target_link_libraries(qbt_gui PRIVATE - qbt_lineedit qbt_powermanagement qbt_rss qbt_properties qbt_searchengine + qbt_powermanagement qbt_rss qbt_properties qbt_searchengine qbt_base ) diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 62fbec101..4ec7f922b 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include "base/bittorrent/session.h" @@ -313,15 +314,20 @@ void AdvancedSettings::loadAdvancedSettings() const BitTorrent::Session *const session = BitTorrent::Session::instance(); // add section headers - labelQbtLink.setText(makeLink("https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced" - , tr("Open documentation"))); - labelQbtLink.setOpenExternalLinks(true); - addRow(QBITTORRENT_HEADER, QString("%1").arg(tr("qBittorrent Section")), &labelQbtLink); + auto *labelQbtLink = new QLabel( + makeLink(QLatin1String("https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced") + , tr("Open documentation")) + , this); + labelQbtLink->setOpenExternalLinks(true); + addRow(QBITTORRENT_HEADER, QString("%1").arg(tr("qBittorrent Section")), labelQbtLink); static_cast(cellWidget(QBITTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); - labelLibtorrentLink.setText(makeLink("https://www.libtorrent.org/reference.html", tr("Open documentation"))); - labelLibtorrentLink.setOpenExternalLinks(true); - addRow(LIBTORRENT_HEADER, QString("%1").arg(tr("libtorrent Section")), &labelLibtorrentLink); + auto *labelLibtorrentLink = new QLabel( + makeLink(QLatin1String("https://www.libtorrent.org/reference.html") + , tr("Open documentation")) + , this); + labelLibtorrentLink->setOpenExternalLinks(true); + addRow(LIBTORRENT_HEADER, QString("%1").arg(tr("libtorrent Section")), labelLibtorrentLink); static_cast(cellWidget(LIBTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); // Async IO threads diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index ebd057d7d..5d317644a 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -58,7 +57,6 @@ private: void loadAdvancedSettings(); template void addRow(int row, const QString &text, T *widget); - QLabel labelQbtLink, labelLibtorrentLink; QSpinBox spinBoxAsyncIOThreads, spinBoxFilePoolSize, spinBoxCheckingMemUsage, spinBoxCache, spinBoxSaveResumeDataInterval, spinBoxOutgoingPortsMin, spinBoxOutgoingPortsMax, spinBoxListRefresh, spinBoxTrackerPort, spinBoxCacheTTL, spinBoxSendBufferWatermark, spinBoxSendBufferLowWatermark, diff --git a/src/gui/cookiesdialog.h b/src/gui/cookiesdialog.h index 62558055d..311d488d4 100644 --- a/src/gui/cookiesdialog.h +++ b/src/gui/cookiesdialog.h @@ -31,13 +31,13 @@ #include +class CookiesModel; + namespace Ui { class CookiesDialog; } -class CookiesModel; - class CookiesDialog : public QDialog { Q_OBJECT diff --git a/src/gui/executionlogwidget.h b/src/gui/executionlogwidget.h index 45c7adc7a..8e5953ca8 100644 --- a/src/gui/executionlogwidget.h +++ b/src/gui/executionlogwidget.h @@ -32,11 +32,12 @@ #include #include "base/logger.h" +class LogListWidget; + namespace Ui { class ExecutionLogWidget; } -class LogListWidget; class ExecutionLogWidget : public QWidget { diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 02a099668..494eb19e3 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -1,6 +1,5 @@ INCLUDEPATH += $$PWD -include(lineedit/lineedit.pri) include(powermanagement/powermanagement.pri) include(properties/properties.pri) unix:!macx:dbus: include(qtnotify/qtnotify.pri) @@ -24,6 +23,7 @@ HEADERS += \ $$PWD/guiiconprovider.h \ $$PWD/hidabletabwidget.h \ $$PWD/ipsubnetwhitelistoptionsdialog.h \ + $$PWD/lineedit.h \ $$PWD/loglistwidget.h \ $$PWD/mainwindow.h \ $$PWD/optionsdialog.h \ @@ -85,6 +85,7 @@ SOURCES += \ $$PWD/fspathedit_p.cpp \ $$PWD/guiiconprovider.cpp \ $$PWD/ipsubnetwhitelistoptionsdialog.cpp \ + $$PWD/lineedit.cpp \ $$PWD/loglistwidget.cpp \ $$PWD/mainwindow.cpp \ $$PWD/optionsdialog.cpp \ diff --git a/src/gui/lineedit/src/lineedit.cpp b/src/gui/lineedit.cpp similarity index 100% rename from src/gui/lineedit/src/lineedit.cpp rename to src/gui/lineedit.cpp diff --git a/src/gui/lineedit/src/lineedit.h b/src/gui/lineedit.h similarity index 100% rename from src/gui/lineedit/src/lineedit.h rename to src/gui/lineedit.h diff --git a/src/gui/lineedit/CMakeLists.txt b/src/gui/lineedit/CMakeLists.txt deleted file mode 100644 index b0c982e7d..000000000 --- a/src/gui/lineedit/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_library(qbt_lineedit STATIC -src/lineedit.cpp -src/lineedit.h -) - -target_link_libraries(qbt_lineedit - PRIVATE - qbt_gui_headers - PUBLIC - Qt5::Widgets -) - -target_include_directories(qbt_lineedit PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) diff --git a/src/gui/lineedit/lineedit.pri b/src/gui/lineedit/lineedit.pri deleted file mode 100644 index d07a720c6..000000000 --- a/src/gui/lineedit/lineedit.pri +++ /dev/null @@ -1,3 +0,0 @@ -INCLUDEPATH += $$PWD/src -HEADERS += $$PWD/src/lineedit.h -SOURCES += $$PWD/src/lineedit.cpp diff --git a/src/gui/powermanagement/CMakeLists.txt b/src/gui/powermanagement/CMakeLists.txt index 17b0395e7..760e5f9c0 100644 --- a/src/gui/powermanagement/CMakeLists.txt +++ b/src/gui/powermanagement/CMakeLists.txt @@ -1,5 +1,8 @@ add_library(qbt_powermanagement STATIC +# headers powermanagement.h + +# sources powermanagement.cpp ) diff --git a/src/gui/properties/CMakeLists.txt b/src/gui/properties/CMakeLists.txt index 0adc4a1fa..b4c87dbfe 100644 --- a/src/gui/properties/CMakeLists.txt +++ b/src/gui/properties/CMakeLists.txt @@ -39,7 +39,7 @@ target_link_libraries(qbt_properties PRIVATE qbt_gui_headers PUBLIC - qbt_base qbt_lineedit Qt5::Widgets + qbt_base Qt5::Widgets ) target_include_directories(qbt_properties diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 883a18a09..7fa20e0d3 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -133,8 +134,8 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) connect(header(), &QHeaderView::sectionResized, this, &PeerListWidget::saveSettings); connect(header(), &QHeaderView::sortIndicatorChanged, this, &PeerListWidget::saveSettings); handleSortColumnChanged(header()->sortIndicatorSection()); - m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers); + const auto *copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers); // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 diff --git a/src/gui/properties/peerlistwidget.h b/src/gui/properties/peerlistwidget.h index f49c5ecf4..747b95d22 100644 --- a/src/gui/properties/peerlistwidget.h +++ b/src/gui/properties/peerlistwidget.h @@ -32,7 +32,6 @@ #include #include #include -#include #include class QSortFilterProxyModel; @@ -43,11 +42,6 @@ class PeerListDelegate; class PeerListSortModel; class PropertiesWidget; -namespace Net -{ - class ReverseResolution; -} - namespace BitTorrent { class TorrentHandle; @@ -55,6 +49,11 @@ namespace BitTorrent struct PeerAddress; } +namespace Net +{ + class ReverseResolution; +} + class PeerListWidget : public QTreeView { Q_OBJECT @@ -92,7 +91,6 @@ private: QPointer m_resolver; PropertiesWidget *m_properties; bool m_resolveCountries; - QShortcut *m_copyHotkey; }; #endif // PEERLISTWIDGET_H diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index fe5e562f6..e011f3bce 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -44,6 +44,7 @@ #include "base/bittorrent/downloadpriority.h" #include "base/bittorrent/session.h" +#include "base/bittorrent/torrenthandle.h" #include "base/preferences.h" #include "base/unicodestrings.h" #include "base/utils/fs.h" @@ -149,16 +150,17 @@ PropertiesWidget::PropertiesWidget(QWidget *parent) connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility); connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings); - m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkeyFile, &QShortcut::activated + const auto *editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); + connect(editHotkeyFile, &QShortcut::activated , this, [this]() { m_ui->filesList->renameSelectedFile(m_torrent); }); - m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::editWebSeed); + const auto *editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); + connect(editHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::editWebSeed); + const auto *deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); + connect(deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds); + const auto *openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); + connect(openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile); + connect(m_ui->listWebSeeds, &QListWidget::doubleClicked, this, &PropertiesWidget::editWebSeed); - m_deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds); - m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile); configure(); connect(Preferences::instance(), &Preferences::changed, this, &PropertiesWidget::configure); @@ -175,10 +177,6 @@ PropertiesWidget::~PropertiesWidget() delete m_propListModel; delete m_propListDelegate; delete m_tabBar; - delete m_editHotkeyFile; - delete m_editHotkeyWeb; - delete m_deleteHotkeyWeb; - delete m_openHotkeyFile; delete m_ui; qDebug() << Q_FUNC_INFO << "EXIT"; } diff --git a/src/gui/properties/propertieswidget.h b/src/gui/properties/propertieswidget.h index 3fa9b3474..0e59b1124 100644 --- a/src/gui/properties/propertieswidget.h +++ b/src/gui/properties/propertieswidget.h @@ -32,10 +32,7 @@ #include #include -#include "base/bittorrent/torrenthandle.h" - class QPushButton; -class QShortcut; class QTreeView; class DownloadedPiecesBar; @@ -47,6 +44,11 @@ class PropTabBar; class TorrentContentFilterModel; class TrackerListWidget; +namespace BitTorrent +{ + class TorrentHandle; +} + namespace Ui { class PropertiesWidget; @@ -121,10 +123,6 @@ private: PieceAvailabilityBar *m_piecesAvailability; PropTabBar *m_tabBar; LineEdit *m_contentFilterLine; - QShortcut *m_editHotkeyFile; - QShortcut *m_editHotkeyWeb; - QShortcut *m_deleteHotkeyWeb; - QShortcut *m_openHotkeyFile; }; #endif // PROPERTIESWIDGET_H diff --git a/src/gui/properties/proplistdelegate.cpp b/src/gui/properties/proplistdelegate.cpp index 75d8e058e..6fb6a5f54 100644 --- a/src/gui/properties/proplistdelegate.cpp +++ b/src/gui/properties/proplistdelegate.cpp @@ -41,6 +41,7 @@ #endif #include "base/bittorrent/downloadpriority.h" +#include "base/bittorrent/torrenthandle.h" #include "base/unicodestrings.h" #include "base/utils/misc.h" #include "base/utils/string.h" diff --git a/src/gui/properties/speedwidget.cpp b/src/gui/properties/speedwidget.cpp index 9b337c3fa..761cb17ee 100644 --- a/src/gui/properties/speedwidget.cpp +++ b/src/gui/properties/speedwidget.cpp @@ -39,6 +39,7 @@ #include "base/bittorrent/sessionstatus.h" #include "base/preferences.h" #include "propertieswidget.h" +#include "speedplotview.h" ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu) : QComboBox(parent) diff --git a/src/gui/properties/speedwidget.h b/src/gui/properties/speedwidget.h index d8a9870ed..cbde6ab60 100644 --- a/src/gui/properties/speedwidget.h +++ b/src/gui/properties/speedwidget.h @@ -32,14 +32,13 @@ #include #include -#include "speedplotview.h" - class QHBoxLayout; class QLabel; class QMenu; class QVBoxLayout; class PropertiesWidget; +class SpeedPlotView; class ComboBoxMenuButton : public QComboBox { diff --git a/src/gui/properties/trackerlistwidget.cpp b/src/gui/properties/trackerlistwidget.cpp index 4146e4182..bcf23b7b3 100644 --- a/src/gui/properties/trackerlistwidget.cpp +++ b/src/gui/properties/trackerlistwidget.cpp @@ -54,6 +54,8 @@ #include "propertieswidget.h" #include "trackersadditiondialog.h" +#define NB_STICKY_ITEM 3 + TrackerListWidget::TrackerListWidget(PropertiesWidget *properties) : QTreeWidget() , m_properties(properties) @@ -87,6 +89,7 @@ TrackerListWidget::TrackerListWidget(PropertiesWidget *properties) connect(header(), &QHeaderView::sectionMoved, this, &TrackerListWidget::saveSettings); connect(header(), &QHeaderView::sectionResized, this, &TrackerListWidget::saveSettings); connect(header(), &QHeaderView::sortIndicatorChanged, this, &TrackerListWidget::saveSettings); + // Set DHT, PeX, LSD items m_DHTItem = new QTreeWidgetItem({ "", "** [DHT] **", "", "0", "", "", "0" }); insertTopLevelItem(0, m_DHTItem); @@ -97,33 +100,38 @@ TrackerListWidget::TrackerListWidget(PropertiesWidget *properties) m_LSDItem = new QTreeWidgetItem({ "", "** [LSD] **", "", "0", "", "", "0" }); insertTopLevelItem(2, m_LSDItem); setRowColor(2, QColor("grey")); + // Set static items alignment - m_DHTItem->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter)); - m_PEXItem->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter)); - m_LSDItem->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter)); - m_DHTItem->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter)); - m_PEXItem->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter)); - m_LSDItem->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter)); - m_DHTItem->setTextAlignment(COL_LEECHES, (Qt::AlignRight | Qt::AlignVCenter)); - m_PEXItem->setTextAlignment(COL_LEECHES, (Qt::AlignRight | Qt::AlignVCenter)); - m_LSDItem->setTextAlignment(COL_LEECHES, (Qt::AlignRight | Qt::AlignVCenter)); - m_DHTItem->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter)); - m_PEXItem->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter)); - m_LSDItem->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter)); + const Qt::Alignment alignment = (Qt::AlignRight | Qt::AlignVCenter); + m_DHTItem->setTextAlignment(COL_PEERS, alignment); + m_PEXItem->setTextAlignment(COL_PEERS, alignment); + m_LSDItem->setTextAlignment(COL_PEERS, alignment); + m_DHTItem->setTextAlignment(COL_SEEDS, alignment); + m_PEXItem->setTextAlignment(COL_SEEDS, alignment); + m_LSDItem->setTextAlignment(COL_SEEDS, alignment); + m_DHTItem->setTextAlignment(COL_LEECHES, alignment); + m_PEXItem->setTextAlignment(COL_LEECHES, alignment); + m_LSDItem->setTextAlignment(COL_LEECHES, alignment); + m_DHTItem->setTextAlignment(COL_DOWNLOADED, alignment); + m_PEXItem->setTextAlignment(COL_DOWNLOADED, alignment); + m_LSDItem->setTextAlignment(COL_DOWNLOADED, alignment); + // Set header alignment - headerItem()->setTextAlignment(COL_TIER, (Qt::AlignRight | Qt::AlignVCenter)); - headerItem()->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter)); - headerItem()->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter)); - headerItem()->setTextAlignment(COL_LEECHES, (Qt::AlignRight | Qt::AlignVCenter)); - headerItem()->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter)); + headerItem()->setTextAlignment(COL_TIER, alignment); + headerItem()->setTextAlignment(COL_PEERS, alignment); + headerItem()->setTextAlignment(COL_SEEDS, alignment); + headerItem()->setTextAlignment(COL_LEECHES, alignment); + headerItem()->setTextAlignment(COL_DOWNLOADED, alignment); + // Set hotkeys - m_editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkey, &QShortcut::activated, this, &TrackerListWidget::editSelectedTracker); + const auto *editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(editHotkey, &QShortcut::activated, this, &TrackerListWidget::editSelectedTracker); + const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(deleteHotkey, &QShortcut::activated, this, &TrackerListWidget::deleteSelectedTrackers); + const auto *copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(copyHotkey, &QShortcut::activated, this, &TrackerListWidget::copyTrackerUrl); + connect(this, &QAbstractItemView::doubleClicked, this, &TrackerListWidget::editSelectedTracker); - m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_deleteHotkey, &QShortcut::activated, this, &TrackerListWidget::deleteSelectedTrackers); - m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_copyHotkey, &QShortcut::activated, this, &TrackerListWidget::copyTrackerUrl); // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 @@ -138,10 +146,12 @@ TrackerListWidget::~TrackerListWidget() saveSettings(); } -QList TrackerListWidget::getSelectedTrackerItems() const +QVector TrackerListWidget::getSelectedTrackerItems() const { const QList selectedTrackerItems = selectedItems(); - QList selectedTrackers; + QVector selectedTrackers; + selectedTrackers.reserve(selectedTrackerItems.size()); + for (QTreeWidgetItem *item : selectedTrackerItems) { if (indexOfTopLevelItem(item) >= NB_STICKY_ITEM) // Ignore STICKY ITEMS selectedTrackers << item; @@ -165,7 +175,7 @@ void TrackerListWidget::moveSelectionUp() clear(); return; } - const QList selectedTrackerItems = getSelectedTrackerItems(); + const QVector selectedTrackerItems = getSelectedTrackerItems(); if (selectedTrackerItems.isEmpty()) return; bool change = false; @@ -207,7 +217,7 @@ void TrackerListWidget::moveSelectionDown() clear(); return; } - const QList selectedTrackerItems = getSelectedTrackerItems(); + const QVector selectedTrackerItems = getSelectedTrackerItems(); if (selectedTrackerItems.isEmpty()) return; bool change = false; @@ -246,6 +256,7 @@ void TrackerListWidget::clear() { qDeleteAll(m_trackerItems); m_trackerItems.clear(); + m_DHTItem->setText(COL_STATUS, ""); m_DHTItem->setText(COL_SEEDS, ""); m_DHTItem->setText(COL_LEECHES, ""); @@ -260,7 +271,7 @@ void TrackerListWidget::clear() m_LSDItem->setText(COL_MSG, ""); } -void TrackerListWidget::loadStickyItems(BitTorrent::TorrentHandle *const torrent) +void TrackerListWidget::loadStickyItems(const BitTorrent::TorrentHandle *torrent) { QString working = tr("Working"); QString disabled = tr("Disabled"); @@ -327,16 +338,18 @@ void TrackerListWidget::loadStickyItems(BitTorrent::TorrentHandle *const torrent void TrackerListWidget::loadTrackers() { // Load trackers from torrent handle - BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); + const BitTorrent::TorrentHandle *torrent = m_properties->getCurrentTorrent(); if (!torrent) return; loadStickyItems(torrent); // Load actual trackers information - QHash trackerData = torrent->trackerInfos(); + const QHash trackerData = torrent->trackerInfos(); QStringList oldTrackerURLs = m_trackerItems.keys(); + for (const BitTorrent::TrackerEntry &entry : asConst(torrent->trackers())) { - QString trackerURL = entry.url(); + const QString trackerURL = entry.url(); + QTreeWidgetItem *item = m_trackerItems.value(trackerURL, nullptr); if (!item) { item = new QTreeWidgetItem(); @@ -347,9 +360,11 @@ void TrackerListWidget::loadTrackers() else { oldTrackerURLs.removeOne(trackerURL); } + item->setText(COL_TIER, QString::number(entry.tier())); - BitTorrent::TrackerInfo data = trackerData.value(trackerURL); - QString errorMessage = data.lastMessage.trimmed(); + + const BitTorrent::TrackerInfo data = trackerData.value(trackerURL); + switch (entry.status()) { case BitTorrent::TrackerEntry::Working: item->setText(COL_STATUS, tr("Working")); @@ -361,7 +376,7 @@ void TrackerListWidget::loadTrackers() break; case BitTorrent::TrackerEntry::NotWorking: item->setText(COL_STATUS, tr("Not working")); - item->setText(COL_MSG, errorMessage); + item->setText(COL_MSG, data.lastMessage.trimmed()); break; case BitTorrent::TrackerEntry::NotContacted: item->setText(COL_STATUS, tr("Not contacted yet")); @@ -370,16 +385,24 @@ void TrackerListWidget::loadTrackers() } item->setText(COL_PEERS, QString::number(data.numPeers)); - item->setText(COL_SEEDS, (entry.numSeeds() > -1) ? QString::number(entry.numSeeds()) : tr("N/A")); - item->setText(COL_LEECHES, (entry.numLeeches() > -1) ? QString::number(entry.numLeeches()) : tr("N/A")); - item->setText(COL_DOWNLOADED, (entry.numDownloaded() > -1) ? QString::number(entry.numDownloaded()) : tr("N/A")); - - item->setTextAlignment(COL_TIER, (Qt::AlignRight | Qt::AlignVCenter)); - item->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter)); - item->setTextAlignment(COL_SEEDS, (Qt::AlignRight | Qt::AlignVCenter)); - item->setTextAlignment(COL_LEECHES, (Qt::AlignRight | Qt::AlignVCenter)); - item->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter)); + item->setText(COL_SEEDS, ((entry.numSeeds() > -1) + ? QString::number(entry.numSeeds()) + : tr("N/A"))); + item->setText(COL_LEECHES, ((entry.numLeeches() > -1) + ? QString::number(entry.numLeeches()) + : tr("N/A"))); + item->setText(COL_DOWNLOADED, ((entry.numDownloaded() > -1) + ? QString::number(entry.numDownloaded()) + : tr("N/A"))); + + const Qt::Alignment alignment = (Qt::AlignRight | Qt::AlignVCenter); + item->setTextAlignment(COL_TIER, alignment); + item->setTextAlignment(COL_PEERS, alignment); + item->setTextAlignment(COL_SEEDS, alignment); + item->setTextAlignment(COL_LEECHES, alignment); + item->setTextAlignment(COL_DOWNLOADED, alignment); } + // Remove old trackers for (const QString &tracker : asConst(oldTrackerURLs)) delete m_trackerItems.take(tracker); @@ -400,7 +423,7 @@ void TrackerListWidget::askForTrackers() void TrackerListWidget::copyTrackerUrl() { - const QList selectedTrackerItems = getSelectedTrackerItems(); + const QVector selectedTrackerItems = getSelectedTrackerItems(); if (selectedTrackerItems.isEmpty()) return; QStringList urlsToCopy; @@ -421,7 +444,7 @@ void TrackerListWidget::deleteSelectedTrackers() return; } - const QList selectedTrackerItems = getSelectedTrackerItems(); + const QVector selectedTrackerItems = getSelectedTrackerItems(); if (selectedTrackerItems.isEmpty()) return; QStringList urlsToRemove; @@ -453,7 +476,7 @@ void TrackerListWidget::editSelectedTracker() BitTorrent::TorrentHandle *const torrent = m_properties->getCurrentTorrent(); if (!torrent) return; - QList selectedTrackerItems = getSelectedTrackerItems(); + const QVector selectedTrackerItems = getSelectedTrackerItems(); if (selectedTrackerItems.isEmpty()) return; // During multi-select only process item selected last @@ -574,8 +597,8 @@ void TrackerListWidget::saveSettings() const QStringList TrackerListWidget::headerLabels() { - static const QStringList header { - tr("Tier") + return { + tr("Tier") , tr("URL") , tr("Status") , tr("Peers") @@ -584,8 +607,6 @@ QStringList TrackerListWidget::headerLabels() , tr("Downloaded") , tr("Message") }; - - return header; } int TrackerListWidget::visibleColumnsCount() const diff --git a/src/gui/properties/trackerlistwidget.h b/src/gui/properties/trackerlistwidget.h index d892b4a38..16d9ee2f1 100644 --- a/src/gui/properties/trackerlistwidget.h +++ b/src/gui/properties/trackerlistwidget.h @@ -29,14 +29,10 @@ #ifndef TRACKERLIST_H #define TRACKERLIST_H -#include #include +#include -#include "propertieswidget.h" - -class QShortcut; - -#define NB_STICKY_ITEM 3 +class PropertiesWidget; namespace BitTorrent { @@ -75,7 +71,7 @@ public slots: void moveSelectionDown(); void clear(); - void loadStickyItems(BitTorrent::TorrentHandle *const torrent); + void loadStickyItems(const BitTorrent::TorrentHandle *torrent); void loadTrackers(); void askForTrackers(); void copyTrackerUrl(); @@ -88,19 +84,16 @@ public slots: void saveSettings() const; protected: - QList getSelectedTrackerItems() const; + QVector getSelectedTrackerItems() const; private: + static QStringList headerLabels(); + PropertiesWidget *m_properties; QHash m_trackerItems; QTreeWidgetItem *m_DHTItem; QTreeWidgetItem *m_PEXItem; QTreeWidgetItem *m_LSDItem; - QShortcut *m_editHotkey; - QShortcut *m_deleteHotkey; - QShortcut *m_copyHotkey; - - static QStringList headerLabels(); }; #endif // TRACKERLIST_H diff --git a/src/gui/qtnotify/CMakeLists.txt b/src/gui/qtnotify/CMakeLists.txt index 7283f1f70..2328dd0ed 100644 --- a/src/gui/qtnotify/CMakeLists.txt +++ b/src/gui/qtnotify/CMakeLists.txt @@ -1,6 +1,9 @@ add_library(qbt_qtnotify STATIC -notifications.cpp +# headers notifications.h + +# sources +notifications.cpp ) set_target_properties(qbt_qtnotify PROPERTIES AUTOUIC False AUTORCC False) diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 9555a6e16..fe962336e 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -121,12 +121,12 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) connect(m_ui->listRules, &QListWidget::itemSelectionChanged, this, &AutomatedRssDownloader::updateRuleDefinitionBox); connect(m_ui->listRules, &QListWidget::itemChanged, this, &AutomatedRssDownloader::handleRuleCheckStateChange); - m_editHotkey = new QShortcut(Qt::Key_F2, m_ui->listRules, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::renameSelectedRule); - connect(m_ui->listRules, &QAbstractItemView::doubleClicked, this, &AutomatedRssDownloader::renameSelectedRule); + const auto *editHotkey = new QShortcut(Qt::Key_F2, m_ui->listRules, nullptr, nullptr, Qt::WidgetShortcut); + connect(editHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::renameSelectedRule); + const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, m_ui->listRules, nullptr, nullptr, Qt::WidgetShortcut); + connect(deleteHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked); - m_deleteHotkey = new QShortcut(QKeySequence::Delete, m_ui->listRules, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_deleteHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked); + connect(m_ui->listRules, &QAbstractItemView::doubleClicked, this, &AutomatedRssDownloader::renameSelectedRule); loadFeedList(); @@ -149,8 +149,6 @@ AutomatedRssDownloader::~AutomatedRssDownloader() saveEditedRule(); saveSettings(); - delete m_editHotkey; - delete m_deleteHotkey; delete m_ui; delete m_episodeRegex; } diff --git a/src/gui/rss/automatedrssdownloader.h b/src/gui/rss/automatedrssdownloader.h index 26c4f70d8..0ce3f707a 100644 --- a/src/gui/rss/automatedrssdownloader.h +++ b/src/gui/rss/automatedrssdownloader.h @@ -37,20 +37,19 @@ #include "base/rss/rss_autodownloadrule.h" -namespace Ui -{ - class AutomatedRssDownloader; -} - class QListWidgetItem; class QRegularExpression; -class QShortcut; namespace RSS { class Feed; } +namespace Ui +{ + class AutomatedRssDownloader; +} + class AutomatedRssDownloader : public QDialog { Q_OBJECT @@ -102,8 +101,6 @@ private: Ui::AutomatedRssDownloader *m_ui; QListWidgetItem *m_currentRuleItem; - QShortcut *m_editHotkey; - QShortcut *m_deleteHotkey; QSet> m_treeListEntries; RSS::AutoDownloadRule m_currentRule; QHash m_itemsByRuleName; diff --git a/src/gui/rss/rsswidget.cpp b/src/gui/rss/rsswidget.cpp index e1613e4ed..d1482076e 100644 --- a/src/gui/rss/rsswidget.cpp +++ b/src/gui/rss/rsswidget.cpp @@ -93,10 +93,10 @@ RSSWidget::RSSWidget(QWidget *parent) loadFoldersOpenState(); m_feedListWidget->setCurrentItem(m_feedListWidget->stickyUnreadItem()); - m_editHotkey = new QShortcut(Qt::Key_F2, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkey, &QShortcut::activated, this, &RSSWidget::renameSelectedRSSItem); - m_deleteHotkey = new QShortcut(QKeySequence::Delete, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_deleteHotkey, &QShortcut::activated, this, &RSSWidget::deleteSelectedItems); + const auto *editHotkey = new QShortcut(Qt::Key_F2, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut); + connect(editHotkey, &QShortcut::activated, this, &RSSWidget::renameSelectedRSSItem); + const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut); + connect(deleteHotkey, &QShortcut::activated, this, &RSSWidget::deleteSelectedItems); // Feeds list actions connect(m_ui->actionDelete, &QAction::triggered, this, &RSSWidget::deleteSelectedItems); @@ -135,8 +135,6 @@ RSSWidget::~RSSWidget() saveFoldersOpenState(); - delete m_editHotkey; - delete m_deleteHotkey; delete m_feedListWidget; delete m_ui; } diff --git a/src/gui/rss/rsswidget.h b/src/gui/rss/rsswidget.h index d0246ad3e..791610446 100644 --- a/src/gui/rss/rsswidget.h +++ b/src/gui/rss/rsswidget.h @@ -34,7 +34,6 @@ #include class QListWidgetItem; -class QShortcut; class QTreeWidgetItem; class ArticleListWidget; @@ -86,8 +85,6 @@ private: Ui::RSSWidget *m_ui; ArticleListWidget *m_articleListWidget; FeedListWidget *m_feedListWidget; - QShortcut *m_editHotkey; - QShortcut *m_deleteHotkey; }; #endif // RSSWIDGET_H diff --git a/src/gui/search/CMakeLists.txt b/src/gui/search/CMakeLists.txt index a80aee3cc..88b218cad 100644 --- a/src/gui/search/CMakeLists.txt +++ b/src/gui/search/CMakeLists.txt @@ -29,5 +29,5 @@ target_link_libraries(qbt_searchengine PUBLIC qbt_base PRIVATE - qbt_lineedit qbt_gui_headers + qbt_gui_headers ) diff --git a/src/gui/search/searchjobwidget.h b/src/gui/search/searchjobwidget.h index 0f3853db3..9f1fbb83a 100644 --- a/src/gui/search/searchjobwidget.h +++ b/src/gui/search/searchjobwidget.h @@ -38,14 +38,14 @@ class QHeaderView; class QModelIndex; class QStandardItemModel; -template class CachedSettingValue; - class LineEdit; class SearchHandler; class SearchListDelegate; class SearchSortModel; struct SearchResult; +template class CachedSettingValue; + namespace Ui { class SearchJobWidget; diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index de3b29947..49d4ac343 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -137,8 +137,8 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) connect(m_ui->selectPlugin, static_cast(&QComboBox::currentIndexChanged) , this, &SearchWidget::fillCatCombobox); - m_focusSearchHotkey = new QShortcut(QKeySequence::Find, this); - connect(m_focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits); + const auto focusSearchHotkey = new QShortcut(QKeySequence::Find, this); + connect(focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits); } void SearchWidget::fillCatCombobox() diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index cbfbfe321..d692096eb 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -33,7 +33,6 @@ #include #include -class QShortcut; class QTabWidget; class MainWindow; @@ -80,5 +79,4 @@ private: QList m_allTabs; // To store all tabs MainWindow *m_mainWindow; bool m_isNewQueryString; - QShortcut *m_focusSearchHotkey; }; diff --git a/src/gui/torrentcontentmodelfolder.cpp b/src/gui/torrentcontentmodelfolder.cpp index 75870a5ce..89c9147c3 100644 --- a/src/gui/torrentcontentmodelfolder.cpp +++ b/src/gui/torrentcontentmodelfolder.cpp @@ -28,6 +28,8 @@ #include "torrentcontentmodelfolder.h" +#include + #include "base/bittorrent/torrenthandle.h" #include "base/global.h" diff --git a/src/gui/torrentcontentmodelitem.cpp b/src/gui/torrentcontentmodelitem.cpp index bcec140b2..bf136ee83 100644 --- a/src/gui/torrentcontentmodelitem.cpp +++ b/src/gui/torrentcontentmodelitem.cpp @@ -28,6 +28,8 @@ #include "torrentcontentmodelitem.h" +#include + #include "torrentcontentmodelfolder.h" TorrentContentModelItem::TorrentContentModelItem(TorrentContentModelFolder *parent) diff --git a/src/gui/torrentcreatordialog.h b/src/gui/torrentcreatordialog.h index bd94475bf..94e0efdb4 100644 --- a/src/gui/torrentcreatordialog.h +++ b/src/gui/torrentcreatordialog.h @@ -34,14 +34,14 @@ #include "base/settingvalue.h" -namespace Ui +namespace BitTorrent { - class TorrentCreatorDialog; + class TorrentCreatorThread; } -namespace BitTorrent +namespace Ui { - class TorrentCreatorThread; + class TorrentCreatorDialog; } class TorrentCreatorDialog : public QDialog diff --git a/src/gui/transferlistdelegate.h b/src/gui/transferlistdelegate.h index 85587e746..d7db74c7a 100644 --- a/src/gui/transferlistdelegate.h +++ b/src/gui/transferlistdelegate.h @@ -39,7 +39,6 @@ namespace BitTorrent { enum class TorrentState; } -// Defines for download list list columns class TransferListDelegate : public QItemDelegate { diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 7e57dc277..f86a56391 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -186,16 +186,16 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings); connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings); - m_editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent); - m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents); - m_permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents); - m_doubleClickHotkey = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_doubleClickHotkey, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked); - m_recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut); - connect(m_recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents); + const auto *editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent); + const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents); + const auto *permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents); + const auto *doubleClickHotkey = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(doubleClickHotkey, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked); + const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut); + connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents); // This hack fixes reordering of first column with Qt5. // https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777 diff --git a/src/gui/transferlistwidget.h b/src/gui/transferlistwidget.h index 1e626131a..f80e883d3 100644 --- a/src/gui/transferlistwidget.h +++ b/src/gui/transferlistwidget.h @@ -33,18 +33,16 @@ #include #include -namespace BitTorrent -{ - class TorrentHandle; -} - -class QShortcut; - class MainWindow; class TransferListDelegate; class TransferListModel; class TransferListSortModel; +namespace BitTorrent +{ + class TorrentHandle; +} + class TransferListWidget : public QTreeView { Q_OBJECT @@ -128,11 +126,6 @@ private: TransferListModel *m_listModel; TransferListSortModel *m_sortFilterModel; MainWindow *m_mainWindow; - QShortcut *m_editHotkey; - QShortcut *m_deleteHotkey; - QShortcut *m_permDeleteHotkey; - QShortcut *m_doubleClickHotkey; - QShortcut *m_recheckHotkey; }; #endif // TRANSFERLISTWIDGET_H diff --git a/src/webui/CMakeLists.txt b/src/webui/CMakeLists.txt index acfeda8d7..1350691ec 100644 --- a/src/webui/CMakeLists.txt +++ b/src/webui/CMakeLists.txt @@ -3,9 +3,9 @@ add_library(qbt_webui STATIC api/apicontroller.h api/apierror.h api/appcontroller.h -api/isessionmanager.h api/authcontroller.h api/freediskspacechecker.h +api/isessionmanager.h api/logcontroller.h api/rsscontroller.h api/searchcontroller.h