From f2bfcd25d1ac61fe8d8de13d10fe6468275885ad Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sun, 10 Jan 2021 12:27:17 +0800 Subject: [PATCH] Small fix * Add *.rmd to Markdown suffix * Turn on system title bar by default * Enable AutoBreak by default * Fix title on new note --- src/core/buffer/filetypehelper.cpp | 5 ++++- src/core/sessionconfig.cpp | 17 ++++++++++++----- src/core/sessionconfig.h | 2 ++ src/data/core/vnotex.json | 2 +- src/widgets/markdownviewwindow.cpp | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/core/buffer/filetypehelper.cpp b/src/core/buffer/filetypehelper.cpp index 1712cae4..0c471b0b 100644 --- a/src/core/buffer/filetypehelper.cpp +++ b/src/core/buffer/filetypehelper.cpp @@ -24,7 +24,10 @@ void FileTypeHelper::setupBuiltInTypes() type.m_type = Type::Markdown; type.m_displayName = Buffer::tr("Markdown"); type.m_typeName = QStringLiteral("Markdown"); - type.m_suffixes << QStringLiteral("md") << QStringLiteral("mkd") << QStringLiteral("markdown"); + type.m_suffixes << QStringLiteral("md") + << QStringLiteral("mkd") + << QStringLiteral("rmd") + << QStringLiteral("markdown"); m_fileTypes.push_back(type); } diff --git a/src/core/sessionconfig.cpp b/src/core/sessionconfig.cpp index 4a0273d3..d30d1f33 100644 --- a/src/core/sessionconfig.cpp +++ b/src/core/sessionconfig.cpp @@ -8,6 +8,7 @@ #include #include "configmgr.h" +#include "mainconfig.h" using namespace vnotex; @@ -53,6 +54,10 @@ void SessionConfig::init() const auto &sessionJobj = sessionSettings->getJson(); loadCore(sessionJobj); + + if (MainConfig::isVersionChanged()) { + doVersionSpecificOverride(); + } } void SessionConfig::loadCore(const QJsonObject &p_session) @@ -75,12 +80,7 @@ void SessionConfig::loadCore(const QJsonObject &p_session) if (!isUndefinedKey(coreObj, QStringLiteral("system_title_bar"))) { m_systemTitleBarEnabled = readBool(coreObj, QStringLiteral("system_title_bar")); } else { - // Enable system title bar on macOS by default. -#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) m_systemTitleBarEnabled = true; -#else - m_systemTitleBarEnabled = false; -#endif } if (!isUndefinedKey(coreObj, QStringLiteral("minimize_to_system_tray"))) { @@ -277,3 +277,10 @@ void SessionConfig::setMinimizeToSystemTray(bool p_enabled) { updateConfig(m_minimizeToSystemTray, p_enabled ? 1 : 0, this); } + +void SessionConfig::doVersionSpecificOverride() +{ + // In a new version, we may want to change one value by force. + // SHOULD set the in memory variable only, or will override the notebook list. + m_systemTitleBarEnabled = true; +} diff --git a/src/core/sessionconfig.h b/src/core/sessionconfig.h index 5b6dcf22..ede480ee 100644 --- a/src/core/sessionconfig.h +++ b/src/core/sessionconfig.h @@ -93,6 +93,8 @@ namespace vnotex QJsonObject saveStateAndGeometry() const; + void doVersionSpecificOverride(); + QString m_newNotebookDefaultRootFolderPath; // Use root folder to identify a notebook uniquely. diff --git a/src/data/core/vnotex.json b/src/data/core/vnotex.json index 96942087..0a62d778 100644 --- a/src/data/core/vnotex.json +++ b/src/data/core/vnotex.json @@ -247,7 +247,7 @@ "//comment" : "Whether allow HTML tags in source", "html_tag" : true, "//comment" : "Whether auto break a line with '\\n'", - "auto_break" : false, + "auto_break" : true, "//comment" : "Whether convert URL-like text to links", "linkify" : true, "//comment" : "Whether add indentation to the first line of paragraph", diff --git a/src/widgets/markdownviewwindow.cpp b/src/widgets/markdownviewwindow.cpp index 956d6d6e..c1b4e532 100644 --- a/src/widgets/markdownviewwindow.cpp +++ b/src/widgets/markdownviewwindow.cpp @@ -241,7 +241,7 @@ void MarkdownViewWindow::handleBufferChangedInternal() Q_ASSERT(m_mode != Mode::Read); const auto &markdownEditorConfig = ConfigMgr::getInst().getEditorConfig().getMarkdownEditorConfig(); if (markdownEditorConfig.getInsertFileNameAsTitle() && buffer->getContent().isEmpty()) { - const auto title = QString("# %1\n").arg(QFileInfo(buffer->getName()).baseName()); + const auto title = QString("# %1\n").arg(QFileInfo(buffer->getName()).completeBaseName()); m_editor->insertText(title); } }