From 6135496a4371d129ad5931e9f9bd87f4302aca39 Mon Sep 17 00:00:00 2001 From: AngryFender Date: Sun, 18 Feb 2024 18:42:10 +0000 Subject: [PATCH] Github Issue #39: Added buttons to increment and drecement font sizes by 1. Also added limit to font sizes from 7 to 30 --- mkedit.h | 2 -- mktextdocument.h | 3 +++ settingsdialog.cpp | 16 ++++++++++++++++ settingsdialog.ui | 20 +++++++++++++++++++- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/mkedit.h b/mkedit.h index 633741b..d3c3bf0 100644 --- a/mkedit.h +++ b/mkedit.h @@ -16,8 +16,6 @@ #define FILE_SAVE_TIMEOUT 300 #define BLOCKRADIUS 4 -#define MAXIMUM_FONT_SIZE 40 -#define MINIMUM_FONT_SIZE 8 class MkEdit : public QTextEdit { diff --git a/mktextdocument.h b/mktextdocument.h index 3855a0b..241fc52 100644 --- a/mktextdocument.h +++ b/mktextdocument.h @@ -21,6 +21,9 @@ #include +#define MAXIMUM_FONT_SIZE 30 +#define MINIMUM_FONT_SIZE 7 + class FormatCollection{ public: FormatCollection(int fontSize){ diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 3f26af4..a62cdcd 100644 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -59,6 +59,22 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QObject::connect(ui->btn_dialog,&QDialogButtonBox::accepted, this,&SettingsDialog::saveSettingsHandler); + + QObject::connect(ui->btn_plus,&QPushButton::clicked, + this,[this]() + { + int size = this->ui->ledit_font_size->text().toInt(); + size = std::min(MAXIMUM_FONT_SIZE,size+1); + ui->ledit_font_size->setText(QString::number(size)); + }); + + QObject::connect(ui->btn_minus,&QPushButton::clicked, + this,[this]() + { + int size = this->ui->ledit_font_size->text().toInt(); + size = std::max(MINIMUM_FONT_SIZE,size-1); + ui->ledit_font_size->setText(QString::number(size)); + }); } void SettingsDialog::setFont(const QFont &font) diff --git a/settingsdialog.ui b/settingsdialog.ui index bd44698..d0202e8 100644 --- a/settingsdialog.ui +++ b/settingsdialog.ui @@ -119,7 +119,25 @@ li.checked::marker { content: "\2612"; } - + + + + + + + + + + + + + + + + - + + + +