diff --git a/settingsdialog.cpp b/settingsdialog.cpp index d3f369a..abd2738 100644 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -12,14 +12,48 @@ SettingsDialog::SettingsDialog(QWidget *parent) : previewHighligher.setDocument(&this->previewDocument) ; ui->txt_preview->setDocument(&this->previewDocument); + ui->cmb_theme->addItem("Light Theme"); + ui->cmb_theme->addItem("Dark Theme"); + + ui->cmb_stretch->addItem("AnyStretch"); + ui->cmb_stretch->addItem("UltraCondensed"); + ui->cmb_stretch->addItem("ExtraCondensed"); + ui->cmb_stretch->addItem("Condensed"); + ui->cmb_stretch->addItem("SemiCondensed"); + ui->cmb_stretch->addItem("Unstretched"); + ui->cmb_stretch->addItem("SemiExpanded"); + ui->cmb_stretch->addItem("Expanded"); + ui->cmb_stretch->addItem("ExtraExpanded"); + ui->cmb_stretch->addItem("UltraExpanded"); + + ui->cmb_weight->addItem("Thin"); + ui->cmb_weight->addItem("ExtraLight"); + ui->cmb_weight->addItem("Light"); + ui->cmb_weight->addItem("Normal"); + ui->cmb_weight->addItem("Medium"); + ui->cmb_weight->addItem("DemiBold"); + ui->cmb_weight->addItem("Bold"); + ui->cmb_weight->addItem("ExtraBold"); + ui->cmb_weight->addItem("Black"); + + ui->ledit_font_size->setValidator(new QIntValidator(6,30,ui->ledit_font_size)); QObject::connect(ui->btn_vaultRootPath, &QPushButton::pressed, - this, &SettingsDialog::executeFolderDialog); + this, &SettingsDialog::executeFolderDialog); QObject::connect(this,&SettingsDialog::syntaxColorUpdate, - &previewHighligher,&Highlighter::syntaxColorUpdateHandler); + &previewHighligher,&Highlighter::syntaxColorUpdateHandler); - ui->cmb_theme->addItem("Light Theme"); - ui->cmb_theme->addItem("Dark Theme"); + QObject::connect(ui->cmb_font,&QFontComboBox::currentFontChanged, + this, &SettingsDialog::updateFontHandler); + + QObject::connect(ui->ledit_font_size,&QLineEdit::textChanged, + this, &SettingsDialog::updateFontSizeHandler); + + QObject::connect(ui->cmb_stretch,&QComboBox::currentIndexChanged, + this, &SettingsDialog::updateStretchHandler); + + QObject::connect(ui->cmb_weight,&QComboBox::currentIndexChanged, + this, &SettingsDialog::updateWeightHandler); } SettingsDialog::~SettingsDialog() @@ -40,6 +74,55 @@ void SettingsDialog::executeFolderDialog() } } +void SettingsDialog::updateFontHandler(const QFont &f) +{ + ui->txt_preview->setFont(f); + ui->txt_preview->update(); +} + +void SettingsDialog::updateFontSizeHandler(const QString &text) +{ + QFont font = ui->txt_preview->font(); + font.setPointSize(text.toInt()); + ui->txt_preview->setFont(font); +} + +void SettingsDialog::updateStretchHandler(const int index) +{ + QFont font = ui->txt_preview->font(); + switch(index){ + case 0: font.setStretch(QFont::AnyStretch);break; + case 1: font.setStretch(QFont::UltraCondensed);break; + case 2: font.setStretch(QFont::ExtraCondensed);break; + case 3: font.setStretch(QFont::Condensed);break; + case 4: font.setStretch(QFont::SemiCondensed);break; + case 5: font.setStretch(QFont::Unstretched);break; + case 6: font.setStretch(QFont::SemiExpanded);break; + case 7: font.setStretch(QFont::Expanded);break; + case 8: font.setStretch(QFont::ExtraExpanded);break; + case 9: font.setStretch(QFont::UltraExpanded);break; + default: break; + } + ui->txt_preview->setFont(font); +} + +void SettingsDialog::updateWeightHandler(const int weight) +{ + QFont font = ui->txt_preview->font(); + switch(weight){ + case 0: font.setWeight(QFont::Thin);break; + case 1: font.setWeight(QFont::Light);break; + case 2: font.setWeight(QFont::Normal);break; + case 3: font.setWeight(QFont::Medium);break; + case 4: font.setWeight(QFont::DemiBold);break; + case 5: font.setWeight(QFont::Bold);break; + case 6: font.setWeight(QFont::ExtraBold);break; + case 7: font.setWeight(QFont::Black);break; + default: break; + } + ui->txt_preview->setFont(font); +} + void SettingsDialog::syntaxColorUpdateHandler(HighlightColor &colors) { this->previewColors = colors; diff --git a/settingsdialog.h b/settingsdialog.h index 8c5e0ee..0d3ded5 100644 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -35,6 +35,10 @@ class SettingsDialog : public QDialog void syntaxColorUpdate(HighlightColor &colors); private slots: void executeFolderDialog(); + void updateFontHandler(const QFont &f); + void updateFontSizeHandler(const QString &text ); + void updateStretchHandler(const int index); + void updateWeightHandler(const int index); public slots: void syntaxColorUpdateHandler(HighlightColor &colors); void show(); diff --git a/settingsdialog.ui b/settingsdialog.ui index 82762f7..283120e 100644 --- a/settingsdialog.ui +++ b/settingsdialog.ui @@ -41,23 +41,60 @@ - + - Font + Theme + + + - + - Theme + Font - + - + + + + Font Size + + + + + + + Stretch + + + + + + + + + + Weight + + + + + + + + + + Preview + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> @@ -71,21 +108,21 @@ li.checked::marker { content: "\2612"; } - - + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - -