add shortcut Ctrl+Alt+S for creating subfolder

This commit is contained in:
Le Tan 2018-01-10 20:16:32 +08:00
parent 14df9e6e90
commit cd8f148946
2 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -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);