qt6ct
qt6ct copied to clipboard
Option to disable font settings
I have an issue using qt6ct
with qt creator. It correctly set's icon theme and color theme to make creator operate effectively on GNOME, including allowing me to style the designer UI in dark mode. But, it messes with the font within the editor.
Because the font setting is very one-size-fits all, it makes the normally bold elements within the editor go away so all text is "Regular" while the default behavior in Qt Creator is to make certain code elements bold.
If there was a checkbox to not write any font setting to the config nor have any default font setting injected into the Qt app, this problem would be solved, then I could still use the icon and color scheme settings alone but let Creator control fonts completely.
Desired font style with some bold elements:
qt6ct theme applied, all text "Regular":
qt6ct likely needs this: https://invent.kde.org/frameworks/kconfig/-/blob/master/src/gui/kconfiggroupgui.cpp#L153-170
I can confirm that I have had similar issues with QtCreator, and sometimes unexpected crashes with qt5/6ct. In the case of QtCreator specifically I ended up disabling theming for it through qt6ct settings.
Perhaps this (mirroring the KDE code) would fix both problems and get rid of the need to disable font settings:
diff --git a/src/qt6ct/fontspage.cpp b/src/qt6ct/fontspage.cpp
index 5113edd..f0b95d5 100644
--- a/src/qt6ct/fontspage.cpp
+++ b/src/qt6ct/fontspage.cpp
@@ -70,11 +70,20 @@ void FontsPage::onFontChangeRequested(QWidget *widget)
{
bool ok = false;
QFont font = QFontDialog::getFont (&ok, widget->font(), this);
- if(ok)
+ if(!ok)
{
- widget->setFont(font);
- qobject_cast<QLabel*>(widget)->setText(font.family () + " " + QString::number(font.pointSize ()));
+ return;
}
+ if(font.weight() == QFont::Normal
+ && (font.styleName() == QLatin1String("Regular")
+ || font.styleName() == QLatin1String("Normal")
+ || font.styleName() == QLatin1String("Book")
+ || font.styleName() == QLatin1String("Roman")))
+ {
+ font.setStyleName(QString());
+ }
+ widget->setFont(font);
+ qobject_cast<QLabel*>(widget)->setText(font.family () + " " + QString::number(font.pointSize ()));
}
void FontsPage::readSettings()
Apply the patch, re-set the font settings and fonts should have the proper bold-ness.