Prechádzať zdrojové kódy

add config close_before_external_editor

Do not close the note when opening it with external editors if this is true.
Le Tan 8 rokov pred
rodič
commit
e6db71217a

+ 3 - 0
src/resources/vnote.ini

@@ -178,6 +178,9 @@ vim_exemption_keys=cv
 ; Could be absolute path
 flash_page=flash_page.md
 
+; Whether close note before editting with external editor
+close_before_external_editor=true
+
 [web]
 ; Location and configuration for Mathjax
 mathjax_javascript=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML

+ 3 - 0
src/vconfigmanager.cpp

@@ -279,6 +279,9 @@ void VConfigManager::initialize()
 
     m_vimExemptionKeys = getConfigFromSettings("global",
                                                "vim_exemption_keys").toString();
+
+    m_closeBeforeExternalEditor = getConfigFromSettings("global",
+                                                        "close_before_external_editor").toBool();
 }
 
 void VConfigManager::initSettings()

+ 10 - 0
src/vconfigmanager.h

@@ -397,6 +397,8 @@ public:
 
     QString getThemeFile() const;
 
+    bool getCloseBeforeExternalEditor() const;
+
 private:
     // Look up a config from user and default settings.
     QVariant getConfigFromSettings(const QString &section, const QString &key) const;
@@ -769,6 +771,9 @@ private:
     // [name] -> [file path].
     QMap<QString, QString> m_codeBlockCssStyles;
 
+    // Whether close note before open it via external editor.
+    bool m_closeBeforeExternalEditor;
+
     // The name of the config file in each directory, obsolete.
     // Use c_dirConfigFile instead.
     static const QString c_obsoleteDirConfigFile;
@@ -1911,4 +1916,9 @@ inline void VConfigManager::setCodeBlockCssStyle(const QString &p_style)
     setConfigToSettings("global", "code_block_css_style", m_codeBlockCssStyle);
 }
 
+inline bool VConfigManager::getCloseBeforeExternalEditor() const
+{
+    return m_closeBeforeExternalEditor;
+}
+
 #endif // VCONFIGMANAGER_H

+ 3 - 2
src/vfilelist.cpp

@@ -1035,13 +1035,14 @@ void VFileList::handleOpenWithActionTriggered()
     if (item) {
         VNoteFile *file = getVFile(item);
         if (file
-            && (!editArea->isFileOpened(file) || editArea->closeFile(file, false))) {
+            && (!g_config->getCloseBeforeExternalEditor()
+                || !editArea->isFileOpened(file)
+                || editArea->closeFile(file, false))) {
             cmd.replace("%0", file->fetchPath());
             QProcess *process = new QProcess(this);
             connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
                     process, &QProcess::deleteLater);
             process->start(cmd);
-            qDebug() << "open with" << cmd << "process" << process->processId();
         }
     }
 }