Commit 2bdc7833 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Allow non monospaced fonts to be selected

Due to various issues outside the scope of Konsole, some monospaced
fonts are not allowed to be selected.  The default is still to only
allow system found monospaced fonts but users can bypass to allow any
font to be picked. There is a warning about issues when doing this.

CCBUG: 349350
(cherry picked from commit fa5f32f1)
parent e5887db2
......@@ -434,6 +434,10 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
_ui->fontPreviewLabel->setFont(profileFont);
setFontInputValue(profileFont);
// Always set to unchecked
_ui->showAllFontsButton->setChecked(false);
connect(_ui->showAllFontsButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::showAllFontsButtonWarning);
connect(_ui->fontSizeInput, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &Konsole::EditProfileDialog::setFontSize);
connect(_ui->selectFontButton, &QPushButton::clicked, this, &Konsole::EditProfileDialog::showFontDialog);
......@@ -446,6 +450,16 @@ void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile)
_ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled());
connect(_ui->enableMouseWheelZoomButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::toggleMouseWheelZoom);
}
void EditProfileDialog::showAllFontsButtonWarning(bool enable)
{
if (enable) {
KMessageBox::information(this,
"By its very nature, a terminal program requires font characters that are equal width (monospace). Any non monospaced font may cause display issues. This should not be necessary except in rare cases.",
"Warning");
}
}
void EditProfileDialog::setAntialiasText(bool enable)
{
QFont profileFont = _ui->fontPreviewLabel->font();
......@@ -1200,11 +1214,17 @@ void EditProfileDialog::fontSelected(const QFont& aFont)
void EditProfileDialog::showFontDialog()
{
QFont currentFont = _ui->fontPreviewLabel->font();
bool showAllFonts = _ui->showAllFontsButton->isChecked();
bool result;
currentFont = QFontDialog::getFont(&result, currentFont, this,
if (showAllFonts) {
currentFont = QFontDialog::getFont(&result, currentFont, this,
i18n("Select All Font"));
} else {
currentFont = QFontDialog::getFont(&result, currentFont, this,
i18n("Select Fixed Width Font"),
QFontDialog::MonospacedFonts);
}
if (!result) return;
fontSelected(currentFont);
......
......@@ -123,6 +123,7 @@ private slots:
// appearance page
void setFontSize(double pointSize);
void setFontInputValue(const QFont&);
void showAllFontsButtonWarning(bool enable);
void setAntialiasText(bool enable);
void setBoldIntense(bool enable);
void showFontDialog();
......
......@@ -574,6 +574,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showAllFontsButton">
<property name="toolTip">
<string>Show all fonts instead of the monospaced fonts</string>
</property>
<property name="text">
<string>Show All Fonts</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
......
......@@ -232,9 +232,9 @@ void TerminalDisplay::setVTFont(const QFont& f)
QFontInfo fontInfo(newFont);
if (!fontInfo.fixedPitch()) {
qWarning() << "Using a variable-width font - this might cause display problems";
}
// if (!fontInfo.fixedPitch()) {
// qWarning() << "Using a variable-width font - this might cause display problems";
// }
// QFontInfo::fixedPitch() appears to not match QFont::fixedPitch()
// related? https://bugreports.qt.io/browse/QTBUG-34082
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment