From 99959b1aa359ba4f80c59028dc73fbfdb2636a3f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Thu, 19 Jul 2007 12:58:45 +0000 Subject: [PATCH] - Added keyboard shortcuts for main actions (thanks Alexander Kuzmenkov) --- Changelog | 1 + TODO | 3 +- src/GUI.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++++------- src/GUI.h | 23 ++++++++++++++ 4 files changed, 107 insertions(+), 12 deletions(-) diff --git a/Changelog b/Changelog index 1c9e241ce..6b0b53a48 100644 --- a/Changelog +++ b/Changelog @@ -22,6 +22,7 @@ - FEATURE: Allow to set global upload/download limits from tray icon menu - FEATURE: IPv6 is now fully supported - FEATURE: Real torrent share ratio is now displayed in transfer list + - FEATURE: Added keyboard shortcuts for main actions (see wiki) - I18N: Added Hungarian translation - BUGFIX: Progress of paused torrents is now correct on restart - BUGFIX: Progress column gets sorted on restart it is was during last execution diff --git a/TODO b/TODO index 65c96f9c4..a09e61785 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ // Easy - Translations into as many languages as possible - Improve man page -- Add more keyboard shortcuts // Intermediate - Port on MacOS, Windows (and create an installer for Windows) - Progressing @@ -43,6 +42,8 @@ - Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix - update sorting when a new torrent is added? - Allow to hide columns +- Allow to set priorities for multiple files at once +- Document keyboard shortcuts on wiki * beta2 - Wait for some bug fixes in libtorrent : - upload/download limit per torrent diff --git a/src/GUI.cpp b/src/GUI.cpp index e30ed8288..d4541d8d1 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -197,6 +198,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){ setInfoBar(tr("qBittorrent %1 started.", "e.g: qBittorrent v0.x started.").arg(QString(VERSION))); setInfoBar(tr("Be careful, sharing copyrighted material without permission is against the law."), "red"); show(); + createKeyboardShortcuts(); qDebug("GUI Built"); } @@ -208,17 +210,33 @@ GUI::~GUI(){ delete checkConnect; delete refresher; delete BTSession; - if(systrayIntegration){ - delete myTrayIcon; - delete myTrayIconMenu; - } - delete DLDelegate; - delete DLListModel; - delete tcpServer; - previewProcess->kill(); - previewProcess->waitForFinished(); - delete previewProcess; - delete connecStatusLblIcon; + if(systrayIntegration){ + delete myTrayIcon; + delete myTrayIconMenu; + } + delete DLDelegate; + delete DLListModel; + delete tcpServer; + previewProcess->kill(); + previewProcess->waitForFinished(); + delete previewProcess; + delete connecStatusLblIcon; + // Keyboard shortcuts + delete createShortcut; + delete openShortcut; + delete quitShortcut; + delete switchSearchShortcut; + delete switchDownShortcut; + delete switchUpShortcut; + delete switchRSSShortcut; + delete propertiesShortcut; + delete optionsShortcut; + delete delShortcut; + delete delPermShortcut; + delete startShortcut; + delete startAllShortcut; + delete pauseShortcut; + delete pauseAllPermShortcut; } void GUI::on_actionWebsite_triggered(){ @@ -241,6 +259,58 @@ void GUI::writeSettings() { settings.endGroup(); } +void GUI::createKeyboardShortcuts(){ + createShortcut = new QShortcut(QKeySequence("Ctrl+N"), this); + connect(createShortcut, SIGNAL(activated()), this, SLOT(on_actionCreate_torrent_triggered())); + openShortcut = new QShortcut(QKeySequence("Ctrl+O"), this); + connect(openShortcut, SIGNAL(activated()), this, SLOT(on_actionOpen_triggered())); + quitShortcut = new QShortcut(QKeySequence("Ctrl+Q"), this); + connect(quitShortcut, SIGNAL(activated()), this, SLOT(on_actionExit_triggered())); + switchDownShortcut = new QShortcut(QKeySequence(tr("Alt+1", "shortcut to switch to first tab")), this); + connect(switchDownShortcut, SIGNAL(activated()), this, SLOT(displayDownTab())); + switchUpShortcut = new QShortcut(QKeySequence(tr("Alt+2", "shortcut to switch to second tab")), this); + connect(switchUpShortcut, SIGNAL(activated()), this, SLOT(displayUpTab())); + switchSearchShortcut = new QShortcut(QKeySequence(tr("Alt+3", "shortcut to switch to third tab")), this); + connect(switchSearchShortcut, SIGNAL(activated()), this, SLOT(displaySearchTab())); + switchRSSShortcut = new QShortcut(QKeySequence(tr("Alt+4", "shortcut to switch to fourth tab")), this); + connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab())); + propertiesShortcut = new QShortcut(QKeySequence("Alt+P"), this); + connect(propertiesShortcut, SIGNAL(activated()), this, SLOT(on_actionTorrent_Properties_triggered())); + optionsShortcut = new QShortcut(QKeySequence("Alt+O"), this); + connect(optionsShortcut, SIGNAL(activated()), this, SLOT(on_actionOptions_triggered())); + delShortcut = new QShortcut(QKeySequence("Del"), this); + connect(delShortcut, SIGNAL(activated()), this, SLOT(on_actionDelete_triggered())); + delPermShortcut = new QShortcut(QKeySequence("Shift+Del"), this); + connect(delPermShortcut, SIGNAL(activated()), this, SLOT(on_actionDelete_Permanently_triggered())); + startShortcut = new QShortcut(QKeySequence("Ctrl+S"), this); + connect(startShortcut, SIGNAL(activated()), this, SLOT(on_actionStart_triggered())); + startAllShortcut = new QShortcut(QKeySequence("Ctrl+Shift+S"), this); + connect(startAllShortcut, SIGNAL(activated()), this, SLOT(on_actionStart_All_triggered())); + pauseShortcut = new QShortcut(QKeySequence("Ctrl+P"), this); + connect(pauseShortcut, SIGNAL(activated()), this, SLOT(on_actionPause_triggered())); + pauseAllPermShortcut = new QShortcut(QKeySequence("Ctrl+Shift+P"), this); + connect(pauseAllPermShortcut, SIGNAL(activated()), this, SLOT(on_actionPause_All_triggered())); +} + +// Keyboard shortcuts slots +void GUI::displayDownTab(){ + tabs->setCurrentIndex(0); +} + +void GUI::displayUpTab(){ + tabs->setCurrentIndex(1); +} + +void GUI::displaySearchTab(){ + tabs->setCurrentIndex(2); +} + +void GUI::displayRSSTab(){ + tabs->setCurrentIndex(3); +} + +// End of keyboard shortcuts slots + void GUI::readSettings() { QSettings settings("qBittorrent", "qBittorrent"); settings.beginGroup("MainWindow"); diff --git a/src/GUI.h b/src/GUI.h index d6402cd50..a508878f2 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -53,6 +53,7 @@ class QTcpServer; class QTcpSocket; class QCloseEvent; class RSSImp; +class QShortcut; using namespace libtorrent; namespace fs = boost::filesystem; @@ -86,6 +87,22 @@ class GUI : public QMainWindow, private Ui::MainWindow{ bool delayedSorting; Qt::SortOrder delayedSortingOrder; QMutex DLListAccess; + // Keyboard shortcuts + QShortcut *createShortcut; + QShortcut *openShortcut; + QShortcut *quitShortcut; + QShortcut *switchSearchShortcut; + QShortcut *switchDownShortcut; + QShortcut *switchUpShortcut; + QShortcut *switchRSSShortcut; + QShortcut *propertiesShortcut; + QShortcut *optionsShortcut; + QShortcut *delShortcut; + QShortcut *delPermShortcut; + QShortcut *startShortcut; + QShortcut *startAllShortcut; + QShortcut *pauseShortcut; + QShortcut *pauseAllPermShortcut; // Preview previewSelect *previewSelection; QProcess *previewProcess; @@ -130,6 +147,12 @@ class GUI : public QMainWindow, private Ui::MainWindow{ void on_actionExit_triggered(); void createTrayIcon(); void addLogPeerBlocked(const QString&); + // Keyboard shortcuts + void createKeyboardShortcuts(); + void displayDownTab(); + void displayUpTab(); + void displaySearchTab(); + void displayRSSTab(); // Torrent actions void showProperties(const QModelIndex &index); void on_actionTorrent_Properties_triggered();