From 3a6e43400ff1c36269d6b7cb822b3ffe6ff58fb7 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 5 Sep 2016 04:08:07 +0200 Subject: Fix keyboard naviagtion for TorrentWidget too For an explanation see commit eaaa0c165b83aba1227304eb1074098ac0028ae8 --- torrentwidget.cpp | 28 +++++++++++++++++++++++++++- torrentwidget.h | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/torrentwidget.cpp b/torrentwidget.cpp index f4619f1..cf866df 100644 --- a/torrentwidget.cpp +++ b/torrentwidget.cpp @@ -99,7 +99,7 @@ void TorrentWidget::createActions(){ mMoveA->setShortcut(tr("CTRL+M")); connect(mMoveA, SIGNAL(triggered()), this, SLOT(moveFiles())); mTorrentInfoA = new QAction(QIcon(":/huge_bra.png"), tr("Torrent Info..."), this); - mTorrentInfoA->setShortcut(Qt::Key_Return); + mTorrentInfoA->setShortcut(Qt::CTRL + Qt::Key_Return); connect(mTorrentInfoA, SIGNAL(triggered()), this, SLOT(torrentInfo())); mSelDirA = new QAction(QIcon(":/folder.png"), tr("Select folder..."), this); mSelDirA->setShortcut(tr("CTRL+O")); @@ -271,6 +271,32 @@ void TorrentWidget::searchFile(){ emit statusMessage(QString(tr("Found %1 file(s)").arg(QString::number(success)))); } +void TorrentWidget::keyPressEvent(QKeyEvent *e){ + if(e->key() == Qt::Key_S && (e->modifiers() & Qt::ControlModifier)){ + mSearchTorrents->setFocus(); + mSearchTorrents->selectAll(); + goto exit; + } + if(e->key() == Qt::Key_D && (e->modifiers() & Qt::ControlModifier)){ + mDir->setFocus(); + mDir->selectAll(); + goto exit; + } + if(e->key() == Qt::Key_F && (e->modifiers() & Qt::ControlModifier)){ + mFileView->setFocus(); + goto exit; + } + if(mFileView->hasFocus()){ + if(e->key() == Qt::Key_Return){ + } + } + + return QWidget::keyPressEvent(e); + + exit: + e->accept(); +} + void TorrentWidget::contextMenuEvent(QContextMenuEvent *e){ QMenu contextMenu(this); contextMenu.addActions(actions()); diff --git a/torrentwidget.h b/torrentwidget.h index 051a281..4a354ce 100644 --- a/torrentwidget.h +++ b/torrentwidget.h @@ -13,6 +13,7 @@ class QStandardItemModel; class QLabel; class QToolBar; class QMenuBar; +class QKeyEvent; class FileSorter; class TorrentDisplay; @@ -41,6 +42,7 @@ class TorrentWidget : public QWidget { void fileSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); protected: + virtual void keyPressEvent(QKeyEvent *e); virtual void contextMenuEvent(QContextMenuEvent *e); private: -- cgit v1.2.3-70-g09d2