From cd8f148946b22e526364a8b1461d013a00a8a774 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Wed, 10 Jan 2018 20:16:32 +0800 Subject: [PATCH] add shortcut Ctrl+Alt+S for creating subfolder --- src/resources/vnote.ini | 2 ++ src/vdirectorytree.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index 0279e6ed..b600bd8d 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -229,6 +229,8 @@ copy_targets=WithoutBackground$s:b(mark):c:i:x,OneNote$s:b(mark):c:i:m:a:x,Micro CaptainMode=Ctrl+E ; Create a note in current folder NewNote=Ctrl+Alt+N +; Create a subfolder in current folder +NewSubfolder=Ctrl+Alt+S ; Save current note SaveNote=Ctrl+S ; Save changes and enter read mode diff --git a/src/vdirectorytree.cpp b/src/vdirectorytree.cpp index b460f0be..1f75323c 100644 --- a/src/vdirectorytree.cpp +++ b/src/vdirectorytree.cpp @@ -74,6 +74,16 @@ void VDirectoryTree::initShortcuts() this, [this](){ pasteDirectoriesFromClipboard(); }); + + QKeySequence seq = QKeySequence(g_config->getShortcutKeySequence("NewSubfolder")); + if (!seq.isEmpty()) { + QShortcut *newSubDirShortcut = new QShortcut(seq, this); + newSubDirShortcut->setContext(Qt::ApplicationShortcut); + connect(newSubDirShortcut, &QShortcut::activated, + this, [this](){ + newSubDirectory(); + }); + } } void VDirectoryTree::initActions() @@ -87,6 +97,11 @@ void VDirectoryTree::initActions() newSubDirAct = new QAction(VIconUtils::menuIcon(":/resources/icons/create_subdir.svg"), tr("&New Subfolder"), this); newSubDirAct->setToolTip(tr("Create a subfolder")); + QString shortcutStr = VUtils::getShortcutText(g_config->getShortcutKeySequence("NewSubfolder")); + if (!shortcutStr.isEmpty()) { + newSubDirAct->setText(tr("&New Subfolder\t%1").arg(shortcutStr)); + } + connect(newSubDirAct, &QAction::triggered, this, &VDirectoryTree::newSubDirectory);