소스 검색

Settings: expose zoom delta and zoom factor configs

Le Tan 4 년 전
부모
커밋
1f7acf2bc5

+ 19 - 0
src/widgets/dialogs/settings/markdowneditorpage.cpp

@@ -4,6 +4,7 @@
 #include <QVBoxLayout>
 #include <QCheckBox>
 #include <QGroupBox>
+#include <QDoubleSpinBox>
 
 #include <widgets/widgetsfactory.h>
 #include <core/editorconfig.h>
@@ -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<double>::of(&QDoubleSpinBox::valueChanged),
+                this, &MarkdownEditorPage::pageIsChanged);
+    }
+
     {
         const QString label(tr("HTML tag"));
         m_htmlTagCheckBox = WidgetsFactory::createCheckBox(label, box);

+ 3 - 0
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;
     };
 }
 

+ 18 - 0
src/widgets/dialogs/settings/texteditorpage.cpp

@@ -117,6 +117,20 @@ void TextEditorPage::setupUI()
         connect(m_tabStopWidthSpinBox, QOverload<int>::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<int>::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();
 }
 

+ 2 - 0
src/widgets/dialogs/settings/texteditorpage.h

@@ -38,6 +38,8 @@ namespace vnotex
         QCheckBox *m_expandTabCheckBox = nullptr;
 
         QSpinBox *m_tabStopWidthSpinBox = nullptr;
+
+        QSpinBox *m_zoomDeltaSpinBox = nullptr;
     };
 }