mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
TextEditor: add config for highlighting tab and trailing space
This commit is contained in:
parent
47a49b7bb2
commit
86df5c39a2
@ -1 +1 @@
|
|||||||
Subproject commit 6c2ff0e78aedb6d4a107cd4825473d47813596cc
|
Subproject commit 00b52913fe8f4ccf5ed5a0cbd3493b94fe354b25
|
@ -118,5 +118,4 @@ QString MainConfig::getVersion(const QJsonObject &p_jobj)
|
|||||||
void MainConfig::doVersionSpecificOverride()
|
void MainConfig::doVersionSpecificOverride()
|
||||||
{
|
{
|
||||||
// In a new version, we may want to change one value by force.
|
// In a new version, we may want to change one value by force.
|
||||||
m_coreConfig->m_docksTabBarIconSize = 26;
|
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ void TextEditorConfig::init(const QJsonObject &p_app,
|
|||||||
|
|
||||||
m_tabStopWidth = READINT(QStringLiteral("tab_stop_width"));
|
m_tabStopWidth = READINT(QStringLiteral("tab_stop_width"));
|
||||||
|
|
||||||
|
m_highlightWhitespace = READBOOL(QStringLiteral("highlight_whitespace"));
|
||||||
|
|
||||||
m_zoomDelta = READINT(QStringLiteral("zoom_delta"));
|
m_zoomDelta = READINT(QStringLiteral("zoom_delta"));
|
||||||
|
|
||||||
m_spellCheckEnabled = READBOOL(QStringLiteral("spell_check"));
|
m_spellCheckEnabled = READBOOL(QStringLiteral("spell_check"));
|
||||||
@ -59,6 +61,7 @@ QJsonObject TextEditorConfig::toJson() const
|
|||||||
obj[QStringLiteral("wrap_mode")] = wrapModeToString(m_wrapMode);
|
obj[QStringLiteral("wrap_mode")] = wrapModeToString(m_wrapMode);
|
||||||
obj[QStringLiteral("expand_tab")] = m_expandTab;
|
obj[QStringLiteral("expand_tab")] = m_expandTab;
|
||||||
obj[QStringLiteral("tab_stop_width")] = m_tabStopWidth;
|
obj[QStringLiteral("tab_stop_width")] = m_tabStopWidth;
|
||||||
|
obj[QStringLiteral("highlight_whitespace")] = m_highlightWhitespace;
|
||||||
obj[QStringLiteral("zoom_delta")] = m_zoomDelta;
|
obj[QStringLiteral("zoom_delta")] = m_zoomDelta;
|
||||||
obj[QStringLiteral("spell_check")] = m_spellCheckEnabled;
|
obj[QStringLiteral("spell_check")] = m_spellCheckEnabled;
|
||||||
return obj;
|
return obj;
|
||||||
@ -183,9 +186,9 @@ bool TextEditorConfig::getTextFoldingEnabled() const
|
|||||||
return m_textFoldingEnabled;
|
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
|
TextEditorConfig::InputMode TextEditorConfig::getInputMode() const
|
||||||
@ -223,9 +226,19 @@ bool TextEditorConfig::getExpandTabEnabled() const
|
|||||||
return m_expandTab;
|
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
|
int TextEditorConfig::getTabStopWidth() const
|
||||||
|
@ -46,7 +46,7 @@ namespace vnotex
|
|||||||
void setLineNumberType(TextEditorConfig::LineNumberType p_type);
|
void setLineNumberType(TextEditorConfig::LineNumberType p_type);
|
||||||
|
|
||||||
bool getTextFoldingEnabled() const;
|
bool getTextFoldingEnabled() const;
|
||||||
void setTextFoldingEnabled(bool p_enable);
|
void setTextFoldingEnabled(bool p_enabled);
|
||||||
|
|
||||||
TextEditorConfig::InputMode getInputMode() const;
|
TextEditorConfig::InputMode getInputMode() const;
|
||||||
void setInputMode(TextEditorConfig::InputMode p_mode);
|
void setInputMode(TextEditorConfig::InputMode p_mode);
|
||||||
@ -58,11 +58,14 @@ namespace vnotex
|
|||||||
void setWrapMode(TextEditorConfig::WrapMode p_mode);
|
void setWrapMode(TextEditorConfig::WrapMode p_mode);
|
||||||
|
|
||||||
bool getExpandTabEnabled() const;
|
bool getExpandTabEnabled() const;
|
||||||
void setExpandTabEnabled(bool p_enable);
|
void setExpandTabEnabled(bool p_enabled);
|
||||||
|
|
||||||
int getTabStopWidth() const;
|
int getTabStopWidth() const;
|
||||||
void setTabStopWidth(int p_width);
|
void setTabStopWidth(int p_width);
|
||||||
|
|
||||||
|
bool getHighlightWhitespaceEnabled() const;
|
||||||
|
void setHighlightWhitespaceEnabled(bool p_enabled);
|
||||||
|
|
||||||
int getZoomDelta() const;
|
int getZoomDelta() const;
|
||||||
void setZoomDelta(int p_delta);
|
void setZoomDelta(int p_delta);
|
||||||
|
|
||||||
@ -96,6 +99,8 @@ namespace vnotex
|
|||||||
|
|
||||||
int m_tabStopWidth = 4;
|
int m_tabStopWidth = 4;
|
||||||
|
|
||||||
|
bool m_highlightWhitespace = true;
|
||||||
|
|
||||||
int m_zoomDelta = 0;
|
int m_zoomDelta = 0;
|
||||||
|
|
||||||
bool m_spellCheckEnabled = false;
|
bool m_spellCheckEnabled = false;
|
||||||
|
@ -140,6 +140,7 @@
|
|||||||
"wrap_mode": "word_anywhere",
|
"wrap_mode": "word_anywhere",
|
||||||
"expand_tab": true,
|
"expand_tab": true,
|
||||||
"tab_stop_width": 4,
|
"tab_stop_width": 4,
|
||||||
|
"highlight_whitespace": true,
|
||||||
"//comment" : "Positive to zoom in and negative to zoom out",
|
"//comment" : "Positive to zoom in and negative to zoom out",
|
||||||
"zoom_delta": 0,
|
"zoom_delta": 0,
|
||||||
"spell_check": false
|
"spell_check": false
|
||||||
|
@ -119,6 +119,16 @@ void TextEditorPage::setupUI()
|
|||||||
this, &TextEditorPage::pageIsChanged);
|
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 = WidgetsFactory::createSpinBox(this);
|
||||||
m_zoomDeltaSpinBox->setToolTip(tr("Zoom delta of the basic font size"));
|
m_zoomDeltaSpinBox->setToolTip(tr("Zoom delta of the basic font size"));
|
||||||
@ -178,6 +188,8 @@ void TextEditorPage::loadInternal()
|
|||||||
|
|
||||||
m_tabStopWidthSpinBox->setValue(textConfig.getTabStopWidth());
|
m_tabStopWidthSpinBox->setValue(textConfig.getTabStopWidth());
|
||||||
|
|
||||||
|
m_highlightWhitespaceCheckBox->setChecked(textConfig.getHighlightWhitespaceEnabled());
|
||||||
|
|
||||||
m_zoomDeltaSpinBox->setValue(textConfig.getZoomDelta());
|
m_zoomDeltaSpinBox->setValue(textConfig.getZoomDelta());
|
||||||
|
|
||||||
m_spellCheckCheckBox->setChecked(textConfig.isSpellCheckEnabled());
|
m_spellCheckCheckBox->setChecked(textConfig.isSpellCheckEnabled());
|
||||||
@ -213,6 +225,8 @@ bool TextEditorPage::saveInternal()
|
|||||||
|
|
||||||
textConfig.setTabStopWidth(m_tabStopWidthSpinBox->value());
|
textConfig.setTabStopWidth(m_tabStopWidthSpinBox->value());
|
||||||
|
|
||||||
|
textConfig.setHighlightWhitespaceEnabled(m_highlightWhitespaceCheckBox->isChecked());
|
||||||
|
|
||||||
textConfig.setZoomDelta(m_zoomDeltaSpinBox->value());
|
textConfig.setZoomDelta(m_zoomDeltaSpinBox->value());
|
||||||
|
|
||||||
textConfig.setSpellCheckEnabled(m_spellCheckCheckBox->isChecked());
|
textConfig.setSpellCheckEnabled(m_spellCheckCheckBox->isChecked());
|
||||||
|
@ -39,6 +39,8 @@ namespace vnotex
|
|||||||
|
|
||||||
QSpinBox *m_tabStopWidthSpinBox = nullptr;
|
QSpinBox *m_tabStopWidthSpinBox = nullptr;
|
||||||
|
|
||||||
|
QCheckBox *m_highlightWhitespaceCheckBox = nullptr;
|
||||||
|
|
||||||
QSpinBox *m_zoomDeltaSpinBox = nullptr;
|
QSpinBox *m_zoomDeltaSpinBox = nullptr;
|
||||||
|
|
||||||
QCheckBox *m_spellCheckCheckBox = nullptr;
|
QCheckBox *m_spellCheckCheckBox = nullptr;
|
||||||
|
@ -142,6 +142,8 @@ namespace vnotex
|
|||||||
editorConfig->m_expandTab = p_config.getExpandTabEnabled();
|
editorConfig->m_expandTab = p_config.getExpandTabEnabled();
|
||||||
editorConfig->m_tabStopWidth = p_config.getTabStopWidth();
|
editorConfig->m_tabStopWidth = p_config.getTabStopWidth();
|
||||||
|
|
||||||
|
editorConfig->m_highlightWhitespace = p_config.getHighlightWhitespaceEnabled();
|
||||||
|
|
||||||
switch (p_lineEndingPolicy) {
|
switch (p_lineEndingPolicy) {
|
||||||
case LineEndingPolicy::Platform:
|
case LineEndingPolicy::Platform:
|
||||||
editorConfig->m_lineEndingPolicy = vte::LineEndingPolicy::Platform;
|
editorConfig->m_lineEndingPolicy = vte::LineEndingPolicy::Platform;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user