feat(shortcut): ctrl+w to close window

https://github.com/cutefishos/filemanager/pull/33
This commit is contained in:
kateleet 2021-12-20 23:40:18 +08:00
parent f846b4690e
commit c3f32210ec
3 changed files with 6 additions and 0 deletions

View file

@ -54,6 +54,8 @@ bool ShortCut::eventFilter(QObject *obj, QEvent *e)
emit copy(); emit copy();
} else if (keyEvent->key() == Qt::Key_X && keyEvent->modifiers() & Qt::ControlModifier) { } else if (keyEvent->key() == Qt::Key_X && keyEvent->modifiers() & Qt::ControlModifier) {
emit cut(); 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) { } else if (keyEvent->key() == Qt::Key_V && keyEvent->modifiers() & Qt::ControlModifier) {
emit paste(); emit paste();
} else if (keyEvent->key() == Qt::Key_F2) { } else if (keyEvent->key() == Qt::Key_F2) {

View file

@ -46,6 +46,7 @@ signals:
void deleteFile(); void deleteFile();
void showHidden(); void showHidden();
void keyPressed(const QString &text); void keyPressed(const QString &text);
void close();
protected: protected:
bool eventFilter(QObject *obj, QEvent *e) override; bool eventFilter(QObject *obj, QEvent *e) override;

View file

@ -423,6 +423,9 @@ Item {
onShowHidden: { onShowHidden: {
dirModel.showHiddenFiles = !dirModel.showHiddenFiles dirModel.showHiddenFiles = !dirModel.showHiddenFiles
} }
onClose: {
root.close()
}
} }
function openUrl(url) { function openUrl(url) {