diff --git a/libs/vtextedit b/libs/vtextedit index 6c2ff0e7..00b52913 160000 --- a/libs/vtextedit +++ b/libs/vtextedit @@ -1 +1 @@ -Subproject commit 6c2ff0e78aedb6d4a107cd4825473d47813596cc +Subproject commit 00b52913fe8f4ccf5ed5a0cbd3493b94fe354b25 diff --git a/src/core/mainconfig.cpp b/src/core/mainconfig.cpp index 74fa8bf6..bc13a770 100644 --- a/src/core/mainconfig.cpp +++ b/src/core/mainconfig.cpp @@ -118,5 +118,4 @@ QString MainConfig::getVersion(const QJsonObject &p_jobj) void MainConfig::doVersionSpecificOverride() { // In a new version, we may want to change one value by force. - m_coreConfig->m_docksTabBarIconSize = 26; } diff --git a/src/core/texteditorconfig.cpp b/src/core/texteditorconfig.cpp index 04e7a713..a2547749 100644 --- a/src/core/texteditorconfig.cpp +++ b/src/core/texteditorconfig.cpp @@ -44,6 +44,8 @@ void TextEditorConfig::init(const QJsonObject &p_app, m_tabStopWidth = READINT(QStringLiteral("tab_stop_width")); + m_highlightWhitespace = READBOOL(QStringLiteral("highlight_whitespace")); + m_zoomDelta = READINT(QStringLiteral("zoom_delta")); m_spellCheckEnabled = READBOOL(QStringLiteral("spell_check")); @@ -59,6 +61,7 @@ QJsonObject TextEditorConfig::toJson() const obj[QStringLiteral("wrap_mode")] = wrapModeToString(m_wrapMode); obj[QStringLiteral("expand_tab")] = m_expandTab; obj[QStringLiteral("tab_stop_width")] = m_tabStopWidth; + obj[QStringLiteral("highlight_whitespace")] = m_highlightWhitespace; obj[QStringLiteral("zoom_delta")] = m_zoomDelta; obj[QStringLiteral("spell_check")] = m_spellCheckEnabled; return obj; @@ -183,9 +186,9 @@ bool TextEditorConfig::getTextFoldingEnabled() const return m_textFoldingEnabled; } -void TextEditorConfig::setTextFoldingEnabled(bool p_enable) +void TextEditorConfig::setTextFoldingEnabled(bool p_enabled) { - updateConfig(m_textFoldingEnabled, p_enable, this); + updateConfig(m_textFoldingEnabled, p_enabled, this); } TextEditorConfig::InputMode TextEditorConfig::getInputMode() const @@ -223,9 +226,19 @@ bool TextEditorConfig::getExpandTabEnabled() const return m_expandTab; } -void TextEditorConfig::setExpandTabEnabled(bool p_enable) +void TextEditorConfig::setExpandTabEnabled(bool p_enabled) { - updateConfig(m_expandTab, p_enable, this); + updateConfig(m_expandTab, p_enabled, this); +} + +bool TextEditorConfig::getHighlightWhitespaceEnabled() const +{ + return m_highlightWhitespace; +} + +void TextEditorConfig::setHighlightWhitespaceEnabled(bool p_enabled) +{ + updateConfig(m_highlightWhitespace, p_enabled, this); } int TextEditorConfig::getTabStopWidth() const diff --git a/src/core/texteditorconfig.h b/src/core/texteditorconfig.h index fbe69353..4e788b00 100644 --- a/src/core/texteditorconfig.h +++ b/src/core/texteditorconfig.h @@ -46,7 +46,7 @@ namespace vnotex void setLineNumberType(TextEditorConfig::LineNumberType p_type); bool getTextFoldingEnabled() const; - void setTextFoldingEnabled(bool p_enable); + void setTextFoldingEnabled(bool p_enabled); TextEditorConfig::InputMode getInputMode() const; void setInputMode(TextEditorConfig::InputMode p_mode); @@ -58,11 +58,14 @@ namespace vnotex void setWrapMode(TextEditorConfig::WrapMode p_mode); bool getExpandTabEnabled() const; - void setExpandTabEnabled(bool p_enable); + void setExpandTabEnabled(bool p_enabled); int getTabStopWidth() const; void setTabStopWidth(int p_width); + bool getHighlightWhitespaceEnabled() const; + void setHighlightWhitespaceEnabled(bool p_enabled); + int getZoomDelta() const; void setZoomDelta(int p_delta); @@ -96,6 +99,8 @@ namespace vnotex int m_tabStopWidth = 4; + bool m_highlightWhitespace = true; + int m_zoomDelta = 0; bool m_spellCheckEnabled = false; diff --git a/src/data/core/vnotex.json b/src/data/core/vnotex.json index 7751dc22..87322ba9 100644 --- a/src/data/core/vnotex.json +++ b/src/data/core/vnotex.json @@ -140,6 +140,7 @@ "wrap_mode": "word_anywhere", "expand_tab": true, "tab_stop_width": 4, + "highlight_whitespace": true, "//comment" : "Positive to zoom in and negative to zoom out", "zoom_delta": 0, "spell_check": false diff --git a/src/widgets/dialogs/settings/texteditorpage.cpp b/src/widgets/dialogs/settings/texteditorpage.cpp index 8a9cd819..07bed699 100644 --- a/src/widgets/dialogs/settings/texteditorpage.cpp +++ b/src/widgets/dialogs/settings/texteditorpage.cpp @@ -119,6 +119,16 @@ void TextEditorPage::setupUI() this, &TextEditorPage::pageIsChanged); } + { + const QString label(tr("Highlight whitespace")); + m_highlightWhitespaceCheckBox = WidgetsFactory::createCheckBox(label, this); + m_highlightWhitespaceCheckBox->setToolTip(tr("Highlight Tab and trailing space")); + mainLayout->addRow(m_highlightWhitespaceCheckBox); + addSearchItem(label, m_highlightWhitespaceCheckBox->toolTip(), m_highlightWhitespaceCheckBox); + connect(m_highlightWhitespaceCheckBox, &QCheckBox::stateChanged, + this, &TextEditorPage::pageIsChanged); + } + { m_zoomDeltaSpinBox = WidgetsFactory::createSpinBox(this); m_zoomDeltaSpinBox->setToolTip(tr("Zoom delta of the basic font size")); @@ -178,6 +188,8 @@ void TextEditorPage::loadInternal() m_tabStopWidthSpinBox->setValue(textConfig.getTabStopWidth()); + m_highlightWhitespaceCheckBox->setChecked(textConfig.getHighlightWhitespaceEnabled()); + m_zoomDeltaSpinBox->setValue(textConfig.getZoomDelta()); m_spellCheckCheckBox->setChecked(textConfig.isSpellCheckEnabled()); @@ -213,6 +225,8 @@ bool TextEditorPage::saveInternal() textConfig.setTabStopWidth(m_tabStopWidthSpinBox->value()); + textConfig.setHighlightWhitespaceEnabled(m_highlightWhitespaceCheckBox->isChecked()); + textConfig.setZoomDelta(m_zoomDeltaSpinBox->value()); textConfig.setSpellCheckEnabled(m_spellCheckCheckBox->isChecked()); diff --git a/src/widgets/dialogs/settings/texteditorpage.h b/src/widgets/dialogs/settings/texteditorpage.h index 51bd8067..6b214b4c 100644 --- a/src/widgets/dialogs/settings/texteditorpage.h +++ b/src/widgets/dialogs/settings/texteditorpage.h @@ -39,6 +39,8 @@ namespace vnotex QSpinBox *m_tabStopWidthSpinBox = nullptr; + QCheckBox *m_highlightWhitespaceCheckBox = nullptr; + QSpinBox *m_zoomDeltaSpinBox = nullptr; QCheckBox *m_spellCheckCheckBox = nullptr; diff --git a/src/widgets/textviewwindowhelper.h b/src/widgets/textviewwindowhelper.h index 07525827..c7e04e23 100644 --- a/src/widgets/textviewwindowhelper.h +++ b/src/widgets/textviewwindowhelper.h @@ -142,6 +142,8 @@ namespace vnotex editorConfig->m_expandTab = p_config.getExpandTabEnabled(); editorConfig->m_tabStopWidth = p_config.getTabStopWidth(); + editorConfig->m_highlightWhitespace = p_config.getHighlightWhitespaceEnabled(); + switch (p_lineEndingPolicy) { case LineEndingPolicy::Platform: editorConfig->m_lineEndingPolicy = vte::LineEndingPolicy::Platform;