Skip to content

Commit

Permalink
Github Issue #39: Added buttons to increment and drecement font sizes…
Browse files Browse the repository at this point in the history
… by 1. Also added limit to font sizes from 7 to 30
  • Loading branch information
AngryFender committed Feb 18, 2024
1 parent 9782d8a commit 6135496
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 0 additions & 2 deletions mkedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 3 additions & 0 deletions mktextdocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#include <QUndoStack>


#define MAXIMUM_FONT_SIZE 30
#define MINIMUM_FONT_SIZE 7

class FormatCollection{
public:
FormatCollection(int fontSize){
Expand Down
16 changes: 16 additions & 0 deletions settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 19 additions & 1 deletion settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,25 @@ li.checked::marker { content: &quot;\2612&quot;; }
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="ledit_font_size"/>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="ledit_font_size"/>
</item>
<item>
<widget class="QPushButton" name="btn_plus">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_minus">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
Expand Down

0 comments on commit 6135496

Please sign in to comment.