Browse Source

add config global/sync_note_list_to_current_tab to auto locate to current tab in note list

Le Tan 6 years ago
parent
commit
8871f56368

+ 6 - 6
src/resources/themes/v_detorte/v_detorte.mdhl

@@ -114,7 +114,7 @@ foreground: 56b6c2
 
 CODE
 foreground: 98c379
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 EMPH
 foreground: e0e0e0
@@ -138,11 +138,11 @@ foreground: 9e9e9e
 
 VERBATIM
 foreground: 98c379
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 FENCEDCODEBLOCK
 foreground: 98c379
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 # [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color)
 # The last occurence of the same attribute takes effect
 # Could specify multiple attribute in one line
@@ -195,18 +195,18 @@ foreground: af8787
 
 INLINEEQUATION
 foreground: 93d3cc
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 DISPLAYFORMULA
 foreground: 93d3cc
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 MARK
 foreground: dadada
 background: 802090
 
 TABLE
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 TABLEBORDER
 foreground: e37c84

+ 6 - 6
src/resources/themes/v_moonlight/v_moonlight.mdhl

@@ -114,7 +114,7 @@ foreground: 56b6c2
 
 CODE
 foreground: 98c379
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 EMPH
 font-style: italic
@@ -136,11 +136,11 @@ foreground: 6e7686
 
 VERBATIM
 foreground: 98c379
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 FENCEDCODEBLOCK
 foreground: 98c379
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 # [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color)
 # The last occurence of the same attribute takes effect
 # Could specify multiple attribute in one line
@@ -194,18 +194,18 @@ foreground: 6e7686
 
 INLINEEQUATION
 foreground: 4db6ac
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 DISPLAYFORMULA
 foreground: 4db6ac
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 MARK
 foreground: abb2bf
 background: 551560
 
 TABLE
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 TABLEBORDER
 foreground: e06c75

+ 6 - 6
src/resources/themes/v_native/v_native.mdhl

@@ -111,7 +111,7 @@ foreground: 826200
 
 CODE
 foreground: 8e24aa
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 EMPH
 font-style: italic
@@ -133,11 +133,11 @@ foreground: 93a1a1
 
 VERBATIM
 foreground: 673ab7
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 FENCEDCODEBLOCK
 foreground: 673ab7
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 # [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color)
 # The last occurence of the same attribute takes effect
 hljs-comment: 6c6c6c
@@ -190,18 +190,18 @@ foreground: 6c6c6c
 
 INLINEEQUATION
 foreground: 00897b
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 DISPLAYFORMULA
 foreground: 00897b
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 MARK
 foreground: 363636
 background: ffff76
 
 TABLE
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 TABLEBORDER
 foreground: d33682

+ 6 - 6
src/resources/themes/v_pure/v_pure.mdhl

@@ -112,7 +112,7 @@ foreground: 826200
 
 CODE
 foreground: 8e24aa
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 EMPH
 font-style: italic
@@ -134,11 +134,11 @@ foreground: 93a1a1
 
 VERBATIM
 foreground: 673ab7
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 FENCEDCODEBLOCK
 foreground: 673ab7
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 # [VNote] Codeblock sylte from HighlightJS (bold, italic, underlined, strikeout, color)
 # The last occurence of the same attribute takes effect
 # Could specify multiple attribute in one line
@@ -191,18 +191,18 @@ foreground: 6c6c6c
 
 INLINEEQUATION
 foreground: 00897b
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 DISPLAYFORMULA
 foreground: 00897b
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 MARK
 foreground: 222222
 background: ffff76
 
 TABLE
-font-family: Consolas, Monaco, Andale Mono, Monospace, Courier New
+font-family: YaHei Consolas Hybrid, Consolas, Monaco, Andale Mono, Monospace, Courier New
 
 TABLEBORDER
 foreground: d33682

+ 3 - 0
src/resources/vnote.ini

@@ -286,6 +286,9 @@ windows_opengl=0
 ; Whether allow VNote to send request for couting users
 allow_user_track=true
 
+; Whether auto locate to current tab in note list
+sync_note_list_to_current_tab=false
+
 [editor]
 ; Auto indent as previous line
 auto_indent=true

+ 3 - 0
src/vconfigmanager.cpp

@@ -326,6 +326,9 @@ void VConfigManager::initialize()
     m_highlightMatchesInPage = getConfigFromSettings("global",
                                                      "highlight_matches_in_page").toBool();
 
+    m_syncNoteListToCurrentTab = getConfigFromSettings("global",
+                                                       "sync_note_list_to_current_tab").toBool();
+
     initEditorConfigs();
 
     initMarkdownConfigs();

+ 21 - 0
src/vconfigmanager.h

@@ -634,6 +634,9 @@ public:
     bool getAllowUserTrack() const;
     void setAllowUserTrack(bool p_enabled);
 
+    bool getSyncNoteListToTab() const;
+    void setSyncNoteListToTab(bool p_enabled);
+
 private:
     void initEditorConfigs();
 
@@ -1121,6 +1124,9 @@ private:
     // Whether enable smart table.
     bool m_enableSmartTable;
 
+    // Whether auto locate to current tab in note list.
+    bool m_syncNoteListToCurrentTab;
+
     // The name of the config file in each directory.
     static const QString c_dirConfigFile;
 
@@ -2932,4 +2938,19 @@ inline void VConfigManager::setAllowUserTrack(bool p_enabled)
 {
     setConfigToSettings("global", "allow_user_track", p_enabled);
 }
+
+inline bool VConfigManager::getSyncNoteListToTab() const
+{
+    return m_syncNoteListToCurrentTab;
+}
+
+inline void VConfigManager::setSyncNoteListToTab(bool p_enabled)
+{
+    if (m_syncNoteListToCurrentTab == p_enabled) {
+        return;
+    }
+
+    m_syncNoteListToCurrentTab = p_enabled;
+    setConfigToSettings("global", "sync_note_list_to_current_tab", m_syncNoteListToCurrentTab);
+}
 #endif // VCONFIGMANAGER_H

+ 18 - 4
src/vmainwindow.cpp

@@ -86,7 +86,8 @@ VMainWindow::VMainWindow(VSingleInstanceGuard *p_guard, QWidget *p_parent)
       m_windowOldState(Qt::WindowNoState),
       m_requestQuit(false),
       m_printer(NULL),
-      m_ue(NULL)
+      m_ue(NULL),
+      m_syncNoteListToCurrentTab(true)
 {
     qsrand(QDateTime::currentDateTime().toTime_t());
 
@@ -2137,6 +2138,10 @@ void VMainWindow::handleAreaTabStatusUpdated(const VEditTabInfo &p_info)
 
         m_attachmentList->setFile(dynamic_cast<VNoteFile *>(m_curFile.data()));
 
+        if (m_syncNoteListToCurrentTab && g_config->getSyncNoteListToTab()) {
+            locateFile(m_curFile, false, false);
+        }
+
         QString title;
         if (m_curFile) {
             m_findReplaceDialog->updateState(m_curFile->getDocType(),
@@ -2290,9 +2295,12 @@ void VMainWindow::closeEvent(QCloseEvent *event)
             }
         }
 
+        m_syncNoteListToCurrentTab = false;
+
         if (!m_editArea->closeAllFiles(false)) {
             // Fail to close all the opened files, cancel closing app.
             event->ignore();
+            m_syncNoteListToCurrentTab = true;
             return;
         }
 
@@ -2371,7 +2379,7 @@ void VMainWindow::keyPressEvent(QKeyEvent *event)
     QMainWindow::keyPressEvent(event);
 }
 
-bool VMainWindow::locateFile(VFile *p_file)
+bool VMainWindow::locateFile(VFile *p_file, bool p_focus, bool p_show)
 {
     bool ret = false;
     if (!p_file || p_file->getType() != FileType::Note) {
@@ -2393,13 +2401,15 @@ bool VMainWindow::locateFile(VFile *p_file)
 
             if (m_fileList->locateFile(file)) {
                 ret = true;
-                m_fileList->setFocus();
+                if (p_focus) {
+                    m_fileList->setFocus();
+                }
             }
         }
     }
 
     // Open the directory and file panels after location.
-    if (ret) {
+    if (ret && p_show) {
         showNotebookPanel();
     }
 
@@ -3411,6 +3421,8 @@ void VMainWindow::setToolBarVisible(bool p_visible)
 void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
 {
     QTimer::singleShot(300, [this, p_files]() {
+        m_syncNoteListToCurrentTab = false;
+
         checkNotebooks();
         QCoreApplication::sendPostedEvents();
         promptNewNotebookIfEmpty();
@@ -3441,6 +3453,8 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
         if (g_config->getAllowUserTrack()) {
             QTimer::singleShot(60000, this, SLOT(collectUserStat()));
         }
+
+        m_syncNoteListToCurrentTab = true;
     });
 }
 

+ 4 - 1
src/vmainwindow.h

@@ -64,7 +64,7 @@ public:
     VMainWindow(VSingleInstanceGuard *p_guard, QWidget *p_parent = 0);
 
     // Returns true if the location succeeds.
-    bool locateFile(VFile *p_file);
+    bool locateFile(VFile *p_file, bool p_focus = true, bool p_show = true);
 
     // Returns true if the location succeeds.
     bool locateDirectory(VDirectory *p_directory);
@@ -506,6 +506,9 @@ private:
 
     VTagExplorer *m_tagExplorer;
 
+    // Whether sync note list to current tab.
+    bool m_syncNoteListToCurrentTab;
+
     // Interval of the shared memory timer in ms.
     static const int c_sharedMemTimerInterval;
 };