mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Use Qt object ownership to handle QShortcut deletions
This commit is contained in:
parent
662e1e6134
commit
599bfc0735
@ -34,6 +34,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include <QShortcut>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
@ -133,8 +134,8 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
|
|||||||
connect(header(), &QHeaderView::sectionResized, this, &PeerListWidget::saveSettings);
|
connect(header(), &QHeaderView::sectionResized, this, &PeerListWidget::saveSettings);
|
||||||
connect(header(), &QHeaderView::sortIndicatorChanged, this, &PeerListWidget::saveSettings);
|
connect(header(), &QHeaderView::sortIndicatorChanged, this, &PeerListWidget::saveSettings);
|
||||||
handleSortColumnChanged(header()->sortIndicatorSection());
|
handleSortColumnChanged(header()->sortIndicatorSection());
|
||||||
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers);
|
connect(copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers);
|
||||||
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QShortcut>
|
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
@ -92,7 +91,6 @@ private:
|
|||||||
QPointer<Net::ReverseResolution> m_resolver;
|
QPointer<Net::ReverseResolution> m_resolver;
|
||||||
PropertiesWidget *m_properties;
|
PropertiesWidget *m_properties;
|
||||||
bool m_resolveCountries;
|
bool m_resolveCountries;
|
||||||
QShortcut *m_copyHotkey;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PEERLISTWIDGET_H
|
#endif // PEERLISTWIDGET_H
|
||||||
|
@ -149,16 +149,17 @@ PropertiesWidget::PropertiesWidget(QWidget *parent)
|
|||||||
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility);
|
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility);
|
||||||
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings);
|
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings);
|
||||||
|
|
||||||
m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_editHotkeyFile, &QShortcut::activated
|
connect(editHotkeyFile, &QShortcut::activated
|
||||||
, this, [this]() { m_ui->filesList->renameSelectedFile(m_torrent); });
|
, this, [this]() { m_ui->filesList->renameSelectedFile(m_torrent); });
|
||||||
m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_editHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::editWebSeed);
|
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);
|
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();
|
configure();
|
||||||
connect(Preferences::instance(), &Preferences::changed, this, &PropertiesWidget::configure);
|
connect(Preferences::instance(), &Preferences::changed, this, &PropertiesWidget::configure);
|
||||||
@ -175,10 +176,6 @@ PropertiesWidget::~PropertiesWidget()
|
|||||||
delete m_propListModel;
|
delete m_propListModel;
|
||||||
delete m_propListDelegate;
|
delete m_propListDelegate;
|
||||||
delete m_tabBar;
|
delete m_tabBar;
|
||||||
delete m_editHotkeyFile;
|
|
||||||
delete m_editHotkeyWeb;
|
|
||||||
delete m_deleteHotkeyWeb;
|
|
||||||
delete m_openHotkeyFile;
|
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
qDebug() << Q_FUNC_INFO << "EXIT";
|
qDebug() << Q_FUNC_INFO << "EXIT";
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
|
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QShortcut;
|
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
|
|
||||||
class DownloadedPiecesBar;
|
class DownloadedPiecesBar;
|
||||||
@ -121,10 +120,6 @@ private:
|
|||||||
PieceAvailabilityBar *m_piecesAvailability;
|
PieceAvailabilityBar *m_piecesAvailability;
|
||||||
PropTabBar *m_tabBar;
|
PropTabBar *m_tabBar;
|
||||||
LineEdit *m_contentFilterLine;
|
LineEdit *m_contentFilterLine;
|
||||||
QShortcut *m_editHotkeyFile;
|
|
||||||
QShortcut *m_editHotkeyWeb;
|
|
||||||
QShortcut *m_deleteHotkeyWeb;
|
|
||||||
QShortcut *m_openHotkeyFile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PROPERTIESWIDGET_H
|
#endif // PROPERTIESWIDGET_H
|
||||||
|
@ -121,12 +121,12 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
|
|||||||
connect(m_ui->listRules, &QListWidget::itemSelectionChanged, this, &AutomatedRssDownloader::updateRuleDefinitionBox);
|
connect(m_ui->listRules, &QListWidget::itemSelectionChanged, this, &AutomatedRssDownloader::updateRuleDefinitionBox);
|
||||||
connect(m_ui->listRules, &QListWidget::itemChanged, this, &AutomatedRssDownloader::handleRuleCheckStateChange);
|
connect(m_ui->listRules, &QListWidget::itemChanged, this, &AutomatedRssDownloader::handleRuleCheckStateChange);
|
||||||
|
|
||||||
m_editHotkey = new QShortcut(Qt::Key_F2, m_ui->listRules, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *editHotkey = new QShortcut(Qt::Key_F2, m_ui->listRules, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_editHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::renameSelectedRule);
|
connect(editHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::renameSelectedRule);
|
||||||
connect(m_ui->listRules, &QAbstractItemView::doubleClicked, 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_ui->listRules, &QAbstractItemView::doubleClicked, this, &AutomatedRssDownloader::renameSelectedRule);
|
||||||
connect(m_deleteHotkey, &QShortcut::activated, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
|
|
||||||
|
|
||||||
loadFeedList();
|
loadFeedList();
|
||||||
|
|
||||||
@ -149,8 +149,6 @@ AutomatedRssDownloader::~AutomatedRssDownloader()
|
|||||||
saveEditedRule();
|
saveEditedRule();
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
delete m_editHotkey;
|
|
||||||
delete m_deleteHotkey;
|
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
delete m_episodeRegex;
|
delete m_episodeRegex;
|
||||||
}
|
}
|
||||||
|
@ -37,20 +37,19 @@
|
|||||||
|
|
||||||
#include "base/rss/rss_autodownloadrule.h"
|
#include "base/rss/rss_autodownloadrule.h"
|
||||||
|
|
||||||
namespace Ui
|
|
||||||
{
|
|
||||||
class AutomatedRssDownloader;
|
|
||||||
}
|
|
||||||
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class QRegularExpression;
|
class QRegularExpression;
|
||||||
class QShortcut;
|
|
||||||
|
|
||||||
namespace RSS
|
namespace RSS
|
||||||
{
|
{
|
||||||
class Feed;
|
class Feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class AutomatedRssDownloader;
|
||||||
|
}
|
||||||
|
|
||||||
class AutomatedRssDownloader : public QDialog
|
class AutomatedRssDownloader : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -102,8 +101,6 @@ private:
|
|||||||
|
|
||||||
Ui::AutomatedRssDownloader *m_ui;
|
Ui::AutomatedRssDownloader *m_ui;
|
||||||
QListWidgetItem *m_currentRuleItem;
|
QListWidgetItem *m_currentRuleItem;
|
||||||
QShortcut *m_editHotkey;
|
|
||||||
QShortcut *m_deleteHotkey;
|
|
||||||
QSet<QPair<QString, QString>> m_treeListEntries;
|
QSet<QPair<QString, QString>> m_treeListEntries;
|
||||||
RSS::AutoDownloadRule m_currentRule;
|
RSS::AutoDownloadRule m_currentRule;
|
||||||
QHash<QString, QListWidgetItem *> m_itemsByRuleName;
|
QHash<QString, QListWidgetItem *> m_itemsByRuleName;
|
||||||
|
@ -93,10 +93,10 @@ RSSWidget::RSSWidget(QWidget *parent)
|
|||||||
loadFoldersOpenState();
|
loadFoldersOpenState();
|
||||||
m_feedListWidget->setCurrentItem(m_feedListWidget->stickyUnreadItem());
|
m_feedListWidget->setCurrentItem(m_feedListWidget->stickyUnreadItem());
|
||||||
|
|
||||||
m_editHotkey = new QShortcut(Qt::Key_F2, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *editHotkey = new QShortcut(Qt::Key_F2, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_editHotkey, &QShortcut::activated, this, &RSSWidget::renameSelectedRSSItem);
|
connect(editHotkey, &QShortcut::activated, this, &RSSWidget::renameSelectedRSSItem);
|
||||||
m_deleteHotkey = new QShortcut(QKeySequence::Delete, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, m_feedListWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_deleteHotkey, &QShortcut::activated, this, &RSSWidget::deleteSelectedItems);
|
connect(deleteHotkey, &QShortcut::activated, this, &RSSWidget::deleteSelectedItems);
|
||||||
|
|
||||||
// Feeds list actions
|
// Feeds list actions
|
||||||
connect(m_ui->actionDelete, &QAction::triggered, this, &RSSWidget::deleteSelectedItems);
|
connect(m_ui->actionDelete, &QAction::triggered, this, &RSSWidget::deleteSelectedItems);
|
||||||
@ -135,8 +135,6 @@ RSSWidget::~RSSWidget()
|
|||||||
|
|
||||||
saveFoldersOpenState();
|
saveFoldersOpenState();
|
||||||
|
|
||||||
delete m_editHotkey;
|
|
||||||
delete m_deleteHotkey;
|
|
||||||
delete m_feedListWidget;
|
delete m_feedListWidget;
|
||||||
delete m_ui;
|
delete m_ui;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class QShortcut;
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
class ArticleListWidget;
|
class ArticleListWidget;
|
||||||
@ -86,8 +85,6 @@ private:
|
|||||||
Ui::RSSWidget *m_ui;
|
Ui::RSSWidget *m_ui;
|
||||||
ArticleListWidget *m_articleListWidget;
|
ArticleListWidget *m_articleListWidget;
|
||||||
FeedListWidget *m_feedListWidget;
|
FeedListWidget *m_feedListWidget;
|
||||||
QShortcut *m_editHotkey;
|
|
||||||
QShortcut *m_deleteHotkey;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RSSWIDGET_H
|
#endif // RSSWIDGET_H
|
||||||
|
@ -137,8 +137,8 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
|||||||
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
|
||||||
, this, &SearchWidget::fillCatCombobox);
|
, this, &SearchWidget::fillCatCombobox);
|
||||||
|
|
||||||
m_focusSearchHotkey = new QShortcut(QKeySequence::Find, this);
|
const auto focusSearchHotkey = new QShortcut(QKeySequence::Find, this);
|
||||||
connect(m_focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits);
|
connect(focusSearchHotkey, &QShortcut::activated, this, &SearchWidget::toggleFocusBetweenLineEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchWidget::fillCatCombobox()
|
void SearchWidget::fillCatCombobox()
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QShortcut;
|
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@ -80,5 +79,4 @@ private:
|
|||||||
QList<SearchJobWidget *> m_allTabs; // To store all tabs
|
QList<SearchJobWidget *> m_allTabs; // To store all tabs
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
bool m_isNewQueryString;
|
bool m_isNewQueryString;
|
||||||
QShortcut *m_focusSearchHotkey;
|
|
||||||
};
|
};
|
||||||
|
@ -186,16 +186,16 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow)
|
|||||||
connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings);
|
connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings);
|
||||||
connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings);
|
connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings);
|
||||||
|
|
||||||
m_editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent);
|
connect(editHotkey, &QShortcut::activated, this, &TransferListWidget::renameSelectedTorrent);
|
||||||
m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents);
|
connect(deleteHotkey, &QShortcut::activated, this, &TransferListWidget::softDeleteSelectedTorrents);
|
||||||
m_permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents);
|
connect(permDeleteHotkey, &QShortcut::activated, this, &TransferListWidget::permDeleteSelectedTorrents);
|
||||||
m_doubleClickHotkey = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *doubleClickHotkey = new QShortcut(Qt::Key_Return, this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_doubleClickHotkey, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
|
connect(doubleClickHotkey, &QShortcut::activated, this, &TransferListWidget::torrentDoubleClicked);
|
||||||
m_recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut);
|
const auto *recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, nullptr, nullptr, Qt::WidgetShortcut);
|
||||||
connect(m_recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents);
|
connect(recheckHotkey, &QShortcut::activated, this, &TransferListWidget::recheckSelectedTorrents);
|
||||||
|
|
||||||
// This hack fixes reordering of first column with Qt5.
|
// This hack fixes reordering of first column with Qt5.
|
||||||
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
|
||||||
|
@ -38,8 +38,6 @@ namespace BitTorrent
|
|||||||
class TorrentHandle;
|
class TorrentHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QShortcut;
|
|
||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class TransferListDelegate;
|
class TransferListDelegate;
|
||||||
class TransferListModel;
|
class TransferListModel;
|
||||||
@ -128,11 +126,6 @@ private:
|
|||||||
TransferListModel *m_listModel;
|
TransferListModel *m_listModel;
|
||||||
TransferListSortModel *m_sortFilterModel;
|
TransferListSortModel *m_sortFilterModel;
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
QShortcut *m_editHotkey;
|
|
||||||
QShortcut *m_deleteHotkey;
|
|
||||||
QShortcut *m_permDeleteHotkey;
|
|
||||||
QShortcut *m_doubleClickHotkey;
|
|
||||||
QShortcut *m_recheckHotkey;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRANSFERLISTWIDGET_H
|
#endif // TRANSFERLISTWIDGET_H
|
||||||
|
Loading…
Reference in New Issue
Block a user