Browse Source

add shortcut Ctrl+Alt+S for creating subfolder

Le Tan 8 years ago
parent
commit
cd8f148946
2 changed files with 17 additions and 0 deletions
  1. 2 0
      src/resources/vnote.ini
  2. 15 0
      src/vdirectorytree.cpp

+ 2 - 0
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

+ 15 - 0
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);