Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions src/preferences/dialog/dlgpreflibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,39 @@ void DlgPrefLibrary::slotRowHeightValueChanged(int height) {
}

void DlgPrefLibrary::setLibraryFont(const QFont& font) {
lineEdit_library_font->setText(
QString("%1 %2 %3pt")
.arg(font.family(),
font.styleName(),
QString::number(font.pointSizeF())));
// Update the font name/style/size display
QString fontDescription = font.family();
const QString style = font.styleName();
if (!style.isEmpty()) {
// Use the style name if available, likely it's translated
fontDescription += ' ' + style;
} else {
// Else we compose the "style" string from weight and italic.
// It's not possible to access the translations used in QFontDialog,
// but let's can add them to the user translations
const auto weight = font.weight();
if (weight >= QFont::Bold) {
if (weight >= QFont::Black) {
fontDescription += ' ' + tr("Black");
} else if (weight >= QFont::ExtraBold) {
fontDescription += ' ' + tr("ExtraBold");
} else if (weight >= QFont::Bold) {
fontDescription += ' ' + tr("Bold");
}
} else if (weight >= QFont::DemiBold) {
fontDescription += ' ' + tr("SemiBold");
} else if (weight >= QFont::Medium) {
fontDescription += ' ' + tr("Medium");
} else if (weight >= QFont::Normal) {
// Skip "Normal" as it's implied
} else {
fontDescription += ' ' + tr("Light");
}
}
fontDescription += ' ' + QString::number(font.pointSizeF()) + QStringLiteral("pt");
lineEdit_library_font->setText(fontDescription);

// Apply the font
m_pLibrary->setFont(font);

// Don't let the font height exceed the row height.
Expand Down