2024-03-17 11:18:09 +08:00
|
|
|
#include "editorfontdialog.h"
|
|
|
|
#include "ui_editorfontdialog.h"
|
2024-03-20 21:40:06 +08:00
|
|
|
#include <QAbstractItemView>
|
2024-03-17 11:18:09 +08:00
|
|
|
|
2024-03-25 17:40:19 +08:00
|
|
|
EditorFontDialog::EditorFontDialog(bool onlyMonospaceFont, QWidget *parent)
|
2024-03-17 11:18:09 +08:00
|
|
|
: QDialog(parent)
|
|
|
|
, ui(new Ui::EditorFontDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2024-03-25 17:40:19 +08:00
|
|
|
ui->chkMonoOnly->setChecked(onlyMonospaceFont);
|
|
|
|
ui->fontComboBox->setFontFilters(onlyMonospaceFont ? QFontComboBox::MonospacedFonts : QFontComboBox::AllFonts);
|
2024-03-17 11:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorFontDialog::~EditorFontDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EditorFontDialog::fontFamily() const
|
|
|
|
{
|
|
|
|
return mFontFamily;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorFontDialog::setFontFamily(const QString &fontFamily)
|
|
|
|
{
|
|
|
|
mFontFamily = fontFamily;
|
|
|
|
ui->fontComboBox->setCurrentFont(QFont(mFontFamily));
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorFontDialog::on_chkMonoOnly_toggled(bool checked)
|
|
|
|
{
|
|
|
|
QString savedFont = ui->fontComboBox->currentFont().family();
|
|
|
|
ui->fontComboBox->setFontFilters(checked ? QFontComboBox::MonospacedFonts : QFontComboBox::AllFonts);
|
2024-03-20 21:40:06 +08:00
|
|
|
ui->fontComboBox->view()->reset();
|
2024-03-17 11:18:09 +08:00
|
|
|
ui->fontComboBox->setCurrentFont(QFont(savedFont));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EditorFontDialog::on_buttonBox_accepted()
|
|
|
|
{
|
|
|
|
mFontFamily = ui->fontComboBox->currentFont().family();
|
|
|
|
}
|
|
|
|
|