Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable font settings #46

Open
cdock1029 opened this issue Apr 28, 2024 · 3 comments · May be fixed by #54
Open

Option to disable font settings #46

cdock1029 opened this issue Apr 28, 2024 · 3 comments · May be fixed by #54

Comments

@cdock1029
Copy link

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:

Screenshot from 2024-04-27 21-42-24

Screenshot from 2024-04-27 21-42-33

qt6ct theme applied, all text "Regular":

Screenshot from 2024-04-27 21-39-52

Screenshot from 2024-04-27 21-43-50

@ilya-fedin
Copy link

qt6ct likely needs this: https://invent.kde.org/frameworks/kconfig/-/blob/master/src/gui/kconfiggroupgui.cpp#L153-170

@loathingKernel
Copy link

loathingKernel commented May 15, 2024

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.

@ilya-fedin
Copy link

ilya-fedin commented May 15, 2024

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.

ilya-fedin added a commit to ilya-fedin/qt6ct that referenced this issue Oct 2, 2024
@ilya-fedin ilya-fedin linked a pull request Oct 2, 2024 that will close this issue
detiam pushed a commit to detiam/qt6ct that referenced this issue Oct 17, 2024
ilya-fedin added a commit to ilya-fedin/qt6ct that referenced this issue Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants