enhancement: Auto check "only monospace font" when modify the first editor font.
This commit is contained in:
parent
0339baf069
commit
b2d88e27e0
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
#include "ui_editorfontdialog.h"
|
||||
#include <QAbstractItemView>
|
||||
|
||||
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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue