Add QPlatformTheme::MouseCursorTheme and MouseCursorSize
Also implement in QGenericUnixTheme/QKdeTheme/QGnomeTheme/QGtk3Theme. On Wayland, there is wl_cursor_theme_load() and etc in wayland-cursor.h. On X11/xcb, cursor theme and size are common, either in XCURSOR_THEME and XCURSOR_SIZE envs, or in gsettings for gtk/gnome world. On Windows, cursor theme is part of theme file, see SetWindowTheme in https://learn.microsoft.com/en-gb/windows/win32/api/uxtheme/nf-uxtheme-setwindowtheme . For system settings, for example on Windows 10, Mouse Settings, Additional mouse options, Pointers Tab, Scheme. On macOS, it looks like cursor theme is deprecated. Change-Id: I5821377d966c281fb8330da1f5baa7f0ddf86a9f Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
f678893f8a
commit
a823366f77
@ -147,6 +147,12 @@ QT_BEGIN_NAMESPACE
|
|||||||
input focus after a touch/mouse release.
|
input focus after a touch/mouse release.
|
||||||
This enum value has been added in Qt 6.5.
|
This enum value has been added in Qt 6.5.
|
||||||
|
|
||||||
|
\value MouseCursorTheme (QString) Name of the mouse cursor theme.
|
||||||
|
This enum value has been added in Qt 6.5.
|
||||||
|
|
||||||
|
\value MouseCursorSize (QSize) Size of the mouse cursor.
|
||||||
|
This enum value has been added in Qt 6.5.
|
||||||
|
|
||||||
\sa themeHint(), QStyle::pixelMetric()
|
\sa themeHint(), QStyle::pixelMetric()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -627,6 +633,10 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
|||||||
return QVariant(5000);
|
return QVariant(5000);
|
||||||
case MenuBarFocusOnAltPressRelease:
|
case MenuBarFocusOnAltPressRelease:
|
||||||
return false;
|
return false;
|
||||||
|
case MouseCursorTheme:
|
||||||
|
return QVariant(QString());
|
||||||
|
case MouseCursorSize:
|
||||||
|
return QVariant(QSize(16, 16));
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,9 @@ public:
|
|||||||
FlickStartDistance,
|
FlickStartDistance,
|
||||||
FlickMaximumVelocity,
|
FlickMaximumVelocity,
|
||||||
FlickDeceleration,
|
FlickDeceleration,
|
||||||
MenuBarFocusOnAltPressRelease
|
MenuBarFocusOnAltPressRelease,
|
||||||
|
MouseCursorTheme,
|
||||||
|
MouseCursorSize
|
||||||
};
|
};
|
||||||
Q_ENUM(ThemeHint)
|
Q_ENUM(ThemeHint)
|
||||||
|
|
||||||
|
@ -86,6 +86,20 @@ static bool isDBusTrayAvailable() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static QString mouseCursorTheme()
|
||||||
|
{
|
||||||
|
static QString themeName = qEnvironmentVariable("XCURSOR_THEME");
|
||||||
|
return themeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QSize mouseCursorSize()
|
||||||
|
{
|
||||||
|
constexpr int defaultCursorSize = 24;
|
||||||
|
static const int xCursorSize = qEnvironmentVariableIntValue("XCURSOR_SIZE");
|
||||||
|
static const int s = xCursorSize > 0 ? xCursorSize : defaultCursorSize;
|
||||||
|
return QSize(s, s);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DBUS
|
#ifndef QT_NO_DBUS
|
||||||
static bool checkDBusGlobalMenuAvailable()
|
static bool checkDBusGlobalMenuAvailable()
|
||||||
{
|
{
|
||||||
@ -290,6 +304,10 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
|
|||||||
return QVariant(int(X11KeyboardScheme));
|
return QVariant(int(X11KeyboardScheme));
|
||||||
case QPlatformTheme::UiEffects:
|
case QPlatformTheme::UiEffects:
|
||||||
return QVariant(int(HoverEffect));
|
return QVariant(int(HoverEffect));
|
||||||
|
case QPlatformTheme::MouseCursorTheme:
|
||||||
|
return QVariant(mouseCursorTheme());
|
||||||
|
case QPlatformTheme::MouseCursorSize:
|
||||||
|
return QVariant(mouseCursorSize());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -711,6 +729,10 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
|||||||
return QVariant(d->cursorBlinkRate);
|
return QVariant(d->cursorBlinkRate);
|
||||||
case QPlatformTheme::UiEffects:
|
case QPlatformTheme::UiEffects:
|
||||||
return QVariant(int(HoverEffect));
|
return QVariant(int(HoverEffect));
|
||||||
|
case QPlatformTheme::MouseCursorTheme:
|
||||||
|
return QVariant(mouseCursorTheme());
|
||||||
|
case QPlatformTheme::MouseCursorSize:
|
||||||
|
return QVariant(mouseCursorSize());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -983,6 +1005,10 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
|
|||||||
QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
|
QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Return, Qt::Key_Enter, Qt::Key_Select }));
|
||||||
case QPlatformTheme::PreselectFirstFileInDirectory:
|
case QPlatformTheme::PreselectFirstFileInDirectory:
|
||||||
return true;
|
return true;
|
||||||
|
case QPlatformTheme::MouseCursorTheme:
|
||||||
|
return QVariant(mouseCursorTheme());
|
||||||
|
case QPlatformTheme::MouseCursorSize:
|
||||||
|
return QVariant(mouseCursorSize());
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -101,6 +101,8 @@ QGtk3Theme::QGtk3Theme()
|
|||||||
SETTING_CONNECT("gtk-font-name");
|
SETTING_CONNECT("gtk-font-name");
|
||||||
SETTING_CONNECT("gtk-application-prefer-dark-theme");
|
SETTING_CONNECT("gtk-application-prefer-dark-theme");
|
||||||
SETTING_CONNECT("gtk-theme-name");
|
SETTING_CONNECT("gtk-theme-name");
|
||||||
|
SETTING_CONNECT("gtk-cursor-theme-name");
|
||||||
|
SETTING_CONNECT("gtk-cursor-theme-size");
|
||||||
#undef SETTING_CONNECT
|
#undef SETTING_CONNECT
|
||||||
|
|
||||||
/* Set XCURSOR_SIZE and XCURSOR_THEME for Wayland sessions */
|
/* Set XCURSOR_SIZE and XCURSOR_THEME for Wayland sessions */
|
||||||
@ -150,6 +152,14 @@ QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const
|
|||||||
return QVariant(gtkSetting("gtk-icon-theme-name"));
|
return QVariant(gtkSetting("gtk-icon-theme-name"));
|
||||||
case QPlatformTheme::SystemIconFallbackThemeName:
|
case QPlatformTheme::SystemIconFallbackThemeName:
|
||||||
return QVariant(gtkSetting("gtk-fallback-icon-theme"));
|
return QVariant(gtkSetting("gtk-fallback-icon-theme"));
|
||||||
|
case QPlatformTheme::MouseCursorTheme:
|
||||||
|
return QVariant(gtkSetting("gtk-cursor-theme-name"));
|
||||||
|
case QPlatformTheme::MouseCursorSize: {
|
||||||
|
int s = gtkSetting<gint>("gtk-cursor-theme-size");
|
||||||
|
if (s > 0)
|
||||||
|
return QVariant(QSize(s, s));
|
||||||
|
return QGnomeTheme::themeHint(hint);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return QGnomeTheme::themeHint(hint);
|
return QGnomeTheme::themeHint(hint);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user