mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-06 15:04:34 +08:00
Merge pull request #6294 from thalieht/hotkeys
Add hotkeys for some things. Closes #2090
This commit is contained in:
commit
f6a941defc
@ -117,7 +117,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
|
||||
// Signal / slots
|
||||
connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool)));
|
||||
connect(ui->doNotDeleteTorrentCheckBox, SIGNAL(clicked(bool)), SLOT(doNotDeleteTorrentClicked(bool)));
|
||||
editHotkey = new QShortcut(QKeySequence("F2"), ui->contentTreeView, 0, 0, Qt::WidgetShortcut);
|
||||
editHotkey = new QShortcut(Qt::Key_F2, ui->contentTreeView, 0, 0, Qt::WidgetShortcut);
|
||||
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile()));
|
||||
connect(ui->contentTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile()));
|
||||
|
||||
|
@ -758,31 +758,33 @@ void MainWindow::createKeyboardShortcuts()
|
||||
{
|
||||
m_ui->actionCreateTorrent->setShortcut(QKeySequence::New);
|
||||
m_ui->actionOpen->setShortcut(QKeySequence::Open);
|
||||
m_ui->actionDownloadFromURL->setShortcut(QKeySequence("Ctrl+Shift+O"));
|
||||
m_ui->actionExit->setShortcut(QKeySequence("Ctrl+Q"));
|
||||
m_ui->actionDownloadFromURL->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_O);
|
||||
m_ui->actionExit->setShortcut(Qt::CTRL + Qt::Key_Q);
|
||||
|
||||
QShortcut *switchTransferShortcut = new QShortcut(QKeySequence("Alt+1"), this);
|
||||
QShortcut *switchTransferShortcut = new QShortcut(Qt::ALT + Qt::Key_1, this);
|
||||
connect(switchTransferShortcut, SIGNAL(activated()), this, SLOT(displayTransferTab()));
|
||||
QShortcut *switchSearchShortcut = new QShortcut(QKeySequence("Alt+2"), this);
|
||||
QShortcut *switchSearchShortcut = new QShortcut(Qt::ALT + Qt::Key_2, this);
|
||||
connect(switchSearchShortcut, SIGNAL(activated()), this, SLOT(displaySearchTab()));
|
||||
QShortcut *switchRSSShortcut = new QShortcut(QKeySequence("Alt+3"), this);
|
||||
QShortcut *switchRSSShortcut = new QShortcut(Qt::ALT + Qt::Key_3, this);
|
||||
connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab()));
|
||||
QShortcut *switchExecutionLogShortcut = new QShortcut(Qt::ALT + Qt::Key_4, this);
|
||||
connect(switchExecutionLogShortcut, SIGNAL(activated()), this, SLOT(displayExecutionLogTab()));
|
||||
|
||||
QShortcut *switchSearchFilterShortcut = new QShortcut(QKeySequence::Find, this);
|
||||
connect(switchSearchFilterShortcut, SIGNAL(activated()), this, SLOT(focusSearchFilter()));
|
||||
|
||||
m_ui->actionDocumentation->setShortcut(QKeySequence::HelpContents);
|
||||
m_ui->actionOptions->setShortcut(QKeySequence("Alt+O"));
|
||||
m_ui->actionStart->setShortcut(QKeySequence("Ctrl+S"));
|
||||
m_ui->actionStartAll->setShortcut(QKeySequence("Ctrl+Shift+S"));
|
||||
m_ui->actionPause->setShortcut(QKeySequence("Ctrl+P"));
|
||||
m_ui->actionPauseAll->setShortcut(QKeySequence("Ctrl+Shift+P"));
|
||||
m_ui->actionBottomPriority->setShortcut(QKeySequence("Ctrl+Shift+-"));
|
||||
m_ui->actionDecreasePriority->setShortcut(QKeySequence("Ctrl+-"));
|
||||
m_ui->actionIncreasePriority->setShortcut(QKeySequence("Ctrl++"));
|
||||
m_ui->actionTopPriority->setShortcut(QKeySequence("Ctrl+Shift++"));
|
||||
m_ui->actionOptions->setShortcut(Qt::ALT + Qt::Key_O);
|
||||
m_ui->actionStart->setShortcut(Qt::CTRL + Qt::Key_S);
|
||||
m_ui->actionStartAll->setShortcut(Qt::CTRL + Qt::SHIFT +Qt::Key_S);
|
||||
m_ui->actionPause->setShortcut(Qt::CTRL + Qt::Key_P);
|
||||
m_ui->actionPauseAll->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_P);
|
||||
m_ui->actionBottomPriority->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Minus);
|
||||
m_ui->actionDecreasePriority->setShortcut(Qt::CTRL + Qt::Key_Minus);
|
||||
m_ui->actionIncreasePriority->setShortcut(Qt::CTRL + Qt::Key_Plus);
|
||||
m_ui->actionTopPriority->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Plus);
|
||||
#ifdef Q_OS_MAC
|
||||
m_ui->actionMinimize->setShortcut(QKeySequence("Ctrl+M"));
|
||||
m_ui->actionMinimize->setShortcut(Qt::CTRL + Qt::Key_M);
|
||||
addAction(m_ui->actionMinimize);
|
||||
#endif
|
||||
}
|
||||
@ -793,16 +795,34 @@ void MainWindow::displayTransferTab() const
|
||||
m_tabs->setCurrentWidget(m_transferListWidget);
|
||||
}
|
||||
|
||||
void MainWindow::displaySearchTab() const
|
||||
void MainWindow::displaySearchTab()
|
||||
{
|
||||
if (m_searchWidget)
|
||||
m_tabs->setCurrentWidget(m_searchWidget);
|
||||
if (!m_searchWidget) {
|
||||
m_ui->actionSearchWidget->setChecked(true);
|
||||
displaySearchTab(true);
|
||||
}
|
||||
|
||||
m_tabs->setCurrentWidget(m_searchWidget);
|
||||
}
|
||||
|
||||
void MainWindow::displayRSSTab() const
|
||||
void MainWindow::displayRSSTab()
|
||||
{
|
||||
if (m_rssWidget)
|
||||
m_tabs->setCurrentWidget(m_rssWidget);
|
||||
if (!m_rssWidget) {
|
||||
m_ui->actionRSSReader->setChecked(true);
|
||||
displayRSSTab(true);
|
||||
}
|
||||
|
||||
m_tabs->setCurrentWidget(m_rssWidget);
|
||||
}
|
||||
|
||||
void MainWindow::displayExecutionLogTab()
|
||||
{
|
||||
if (!m_executionLog) {
|
||||
m_ui->actionExecutionLogs->setChecked(true);
|
||||
on_actionExecutionLogs_triggered(true);
|
||||
}
|
||||
|
||||
m_tabs->setCurrentWidget(m_executionLog);
|
||||
}
|
||||
|
||||
// End of keyboard shortcuts slots
|
||||
|
@ -124,8 +124,9 @@ private slots:
|
||||
// Keyboard shortcuts
|
||||
void createKeyboardShortcuts();
|
||||
void displayTransferTab() const;
|
||||
void displaySearchTab() const;
|
||||
void displayRSSTab() const;
|
||||
void displaySearchTab();
|
||||
void displayRSSTab();
|
||||
void displayExecutionLogTab();
|
||||
void focusSearchFilter();
|
||||
void updateGUI();
|
||||
void loadPreferences(bool configureSession = true);
|
||||
|
@ -159,14 +159,14 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *main_window, Tra
|
||||
refreshTimer = new QTimer(this);
|
||||
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
|
||||
refreshTimer->start(3000); // 3sec
|
||||
editHotkeyFile = new QShortcut(QKeySequence("F2"), filesList, 0, 0, Qt::WidgetShortcut);
|
||||
editHotkeyFile = new QShortcut(Qt::Key_F2, filesList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile()));
|
||||
editHotkeyWeb = new QShortcut(QKeySequence("F2"), listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
editHotkeyWeb = new QShortcut(Qt::Key_F2, listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed()));
|
||||
connect(listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed()));
|
||||
deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, listWebSeeds, 0, 0, Qt::WidgetShortcut);
|
||||
connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds()));
|
||||
openHotkeyFile = new QShortcut(QKeySequence("Return"), filesList, 0, 0, Qt::WidgetShortcut);
|
||||
openHotkeyFile = new QShortcut(Qt::Key_Return, filesList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile()));
|
||||
}
|
||||
|
||||
|
@ -44,29 +44,34 @@ PropTabBar::PropTabBar(QWidget *parent) :
|
||||
m_btnGroup = new QButtonGroup(this);
|
||||
// General tab
|
||||
QPushButton *main_infos_button = new QPushButton(GuiIconProvider::instance()->getIcon("document-properties"), tr("General"), parent);
|
||||
main_infos_button->setShortcut(QKeySequence(QString::fromUtf8("Alt+P")));
|
||||
main_infos_button->setShortcut(Qt::ALT + Qt::Key_G);
|
||||
addWidget(main_infos_button);
|
||||
m_btnGroup->addButton(main_infos_button, MAIN_TAB);
|
||||
// Trackers tab
|
||||
QPushButton *trackers_button = new QPushButton(GuiIconProvider::instance()->getIcon("network-server"), tr("Trackers"), parent);
|
||||
trackers_button->setShortcut(Qt::ALT + Qt::Key_C);
|
||||
addWidget(trackers_button);
|
||||
m_btnGroup->addButton(trackers_button, TRACKERS_TAB);
|
||||
// Peers tab
|
||||
QPushButton *peers_button = new QPushButton(GuiIconProvider::instance()->getIcon("edit-find-user"), tr("Peers"), parent);
|
||||
peers_button->setShortcut(Qt::ALT + Qt::Key_R);
|
||||
addWidget(peers_button);
|
||||
m_btnGroup->addButton(peers_button, PEERS_TAB);
|
||||
// URL seeds tab
|
||||
QPushButton *urlseeds_button = new QPushButton(GuiIconProvider::instance()->getIcon("network-server"), tr("HTTP Sources"), parent);
|
||||
urlseeds_button->setShortcut(Qt::ALT + Qt::Key_B);
|
||||
addWidget(urlseeds_button);
|
||||
m_btnGroup->addButton(urlseeds_button, URLSEEDS_TAB);
|
||||
// Files tab
|
||||
QPushButton *files_button = new QPushButton(GuiIconProvider::instance()->getIcon("inode-directory"), tr("Content"), parent);
|
||||
files_button->setShortcut(Qt::ALT + Qt::Key_Z);
|
||||
addWidget(files_button);
|
||||
m_btnGroup->addButton(files_button, FILES_TAB);
|
||||
// Spacer
|
||||
addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
// Speed tab
|
||||
QPushButton *speed_button = new QPushButton(GuiIconProvider::instance()->getIcon("office-chart-line"), tr("Speed"), parent);
|
||||
speed_button->setShortcut(Qt::ALT + Qt::Key_D);
|
||||
addWidget(speed_button);
|
||||
m_btnGroup->addButton(speed_button, SPEED_TAB);
|
||||
// SIGNAL/SLOT
|
||||
|
@ -83,9 +83,9 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
|
||||
lsd_item = new QTreeWidgetItem(QStringList() << "" << "** [LSD] **" << "" << "" << "0" << "0" << "0");
|
||||
insertTopLevelItem(2, lsd_item);
|
||||
setRowColor(2, QColor("grey"));
|
||||
editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(editSelectedTracker()), 0, Qt::WidgetShortcut);
|
||||
editHotkey = new QShortcut(Qt::Key_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);
|
||||
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), 0, Qt::WidgetShortcut);
|
||||
copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), 0, Qt::WidgetShortcut);
|
||||
|
||||
#ifdef QBT_USES_QT5
|
||||
|
@ -115,7 +115,7 @@ AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<Rss::Manager>
|
||||
Q_ASSERT(ok);
|
||||
ok = connect(ui->lineEFilter, SIGNAL(textEdited(QString)), SLOT(updateMatchingArticles()));
|
||||
Q_ASSERT(ok);
|
||||
editHotkey = new QShortcut(QKeySequence("F2"), ui->listRules, 0, 0, Qt::WidgetShortcut);
|
||||
editHotkey = new QShortcut(Qt::Key_F2, ui->listRules, 0, 0, Qt::WidgetShortcut);
|
||||
ok = connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRule()));
|
||||
Q_ASSERT(ok);
|
||||
ok = connect(ui->listRules, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRule()));
|
||||
|
@ -706,7 +706,7 @@ RSSImp::RSSImp(QWidget *parent)
|
||||
|
||||
m_feedList = new FeedListWidget(splitterSide, m_rssManager);
|
||||
splitterSide->insertWidget(0, m_feedList);
|
||||
editHotkey = new QShortcut(QKeySequence("F2"), m_feedList, 0, 0, Qt::WidgetShortcut);
|
||||
editHotkey = new QShortcut(Qt::Key_F2, m_feedList, 0, 0, Qt::WidgetShortcut);
|
||||
connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedRssFile()));
|
||||
connect(m_feedList, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedRssFile()));
|
||||
deleteHotkey = new QShortcut(QKeySequence::Delete, m_feedList, 0, 0, Qt::WidgetShortcut);
|
||||
|
@ -147,7 +147,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window)
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
// Listen for list events
|
||||
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(torrentDoubleClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(torrentDoubleClicked()));
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayListMenu(const QPoint &)));
|
||||
header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(header(), SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(displayDLHoSMenu(const QPoint &)));
|
||||
@ -155,9 +155,11 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window)
|
||||
connect(header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings()));
|
||||
connect(header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings()));
|
||||
|
||||
editHotkey = new QShortcut(QKeySequence("F2"), this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut);
|
||||
editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(renameSelectedTorrent()), 0, Qt::WidgetShortcut);
|
||||
deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(softDeleteSelectedTorrents()), 0, Qt::WidgetShortcut);
|
||||
permDeleteHotkey = new QShortcut(QKeySequence("Shift+Delete"), this, SLOT(permDeleteSelectedTorrents()), 0, Qt::WidgetShortcut);
|
||||
permDeleteHotkey = new QShortcut(Qt::SHIFT + Qt::Key_Delete, this, SLOT(permDeleteSelectedTorrents()), 0, Qt::WidgetShortcut);
|
||||
doubleClickHotkey = new QShortcut(Qt::Key_Return, this, SLOT(torrentDoubleClicked()), 0, Qt::WidgetShortcut);
|
||||
recheckHotkey = new QShortcut(Qt::CTRL + Qt::Key_R, this, SLOT(recheckSelectedTorrents()), 0, Qt::WidgetShortcut);
|
||||
|
||||
#ifdef QBT_USES_QT5
|
||||
// This hack fixes reordering of first column with Qt5.
|
||||
@ -208,9 +210,13 @@ inline QModelIndex TransferListWidget::mapFromSource(const QModelIndex &index) c
|
||||
return nameFilterModel->mapFromSource(index);
|
||||
}
|
||||
|
||||
void TransferListWidget::torrentDoubleClicked(const QModelIndex& index)
|
||||
void TransferListWidget::torrentDoubleClicked()
|
||||
{
|
||||
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(mapToSource(index));
|
||||
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return;
|
||||
|
||||
const QModelIndex index = listModel->index(mapToSource(selectedIndexes.first()).row());
|
||||
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(index);
|
||||
if (!torrent) return;
|
||||
|
||||
int action;
|
||||
@ -327,8 +333,8 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles)
|
||||
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
|
||||
if (torrents.empty()) return;
|
||||
|
||||
if (Preferences::instance()->confirmTorrentDeletion() &&
|
||||
!DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
if (Preferences::instance()->confirmTorrentDeletion()
|
||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
return;
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||
@ -343,8 +349,8 @@ void TransferListWidget::deleteVisibleTorrents()
|
||||
torrents << listModel->torrentHandle(mapToSource(nameFilterModel->index(i, 0)));
|
||||
|
||||
bool deleteLocalFiles = false;
|
||||
if (Preferences::instance()->confirmTorrentDeletion() &&
|
||||
!DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
if (Preferences::instance()->confirmTorrentDeletion()
|
||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
return;
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||
@ -603,8 +609,7 @@ void TransferListWidget::askNewCategoryForSelection()
|
||||
void TransferListWidget::renameSelectedTorrent()
|
||||
{
|
||||
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
if (selectedIndexes.size() != 1) return;
|
||||
if (!selectedIndexes.first().isValid()) return;
|
||||
if ((selectedIndexes.size() != 1) || !selectedIndexes.first().isValid()) return;
|
||||
|
||||
const QModelIndex mi = listModel->index(mapToSource(selectedIndexes.first()).row(), TorrentModel::TR_NAME);
|
||||
BitTorrent::TorrentHandle *const torrent = listModel->torrentHandle(mi);
|
||||
@ -629,8 +634,8 @@ void TransferListWidget::setSelectionCategory(QString category)
|
||||
void TransferListWidget::displayListMenu(const QPoint&)
|
||||
{
|
||||
QModelIndexList selectedIndexes = selectionModel()->selectedRows();
|
||||
if (selectedIndexes.size() == 0)
|
||||
return;
|
||||
if (selectedIndexes.size() == 0) return;
|
||||
|
||||
// Create actions
|
||||
QAction actionStart(GuiIconProvider::instance()->getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), 0);
|
||||
connect(&actionStart, SIGNAL(triggered()), this, SLOT(startSelectedTorrents()));
|
||||
@ -928,7 +933,7 @@ void TransferListWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
event->accept();
|
||||
|
||||
if(event->modifiers() & Qt::ShiftModifier) {
|
||||
if (event->modifiers() & Qt::ShiftModifier) {
|
||||
// Shift + scroll = horizontal scroll
|
||||
QWheelEvent scrollHEvent(event->pos(), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), Qt::Horizontal);
|
||||
QTreeView::wheelEvent(&scrollHEvent);
|
||||
|
@ -101,7 +101,7 @@ protected:
|
||||
QList<BitTorrent::TorrentHandle *> getSelectedTorrents() const;
|
||||
|
||||
protected slots:
|
||||
void torrentDoubleClicked(const QModelIndex& index);
|
||||
void torrentDoubleClicked();
|
||||
void displayListMenu(const QPoint&);
|
||||
void currentChanged(const QModelIndex& current, const QModelIndex&);
|
||||
void toggleSelectedTorrentsSuperSeeding() const;
|
||||
@ -124,6 +124,8 @@ private:
|
||||
QShortcut *editHotkey;
|
||||
QShortcut *deleteHotkey;
|
||||
QShortcut *permDeleteHotkey;
|
||||
QShortcut *doubleClickHotkey;
|
||||
QShortcut *recheckHotkey;
|
||||
};
|
||||
|
||||
#endif // TRANSFERLISTWIDGET_H
|
||||
|
Loading…
Reference in New Issue
Block a user