move custom web zoom factor to Read/Edit setting tab

This commit is contained in:
Le Tan 2018-01-18 19:50:25 +08:00
parent 97021fa7bc
commit 28e4818c26
2 changed files with 90 additions and 86 deletions

View File

@ -411,6 +411,25 @@ VReadEditTab::VReadEditTab(QWidget *p_parent)
m_readBox = new QGroupBox(tr("Read Mode (For Markdown Only)"));
m_editBox = new QGroupBox(tr("Edit Mode"));
// Web Zoom Factor.
m_customWebZoom = new QCheckBox(tr("Custom Web zoom factor"));
m_customWebZoom->setToolTip(tr("Set the zoom factor of the Web page when reading"));
m_webZoomFactorSpin = new QDoubleSpinBox();
m_webZoomFactorSpin->setMaximum(c_webZoomFactorMax);
m_webZoomFactorSpin->setMinimum(c_webZoomFactorMin);
m_webZoomFactorSpin->setSingleStep(0.25);
connect(m_customWebZoom, &QCheckBox::stateChanged,
this, [this](int p_state){
this->m_webZoomFactorSpin->setEnabled(p_state == Qt::Checked);
});
QHBoxLayout *zoomFactorLayout = new QHBoxLayout();
zoomFactorLayout->addWidget(m_customWebZoom);
zoomFactorLayout->addWidget(m_webZoomFactorSpin);
QVBoxLayout *readLayout = new QVBoxLayout();
readLayout->addLayout(zoomFactorLayout);
m_readBox->setLayout(readLayout);
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addWidget(m_readBox);
mainLayout->addWidget(m_editBox);
@ -419,11 +438,49 @@ VReadEditTab::VReadEditTab(QWidget *p_parent)
bool VReadEditTab::loadConfiguration()
{
if (!loadWebZoomFactor()) {
return false;
}
return true;
}
bool VReadEditTab::saveConfiguration()
{
if (!saveWebZoomFactor()) {
return false;
}
return true;
}
bool VReadEditTab::loadWebZoomFactor()
{
qreal factor = g_config->getWebZoomFactor();
bool customFactor = g_config->isCustomWebZoomFactor();
if (customFactor) {
if (factor < c_webZoomFactorMin || factor > c_webZoomFactorMax) {
factor = 1;
}
m_customWebZoom->setChecked(true);
m_webZoomFactorSpin->setValue(factor);
} else {
m_customWebZoom->setChecked(false);
m_webZoomFactorSpin->setValue(factor);
m_webZoomFactorSpin->setEnabled(false);
}
return true;
}
bool VReadEditTab::saveWebZoomFactor()
{
if (m_customWebZoom->isChecked()) {
g_config->setWebZoomFactor(m_webZoomFactorSpin->value());
} else {
g_config->setWebZoomFactor(-1);
}
return true;
}
@ -674,21 +731,6 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
headingSequenceLayout->addWidget(m_headingSequenceTypeCombo);
headingSequenceLayout->addWidget(m_headingSequenceLevelCombo);
// Web Zoom Factor.
m_customWebZoom = new QCheckBox(tr("Custom Web zoom factor"), this);
m_customWebZoom->setToolTip(tr("Set the zoom factor of the Web page when reading"));
m_webZoomFactorSpin = new QDoubleSpinBox(this);
m_webZoomFactorSpin->setMaximum(c_webZoomFactorMax);
m_webZoomFactorSpin->setMinimum(c_webZoomFactorMin);
m_webZoomFactorSpin->setSingleStep(0.25);
connect(m_customWebZoom, &QCheckBox::stateChanged,
this, [this](int p_state){
this->m_webZoomFactorSpin->setEnabled(p_state == Qt::Checked);
});
QHBoxLayout *zoomFactorLayout = new QHBoxLayout();
zoomFactorLayout->addWidget(m_customWebZoom);
zoomFactorLayout->addWidget(m_webZoomFactorSpin);
// Color column.
m_colorColumnEdit = new VLineEdit();
m_colorColumnEdit->setToolTip(tr("Specify the screen column in fenced code block "
@ -702,7 +744,6 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
QFormLayout *mainLayout = new QFormLayout();
mainLayout->addRow(tr("Note open mode:"), m_openModeCombo);
mainLayout->addRow(tr("Heading sequence:"), headingSequenceLayout);
mainLayout->addRow(zoomFactorLayout);
mainLayout->addRow(colorColumnLabel, m_colorColumnEdit);
setLayout(mainLayout);
@ -718,10 +759,6 @@ bool VMarkdownTab::loadConfiguration()
return false;
}
if (!loadWebZoomFactor()) {
return false;
}
if (!loadColorColumn()) {
return false;
}
@ -739,10 +776,6 @@ bool VMarkdownTab::saveConfiguration()
return false;
}
if (!saveWebZoomFactor()) {
return false;
}
if (!saveColorColumn()) {
return false;
}
@ -800,36 +833,6 @@ bool VMarkdownTab::saveHeadingSequence()
return true;
}
bool VMarkdownTab::loadWebZoomFactor()
{
qreal factor = g_config->getWebZoomFactor();
bool customFactor = g_config->isCustomWebZoomFactor();
if (customFactor) {
if (factor < c_webZoomFactorMin || factor > c_webZoomFactorMax) {
factor = 1;
}
m_customWebZoom->setChecked(true);
m_webZoomFactorSpin->setValue(factor);
} else {
m_customWebZoom->setChecked(false);
m_webZoomFactorSpin->setValue(factor);
m_webZoomFactorSpin->setEnabled(false);
}
return true;
}
bool VMarkdownTab::saveWebZoomFactor()
{
if (m_customWebZoom->isChecked()) {
g_config->setWebZoomFactor(m_webZoomFactorSpin->value());
} else {
g_config->setWebZoomFactor(-1);
}
return true;
}
bool VMarkdownTab::loadColorColumn()
{
int colorColumn = g_config->getColorColumn();

View File

@ -62,6 +62,14 @@ public:
bool loadConfiguration();
bool saveConfiguration();
private:
bool loadWebZoomFactor();
bool saveWebZoomFactor();
// Web zoom factor.
QCheckBox *m_customWebZoom;
QDoubleSpinBox *m_webZoomFactorSpin;
QGroupBox *m_readBox;
QGroupBox *m_editBox;
};
@ -74,21 +82,6 @@ public:
bool loadConfiguration();
bool saveConfiguration();
QGroupBox *m_noteBox;
QGroupBox *m_externalBox;
// Image folder.
QCheckBox *m_customImageFolder;
VLineEdit *m_imageFolderEdit;
// Image folder of External File.
QCheckBox *m_customImageFolderExt;
VLineEdit *m_imageFolderEditExt;
// Attachment folder.
QCheckBox *m_customAttachmentFolder;
VLineEdit *m_attachmentFolderEdit;
private slots:
void customImageFolderChanged(int p_state);
void customImageFolderExtChanged(int p_state);
@ -103,6 +96,21 @@ private:
bool loadAttachmentFolder();
bool saveAttachmentFolder();
QGroupBox *m_noteBox;
QGroupBox *m_externalBox;
// Image folder.
QCheckBox *m_customImageFolder;
VLineEdit *m_imageFolderEdit;
// Image folder of External File.
QCheckBox *m_customImageFolderExt;
VLineEdit *m_imageFolderEditExt;
// Attachment folder.
QCheckBox *m_customAttachmentFolder;
VLineEdit *m_attachmentFolderEdit;
};
class VMarkdownTab : public QWidget
@ -113,20 +121,6 @@ public:
bool loadConfiguration();
bool saveConfiguration();
// Default note open mode for markdown.
QComboBox *m_openModeCombo;
// Whether enable heading sequence.
QComboBox *m_headingSequenceTypeCombo;
QComboBox *m_headingSequenceLevelCombo;
// Web zoom factor.
QCheckBox *m_customWebZoom;
QDoubleSpinBox *m_webZoomFactorSpin;
// Color column in code block.
VLineEdit *m_colorColumnEdit;
private:
bool loadOpenMode();
bool saveOpenMode();
@ -134,11 +128,18 @@ private:
bool loadHeadingSequence();
bool saveHeadingSequence();
bool loadWebZoomFactor();
bool saveWebZoomFactor();
bool loadColorColumn();
bool saveColorColumn();
// Default note open mode for markdown.
QComboBox *m_openModeCombo;
// Whether enable heading sequence.
QComboBox *m_headingSequenceTypeCombo;
QComboBox *m_headingSequenceLevelCombo;
// Color column in code block.
VLineEdit *m_colorColumnEdit;
};
class VSettingsDialog : public QDialog