From 107906928a72f92ddc1a752af557758d38e75aba Mon Sep 17 00:00:00 2001 From: Nick Tiskov Date: Mon, 22 Jul 2013 21:48:55 +0400 Subject: [PATCH] Enable delete hotkey in web seed and tracker list. Make delete hotkey in transfer list non-global. --- src/mainwindow.cpp | 5 ----- src/properties/propertieswidget.cpp | 7 ++++++- src/properties/propertieswidget.h | 1 + src/properties/trackerlist.cpp | 2 ++ src/properties/trackerlist.h | 1 + src/transferlistwidget.cpp | 2 ++ src/transferlistwidget.h | 1 + 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fc1caaefc..ae1c81b74 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -557,11 +557,6 @@ void MainWindow::createKeyboardShortcuts() { connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab())); actionDocumentation->setShortcut(QKeySequence("F1")); actionOptions->setShortcut(QKeySequence(QString::fromUtf8("Alt+O"))); -#ifdef Q_WS_MAC - actionDelete->setShortcut(QKeySequence("Ctrl+Backspace")); -#else - actionDelete->setShortcut(QKeySequence(QString::fromUtf8("Del"))); -#endif actionStart->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+S"))); actionStart_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+S"))); actionPause->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+P"))); diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index 05e9d7b93..9e1840d21 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -124,6 +124,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra editHotkeyWeb = new QShortcut(QKeySequence("F2"), listWebSeeds, 0, 0, Qt::WidgetShortcut); connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed())); connect(listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed())); + deleteHotkeyWeb = new QShortcut(QKeySequence(QKeySequence::Delete), listWebSeeds, 0, 0, Qt::WidgetShortcut); + connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds())); } PropertiesWidget::~PropertiesWidget() { @@ -138,6 +140,7 @@ PropertiesWidget::~PropertiesWidget() { delete m_tabBar; delete editHotkeyFile; delete editHotkeyWeb; + delete deleteHotkeyWeb; qDebug() << Q_FUNC_INFO << "EXIT"; } @@ -663,6 +666,8 @@ void PropertiesWidget::askWebSeed() { void PropertiesWidget::deleteSelectedUrlSeeds() { const QList selectedItems = listWebSeeds->selectedItems(); + if (selectedItems.isEmpty()) + return; bool change = false; foreach (const QListWidgetItem *item, selectedItems) { QString url_seed = item->text(); @@ -691,7 +696,7 @@ void PropertiesWidget::copySelectedWebSeedsToClipboard() const { void PropertiesWidget::editWebSeed() { const QList selected_items = listWebSeeds->selectedItems(); - if (selected_items.isEmpty()) + if (selected_items.size() != 1) return; const QListWidgetItem *selected_item = selected_items.last(); diff --git a/src/properties/propertieswidget.h b/src/properties/propertieswidget.h index 0ea4738d6..65d3b41ea 100644 --- a/src/properties/propertieswidget.h +++ b/src/properties/propertieswidget.h @@ -115,6 +115,7 @@ private: LineEdit *m_contentFilerLine; QShortcut *editHotkeyFile; QShortcut *editHotkeyWeb; + QShortcut *deleteHotkeyWeb; }; #endif // PROPERTIESWIDGET_H diff --git a/src/properties/trackerlist.cpp b/src/properties/trackerlist.cpp index 68fbf2cf4..b4096fb5c 100644 --- a/src/properties/trackerlist.cpp +++ b/src/properties/trackerlist.cpp @@ -77,12 +77,14 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie setRowColor(2, QColor("grey")); editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut); connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(editSelectedTracker())); + deleteHotkey = new QShortcut(QKeySequence(QKeySequence::Delete), this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut); loadSettings(); } TrackerList::~TrackerList() { delete editHotkey; + delete deleteHotkey; saveSettings(); } diff --git a/src/properties/trackerlist.h b/src/properties/trackerlist.h index e0c71ac6f..580aa3f38 100644 --- a/src/properties/trackerlist.h +++ b/src/properties/trackerlist.h @@ -54,6 +54,7 @@ private: QTreeWidgetItem* pex_item; QTreeWidgetItem* lsd_item; QShortcut *editHotkey; + QShortcut *deleteHotkey; public: TrackerList(PropertiesWidget *properties); diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index bb3a6a5ad..f8e4bca15 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -143,6 +143,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&))); editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut); + deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTorrents()), 0, Qt::WidgetShortcut); } TransferListWidget::~TransferListWidget() { @@ -156,6 +157,7 @@ TransferListWidget::~TransferListWidget() { delete listModel; delete listDelegate; delete editHotkey; + delete deleteHotkey; qDebug() << Q_FUNC_INFO << "EXIT"; } diff --git a/src/transferlistwidget.h b/src/transferlistwidget.h index 8a4dbd2cd..7b817ed17 100644 --- a/src/transferlistwidget.h +++ b/src/transferlistwidget.h @@ -118,6 +118,7 @@ private: QBtSession* BTSession; MainWindow *main_window; QShortcut *editHotkey; + QShortcut *deleteHotkey; }; #endif // TRANSFERLISTWIDGET_H