From 1f7acf2bc557a72779cfbe63edb896e943cab06f Mon Sep 17 00:00:00 2001 From: Le Tan Date: Thu, 24 Dec 2020 20:18:14 +0800 Subject: [PATCH] Settings: expose zoom delta and zoom factor configs --- .../dialogs/settings/markdowneditorpage.cpp | 19 +++++++++++++++++++ .../dialogs/settings/markdowneditorpage.h | 3 +++ .../dialogs/settings/texteditorpage.cpp | 18 ++++++++++++++++++ src/widgets/dialogs/settings/texteditorpage.h | 2 ++ 4 files changed, 42 insertions(+) diff --git a/src/widgets/dialogs/settings/markdowneditorpage.cpp b/src/widgets/dialogs/settings/markdowneditorpage.cpp index 4363751e..27ed8ee0 100644 --- a/src/widgets/dialogs/settings/markdowneditorpage.cpp +++ b/src/widgets/dialogs/settings/markdowneditorpage.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,8 @@ void MarkdownEditorPage::loadInternal() m_constrainImageWidthCheckBox->setChecked(markdownConfig.getConstrainImageWidthEnabled()); + m_zoomFactorSpinBox->setValue(markdownConfig.getZoomFactorInReadMode()); + m_constrainInPlacePreviewWidthCheckBox->setChecked(markdownConfig.getConstrainInPlacePreviewWidthEnabled()); m_fetchImagesToLocalCheckBox->setChecked(markdownConfig.getFetchImagesInParseAndPaste()); @@ -62,6 +65,8 @@ void MarkdownEditorPage::saveInternal() markdownConfig.setConstrainImageWidthEnabled(m_constrainImageWidthCheckBox->isChecked()); + markdownConfig.setZoomFactorInReadMode(m_zoomFactorSpinBox->value()); + markdownConfig.setConstrainInPlacePreviewWidthEnabled(m_constrainInPlacePreviewWidthCheckBox->isChecked()); markdownConfig.setFetchImagesInParseAndPaste(m_fetchImagesToLocalCheckBox->isChecked()); @@ -105,6 +110,20 @@ QGroupBox *MarkdownEditorPage::setupReadGroup() this, &MarkdownEditorPage::pageIsChanged); } + { + m_zoomFactorSpinBox = WidgetsFactory::createDoubleSpinBox(box); + m_zoomFactorSpinBox->setToolTip(tr("Zoom factor in read mode")); + + m_zoomFactorSpinBox->setRange(0.25, 10); + m_zoomFactorSpinBox->setSingleStep(0.25); + + const QString label(tr("Zoom factor:")); + layout->addRow(label, m_zoomFactorSpinBox); + addSearchItem(label, m_zoomFactorSpinBox->toolTip(), m_zoomFactorSpinBox); + connect(m_zoomFactorSpinBox, QOverload::of(&QDoubleSpinBox::valueChanged), + this, &MarkdownEditorPage::pageIsChanged); + } + { const QString label(tr("HTML tag")); m_htmlTagCheckBox = WidgetsFactory::createCheckBox(label, box); diff --git a/src/widgets/dialogs/settings/markdowneditorpage.h b/src/widgets/dialogs/settings/markdowneditorpage.h index 57880257..c80d29cf 100644 --- a/src/widgets/dialogs/settings/markdowneditorpage.h +++ b/src/widgets/dialogs/settings/markdowneditorpage.h @@ -5,6 +5,7 @@ class QCheckBox; class QGroupBox; +class QDoubleSpinBox; namespace vnotex { @@ -43,6 +44,8 @@ namespace vnotex QCheckBox *m_autoBreakCheckBox = nullptr; QCheckBox *m_linkifyCheckBox = nullptr; + + QDoubleSpinBox *m_zoomFactorSpinBox = nullptr; }; } diff --git a/src/widgets/dialogs/settings/texteditorpage.cpp b/src/widgets/dialogs/settings/texteditorpage.cpp index 7dac0a9d..8d257d10 100644 --- a/src/widgets/dialogs/settings/texteditorpage.cpp +++ b/src/widgets/dialogs/settings/texteditorpage.cpp @@ -117,6 +117,20 @@ void TextEditorPage::setupUI() connect(m_tabStopWidthSpinBox, QOverload::of(&QSpinBox::valueChanged), this, &TextEditorPage::pageIsChanged); } + + { + m_zoomDeltaSpinBox = WidgetsFactory::createSpinBox(this); + m_zoomDeltaSpinBox->setToolTip(tr("Zoom delta of the basic font size")); + + m_zoomDeltaSpinBox->setRange(-20, 20); + m_zoomDeltaSpinBox->setSingleStep(1); + + const QString label(tr("Zoom delta:")); + mainLayout->addRow(label, m_zoomDeltaSpinBox); + addSearchItem(label, m_zoomDeltaSpinBox->toolTip(), m_zoomDeltaSpinBox); + connect(m_zoomDeltaSpinBox, QOverload::of(&QSpinBox::valueChanged), + this, &TextEditorPage::pageIsChanged); + } } void TextEditorPage::loadInternal() @@ -152,6 +166,8 @@ void TextEditorPage::loadInternal() m_expandTabCheckBox->setChecked(textConfig.getExpandTabEnabled()); m_tabStopWidthSpinBox->setValue(textConfig.getTabStopWidth()); + + m_zoomDeltaSpinBox->setValue(textConfig.getZoomDelta()); } void TextEditorPage::saveInternal() @@ -184,6 +200,8 @@ void TextEditorPage::saveInternal() textConfig.setTabStopWidth(m_tabStopWidthSpinBox->value()); + textConfig.setZoomDelta(m_zoomDeltaSpinBox->value()); + EditorPage::notifyEditorConfigChange(); } diff --git a/src/widgets/dialogs/settings/texteditorpage.h b/src/widgets/dialogs/settings/texteditorpage.h index 77716614..3a931b04 100644 --- a/src/widgets/dialogs/settings/texteditorpage.h +++ b/src/widgets/dialogs/settings/texteditorpage.h @@ -38,6 +38,8 @@ namespace vnotex QCheckBox *m_expandTabCheckBox = nullptr; QSpinBox *m_tabStopWidthSpinBox = nullptr; + + QSpinBox *m_zoomDeltaSpinBox = nullptr; }; }