diff --git a/RedPandaIDE/settingsdialog/editorfontwidget.cpp b/RedPandaIDE/settingsdialog/editorfontwidget.cpp index 082fdaef..d993d1ba 100644 --- a/RedPandaIDE/settingsdialog/editorfontwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorfontwidget.cpp @@ -72,7 +72,7 @@ void EditorFontWidget::on_btnAddFont_clicked() { QModelIndex index = ui->lstFontList->currentIndex(); int insertPos = index.isValid() ? index.row() + 1 : mModel.rowCount(); - EditorFontDialog dlg(this); + EditorFontDialog dlg(insertPos==0, this); if (dlg.exec() == QDialog::Accepted) { mModel.insertRow(insertPos); mModel.setData(mModel.index(insertPos), dlg.fontFamily()); @@ -91,13 +91,7 @@ void EditorFontWidget::on_btnRemoveFont_clicked() void EditorFontWidget::on_btnModifyFont_clicked() { QModelIndex index = ui->lstFontList->currentIndex(); - if (!index.isValid()) - return; - EditorFontDialog dlg(this); - dlg.setFontFamily(mModel.data(index, Qt::DisplayRole).toString()); - if (dlg.exec() == QDialog::Accepted) { - mModel.setData(index, dlg.fontFamily()); - } + modifyFont(index); } void EditorFontWidget::on_btnResetFonts_clicked() @@ -216,10 +210,15 @@ void EditorFontWidget::updateIcons(const QSize &/*size*/) { } void EditorFontWidget::on_lstFontList_doubleClicked(const QModelIndex &index) +{ + modifyFont(index); +} + +void EditorFontWidget::modifyFont(const QModelIndex &index) { if (!index.isValid()) return; - EditorFontDialog dlg(this); + EditorFontDialog dlg(index.row()==0, this); dlg.setFontFamily(mModel.data(index, Qt::DisplayRole).toString()); if (dlg.exec() == QDialog::Accepted) { mModel.setData(index, dlg.fontFamily()); diff --git a/RedPandaIDE/settingsdialog/editorfontwidget.h b/RedPandaIDE/settingsdialog/editorfontwidget.h index 89531dcc..233d2b20 100644 --- a/RedPandaIDE/settingsdialog/editorfontwidget.h +++ b/RedPandaIDE/settingsdialog/editorfontwidget.h @@ -58,7 +58,8 @@ private slots: // void on_chkForceFixedFontWidth_toggled(bool checked); void on_lstFontList_doubleClicked(const QModelIndex &index); - +private: + void modifyFont(const QModelIndex &index); private: Ui::EditorFontWidget *ui; EditorFontModel mModel; diff --git a/RedPandaIDE/widgets/editorfontdialog.cpp b/RedPandaIDE/widgets/editorfontdialog.cpp index 431ef326..378d89f3 100644 --- a/RedPandaIDE/widgets/editorfontdialog.cpp +++ b/RedPandaIDE/widgets/editorfontdialog.cpp @@ -2,11 +2,13 @@ #include "ui_editorfontdialog.h" #include -EditorFontDialog::EditorFontDialog(QWidget *parent) +EditorFontDialog::EditorFontDialog(bool onlyMonospaceFont, QWidget *parent) : QDialog(parent) , ui(new Ui::EditorFontDialog) { ui->setupUi(this); + ui->chkMonoOnly->setChecked(onlyMonospaceFont); + ui->fontComboBox->setFontFilters(onlyMonospaceFont ? QFontComboBox::MonospacedFonts : QFontComboBox::AllFonts); } EditorFontDialog::~EditorFontDialog() diff --git a/RedPandaIDE/widgets/editorfontdialog.h b/RedPandaIDE/widgets/editorfontdialog.h index 1239e78d..f2f4023e 100644 --- a/RedPandaIDE/widgets/editorfontdialog.h +++ b/RedPandaIDE/widgets/editorfontdialog.h @@ -12,7 +12,7 @@ class EditorFontDialog : public QDialog Q_OBJECT public: - explicit EditorFontDialog(QWidget *parent = nullptr); + explicit EditorFontDialog(bool onlyMonospaceFont, QWidget *parent = nullptr); ~EditorFontDialog(); QString fontFamily() const;