27QGnomeThemePrivate::QGnomeThemePrivate()
30 QObject::connect(&m_gnomePortal, &QGnomePortalInterface::themeNameChanged, &m_gnomePortal,
31 [
this](
const QString &themeName) { m_themeName = themeName; });
43void QGnomeThemePrivate::configureFonts(
const QString >kFontName)
const
45 Q_ASSERT(!systemFont);
46 const int split = gtkFontName.lastIndexOf(QChar::Space);
47 float size = QStringView{gtkFontName}.mid(split + 1).toFloat();
48 QString fontName = gtkFontName.left(split);
50 systemFont =
new QFont(fontName, size);
51 fixedFont =
new QFont(QLatin1StringView(QGenericUnixTheme::defaultFixedFontNameC), systemFont->pointSize());
52 fixedFont->setStyleHint(QFont::TypeWriter);
53 qCDebug(lcQpaFonts) <<
"default fonts: system" << systemFont <<
"fixed" << fixedFont;
56Qt::ColorScheme QGnomeThemePrivate::colorScheme()
const
58 if (hasRequestedColorScheme())
59 return m_requestedColorScheme;
62 if (Qt::ColorScheme colorScheme = m_gnomePortal.colorScheme();
63 colorScheme != Qt::ColorScheme::Unknown)
70 if (m_themeName.contains(QLatin1StringView(
"light"), Qt::CaseInsensitive))
71 return Qt::ColorScheme::Light;
72 else if (m_themeName.contains(QLatin1StringView(
"dark"), Qt::CaseInsensitive))
73 return Qt::ColorScheme::Dark;
77 return Qt::ColorScheme::Unknown;
85QGnomeTheme::QGnomeTheme()
86 : QGenericUnixTheme(
new QGnomeThemePrivate())
91 QGnomePortalInterface *portal = &d->m_gnomePortal;
93 QObject::connect(portal, &QGnomePortalInterface::colorSchemeChanged, portal,
94 [
this](Qt::ColorScheme colorScheme) { updateColorScheme(colorScheme); });
96 QObject::connect(portal, &QGnomePortalInterface::contrastChanged, portal,
97 [
this](Qt::ContrastPreference contrast) { updateHighContrast(contrast); });
98 QObject::connect(portal, &QGnomePortalInterface::motionChanged, portal,
99 [
this](Qt::MotionPreference motion){ updateReducedMotion(motion); });
103QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint)
const
106 case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
107 return QVariant(
true);
108 case QPlatformTheme::DialogButtonBoxLayout:
109 return QVariant(QPlatformDialogHelper::GnomeLayout);
110 case QPlatformTheme::SystemIconThemeName:
111 return QVariant(QStringLiteral(
"Adwaita"));
112 case QPlatformTheme::SystemIconFallbackThemeName:
113 return QVariant(QStringLiteral(
"gnome"));
114 case QPlatformTheme::IconThemeSearchPaths:
115 return QVariant(xdgIconThemePaths());
116 case QPlatformTheme::IconPixmapSizes:
117 return QVariant::fromValue(availableXdgFileIconSizes());
118 case QPlatformTheme::StyleNames: {
119 QStringList styleNames;
120 styleNames << QStringLiteral(
"Fusion") << QStringLiteral(
"windows");
121 return QVariant(styleNames);
123 case QPlatformTheme::KeyboardScheme:
124 return QVariant(
int(GnomeKeyboardScheme));
125 case QPlatformTheme::PasswordMaskCharacter:
126 return QVariant(QChar(0x2022));
127 case QPlatformTheme::UiEffects:
128 return QVariant(
int(HoverEffect));
129 case QPlatformTheme::ButtonPressKeys:
130 return QVariant::fromValue(
131 QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
132 case QPlatformTheme::PreselectFirstFileInDirectory:
134 case QPlatformTheme::MouseCursorTheme:
135 return QVariant(mouseCursorTheme());
136 case QPlatformTheme::MouseCursorSize:
137 return QVariant(mouseCursorSize());
138 case QPlatformTheme::PreferFileIconFromTheme:
143 return QPlatformTheme::themeHint(hint);
177void QGnomeTheme::requestColorScheme(Qt::ColorScheme scheme)
180 if (d->m_requestedColorScheme == scheme)
182 QPlatformTheme::requestColorScheme(scheme);
183 d->m_requestedColorScheme = scheme;
184 QWindowSystemInterface::handleThemeChange();
244QString QGnomeTheme::standardButtonText(
int button)
const
247 case QPlatformDialogHelper::Ok:
248 return QCoreApplication::translate(
"QGnomeTheme",
"&OK");
249 case QPlatformDialogHelper::Save:
250 return QCoreApplication::translate(
"QGnomeTheme",
"&Save");
251 case QPlatformDialogHelper::Cancel:
252 return QCoreApplication::translate(
"QGnomeTheme",
"&Cancel");
253 case QPlatformDialogHelper::Close:
254 return QCoreApplication::translate(
"QGnomeTheme",
"&Close");
255 case QPlatformDialogHelper::Discard:
256 return QCoreApplication::translate(
"QGnomeTheme",
"Close without Saving");
260 return QPlatformTheme::standardButtonText(button);