From c3f32210ecc353a0f450a875f3bcb15375cba647 Mon Sep 17 00:00:00 2001 From: kateleet Date: Mon, 20 Dec 2021 23:40:18 +0800 Subject: [PATCH] feat(shortcut): ctrl+w to close window https://github.com/cutefishos/filemanager/pull/33 --- helper/shortcut.cpp | 2 ++ helper/shortcut.h | 1 + qml/FolderPage.qml | 3 +++ 3 files changed, 6 insertions(+) diff --git a/helper/shortcut.cpp b/helper/shortcut.cpp index 0e62b65..5edaf79 100644 --- a/helper/shortcut.cpp +++ b/helper/shortcut.cpp @@ -54,6 +54,8 @@ bool ShortCut::eventFilter(QObject *obj, QEvent *e) emit copy(); } else if (keyEvent->key() == Qt::Key_X && keyEvent->modifiers() & Qt::ControlModifier) { emit cut(); + } else if (keyEvent->key() == Qt::Key_W && keyEvent->modifiers() & Qt::ControlModifier) { + emit close(); } else if (keyEvent->key() == Qt::Key_V && keyEvent->modifiers() & Qt::ControlModifier) { emit paste(); } else if (keyEvent->key() == Qt::Key_F2) { diff --git a/helper/shortcut.h b/helper/shortcut.h index 6a24b96..2efb7d5 100644 --- a/helper/shortcut.h +++ b/helper/shortcut.h @@ -46,6 +46,7 @@ signals: void deleteFile(); void showHidden(); void keyPressed(const QString &text); + void close(); protected: bool eventFilter(QObject *obj, QEvent *e) override; diff --git a/qml/FolderPage.qml b/qml/FolderPage.qml index 31486a0..0c5b117 100644 --- a/qml/FolderPage.qml +++ b/qml/FolderPage.qml @@ -423,6 +423,9 @@ Item { onShowHidden: { dirModel.showHiddenFiles = !dirModel.showHiddenFiles } + onClose: { + root.close() + } } function openUrl(url) {