Browse Source

Use Qt object ownership to handle QShortcut deletions

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
599bfc0735
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 5
      src/gui/properties/peerlistwidget.cpp
  2. 2
      src/gui/properties/peerlistwidget.h
  3. 21
      src/gui/properties/propertieswidget.cpp
  4. 5
      src/gui/properties/propertieswidget.h
  5. 12
      src/gui/rss/automatedrssdownloader.cpp
  6. 13
      src/gui/rss/automatedrssdownloader.h
  7. 10
      src/gui/rss/rsswidget.cpp
  8. 3
      src/gui/rss/rsswidget.h
  9. 4
      src/gui/search/searchwidget.cpp
  10. 2
      src/gui/search/searchwidget.h
  11. 20
      src/gui/transferlistwidget.cpp
  12. 7
      src/gui/transferlistwidget.h

5
src/gui/properties/peerlistwidget.cpp

@ -34,6 +34,7 @@ @@ -34,6 +34,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QSet>
#include <QShortcut>
#include <QSortFilterProxyModel>
#include <QStandardItemModel>
#include <QTableView>
@ -133,8 +134,8 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent) @@ -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

2
src/gui/properties/peerlistwidget.h

@ -32,7 +32,6 @@ @@ -32,7 +32,6 @@
#include <QHash>
#include <QPointer>
#include <QSet>
#include <QShortcut>
#include <QTreeView>
class QSortFilterProxyModel;
@ -92,7 +91,6 @@ private: @@ -92,7 +91,6 @@ private:
QPointer<Net::ReverseResolution> m_resolver;
PropertiesWidget *m_properties;
bool m_resolveCountries;
QShortcut *m_copyHotkey;
};
#endif // PEERLISTWIDGET_H

21
src/gui/properties/propertieswidget.cpp

@ -149,16 +149,17 @@ PropertiesWidget::PropertiesWidget(QWidget *parent) @@ -149,16 +149,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 +176,6 @@ PropertiesWidget::~PropertiesWidget() @@ -175,10 +176,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";
}

5
src/gui/properties/propertieswidget.h

@ -35,7 +35,6 @@ @@ -35,7 +35,6 @@
#include "base/bittorrent/torrenthandle.h"
class QPushButton;
class QShortcut;
class QTreeView;
class DownloadedPiecesBar;
@ -121,10 +120,6 @@ private: @@ -121,10 +120,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

12
src/gui/rss/automatedrssdownloader.cpp

@ -121,12 +121,12 @@ AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) @@ -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() @@ -149,8 +149,6 @@ AutomatedRssDownloader::~AutomatedRssDownloader()
saveEditedRule();
saveSettings();
delete m_editHotkey;
delete m_deleteHotkey;
delete m_ui;
delete m_episodeRegex;
}

13
src/gui/rss/automatedrssdownloader.h

@ -37,20 +37,19 @@ @@ -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: @@ -102,8 +101,6 @@ private:
Ui::AutomatedRssDownloader *m_ui;
QListWidgetItem *m_currentRuleItem;
QShortcut *m_editHotkey;
QShortcut *m_deleteHotkey;
QSet<QPair<QString, QString>> m_treeListEntries;
RSS::AutoDownloadRule m_currentRule;
QHash<QString, QListWidgetItem *> m_itemsByRuleName;

10
src/gui/rss/rsswidget.cpp

@ -93,10 +93,10 @@ RSSWidget::RSSWidget(QWidget *parent) @@ -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() @@ -135,8 +135,6 @@ RSSWidget::~RSSWidget()
saveFoldersOpenState();
delete m_editHotkey;
delete m_deleteHotkey;
delete m_feedListWidget;
delete m_ui;
}

3
src/gui/rss/rsswidget.h

@ -34,7 +34,6 @@ @@ -34,7 +34,6 @@
#include <QWidget>
class QListWidgetItem;
class QShortcut;
class QTreeWidgetItem;
class ArticleListWidget;
@ -86,8 +85,6 @@ private: @@ -86,8 +85,6 @@ private:
Ui::RSSWidget *m_ui;
ArticleListWidget *m_articleListWidget;
FeedListWidget *m_feedListWidget;
QShortcut *m_editHotkey;
QShortcut *m_deleteHotkey;
};
#endif // RSSWIDGET_H

4
src/gui/search/searchwidget.cpp

@ -137,8 +137,8 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) @@ -137,8 +137,8 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
connect(m_ui->selectPlugin, static_cast<void (QComboBox::*)(int)>(&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()

2
src/gui/search/searchwidget.h

@ -33,7 +33,6 @@ @@ -33,7 +33,6 @@
#include <QPointer>
#include <QWidget>
class QShortcut;
class QTabWidget;
class MainWindow;
@ -80,5 +79,4 @@ private: @@ -80,5 +79,4 @@ private:
QList<SearchJobWidget *> m_allTabs; // To store all tabs
MainWindow *m_mainWindow;
bool m_isNewQueryString;
QShortcut *m_focusSearchHotkey;
};

20
src/gui/transferlistwidget.cpp

@ -186,16 +186,16 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) @@ -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

7
src/gui/transferlistwidget.h

@ -38,8 +38,6 @@ namespace BitTorrent @@ -38,8 +38,6 @@ namespace BitTorrent
class TorrentHandle;
}
class QShortcut;
class MainWindow;
class TransferListDelegate;
class TransferListModel;
@ -128,11 +126,6 @@ private: @@ -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

Loading…
Cancel
Save