diff --git a/src/kfontchooser.cpp b/src/kfontchooser.cpp --- a/src/kfontchooser.cpp +++ b/src/kfontchooser.cpp @@ -129,6 +129,8 @@ QListWidget *sizeListBox = nullptr; QCheckBox *sizeIsRelativeCheckBox = nullptr; + QCheckBox *onlyFixedCheckbox = nullptr; + QFont selFont; QString selectedStyle; @@ -344,8 +346,6 @@ // Completed the font attributes grid - ++row; - // Add the font preview into the lower part of mainLayout sampleEdit = new QTextEdit(page); sampleEdit->setAcceptRichText(false); @@ -368,6 +368,22 @@ }); mainLayout->addWidget(sampleEdit); + + // Add a checkbox to toggle showing only monospace/fixed-width fonts + onlyFixedCheckbox = new QCheckBox(KFontChooser::tr("Show only monospaced fonts", "@option:check")); + onlyFixedCheckbox->setEnabled(flags ^ ShowDifferences); + + connect(onlyFixedCheckbox, &QAbstractButton::toggled, q, [this](const bool state) { + q->setFont(selFont, state); + }); + + if (flags & ShowDifferences) { // In this mode follow the state of the familyCheckbox + connect(familyCheckbox, &QAbstractButton::toggled, q, [this](const bool state) { + onlyFixedCheckbox->setEnabled(state); + }); + } + mainLayout->addWidget(onlyFixedCheckbox); + // Finished setting up the chooser layout // lets initialize the display if possible