From d65e23c6d2bcfd6f4d4e0c2fe3ee80232fa78eae Mon Sep 17 00:00:00 2001 From: Lukas Hrazky Date: Mon, 19 Jul 2010 23:58:52 +0200 Subject: [PATCH] Ctrl-H shortcut to toggle hidden files' visibility Signed-off-by: Lukas Hrazky --- src/case.cpp | 9 +++++++++ src/case.h | 8 +++++--- src/filelist.cpp | 7 +++++++ src/filelist.h | 1 + src/pane.cpp | 5 +++++ src/pane.h | 1 + 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/case.cpp b/src/case.cpp index 6770447..231e230 100644 --- a/src/case.cpp +++ b/src/case.cpp @@ -97,6 +97,15 @@ void Case::switchActivePane() { } +void Case::keyPressEvent(QKeyEvent *e) { + if(e->key() == Qt::Key_H && e->modifiers() == Qt::ControlModifier) { + activePane->toggleShowHiddenFiles(); + } else { + QMainWindow::keyPressEvent(e); + } +} + + void Case::clonePane() { inactivePane->changePath(activePane->path()); } diff --git a/src/case.h b/src/case.h index b8f2919..7e55fd0 100644 --- a/src/case.h +++ b/src/case.h @@ -23,7 +23,7 @@ #include "button.h" #include -#include +#include class Case : public QMainWindow { @@ -38,12 +38,14 @@ public: public slots: void switchActivePane(); -private: +protected: + void keyPressEvent(QKeyEvent *e); + Pane *leftPane, *rightPane, *activePane, *inactivePane; Button *cloneBtn, *swapBtn, *copyBtn, *moveBtn, *delBtn; FileOperator *fileOperator; -private slots: +protected slots: void clonePane(); void swapPanes(); void copyFiles(); diff --git a/src/filelist.cpp b/src/filelist.cpp index 6b1749f..3d9c8c4 100644 --- a/src/filelist.cpp +++ b/src/filelist.cpp @@ -75,6 +75,13 @@ bool FileList::goUp() { } +void FileList::toggleShowHiddenFiles() { + clearSelection(); + scrollToTop(); + fileSystemModel->setFilter(fileSystemModel->filter() ^ QDir::Hidden); +} + + void FileList::activateItem(QModelIndex index) { const QFileInfo &file = fileSystemModel->fileInfo(index); diff --git a/src/filelist.h b/src/filelist.h index 6d211f3..dd6fda9 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -39,6 +39,7 @@ public: public slots: bool changePath(QString path); bool goUp(); + void toggleShowHiddenFiles(); protected: QFileSystemModel *fileSystemModel; diff --git a/src/pane.cpp b/src/pane.cpp index ac3d553..34ec244 100644 --- a/src/pane.cpp +++ b/src/pane.cpp @@ -92,6 +92,11 @@ void Pane::toggleActive() { } +void Pane::toggleShowHiddenFiles() { + fileList->toggleShowHiddenFiles(); +} + + const QFileInfoList Pane::selection() const { return fileList->selection(); } diff --git a/src/pane.h b/src/pane.h index 0d49815..a565b8d 100644 --- a/src/pane.h +++ b/src/pane.h @@ -38,6 +38,7 @@ public: public slots: bool changePath(QString path); void toggleActive(); + void toggleShowHiddenFiles(); protected: void paintEvent(QPaintEvent *); -- 1.7.9.5