diff options
-rw-r--r-- | shemovcleaner.cpp | 28 | ||||
-rw-r--r-- | shemovcleaner.h | 2 | ||||
-rw-r--r-- | torrentwidget.h | 1 |
3 files changed, 31 insertions, 0 deletions
diff --git a/shemovcleaner.cpp b/shemovcleaner.cpp index e7c6d07..2484689 100644 --- a/shemovcleaner.cpp +++ b/shemovcleaner.cpp @@ -11,6 +11,7 @@ #include <QMessageBox> #include <QTreeView> #include <QSettings> +#include <QKeyEvent> #include "shemovcleaner.h" #include "torrentwidget.h" @@ -43,6 +44,7 @@ ShemovCleaner::ShemovCleaner(QWidget *parent, Qt::WindowFlags f) : QMainWindow(p QSettings s; restoreGeometry(s.value("geometry").toByteArray()); + mTorrentTab->torrentFileView()->setFocus(); } void ShemovCleaner::statusBarMessage(const QString &msg){ @@ -81,6 +83,32 @@ void ShemovCleaner::closeEvent(QCloseEvent *e){ QMainWindow::closeEvent(e); } +void ShemovCleaner::keyPressEvent(QKeyEvent *e){ + //Yes, this could be much more terse, but this is readable! + if(e->key() == Qt::Key_Left && (e->modifiers() & Qt::AltModifier)){ + int curTabIdx = mTab->currentIndex(); + if(curTabIdx - 1 < 0){ + curTabIdx = mTab->count() - 1; + }else{ + --curTabIdx; + } + mTab->setCurrentIndex(curTabIdx); + e->accept(); + return; + } + if(e->key() == Qt::Key_Right && (e->modifiers() & Qt::AltModifier)){ + int curTabIdx = mTab->currentIndex(); + if(curTabIdx + 1 >= mTab->count()){ + curTabIdx = 0; + }else{ + ++curTabIdx; + } + mTab->setCurrentIndex(curTabIdx); + e->accept(); + return; + } +} + void ShemovCleaner::createStatusBar(){ QLabel *l1 = new QLabel(tr("Sel.")); mSelected = new QLabel("000/000"); diff --git a/shemovcleaner.h b/shemovcleaner.h index 441b0a3..0ace511 100644 --- a/shemovcleaner.h +++ b/shemovcleaner.h @@ -8,6 +8,7 @@ class TorrentWidget; class FileWidget; class QLabel; class QAction; +class QKeyEvent; class ShemovCleaner : public QMainWindow { Q_OBJECT @@ -24,6 +25,7 @@ class ShemovCleaner : public QMainWindow { protected: virtual void closeEvent(QCloseEvent *e); + virtual void keyPressEvent(QKeyEvent *e); private: void createStatusBar(); diff --git a/torrentwidget.h b/torrentwidget.h index 10a67d8..549b3db 100644 --- a/torrentwidget.h +++ b/torrentwidget.h @@ -23,6 +23,7 @@ class TorrentWidget : public QWidget { QToolBar *toolBar() { return mToolBar; } QMenuBar *menuBar() { return mMenuBar; } TorrentDisplay *torrentDisplay() { return mTorrentDisplay; } + QTreeView *torrentFileView() { return mFileView; } ~TorrentWidget(); signals: |