From 37f3ed96eb6f41d2b9fc34f64725dd754bb627a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 3 Aug 2017 11:42:27 +0200 Subject: Fallback to QGnomeTheme if Gtk3 does not support long-press-time "gtk-long-press-time" was introduced in 3.14. Therefore, if the property does not exist, we should fallback to QGnomeTheme::themeHint(). Task-number: QTBUG-61393 Change-Id: I898c0ddebdbabb300d7ad9dd275d51836ad9cf8c Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/plugins/platformthemes/gtk3') diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp index 7e64906476..6447776f25 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp +++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp @@ -102,6 +102,15 @@ QGtk3Theme::QGtk3Theme() g_log_set_handler("Gtk", G_LOG_LEVEL_MESSAGE, gtkMessageHandler, NULL); } +static inline QVariant gtkGetLongPressTime() +{ + const char *gtk_long_press_time = "gtk-long-press-time"; + static bool found = g_object_class_find_property(G_OBJECT_GET_CLASS(gtk_settings_get_default()), gtk_long_press_time); + if (!found) + return QVariant(); + return QVariant(gtkSetting(gtk_long_press_time)); // Since 3.14, apparently we support >= 3.6 +} + QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const { switch (hint) { @@ -111,8 +120,12 @@ QVariant QGtk3Theme::themeHint(QPlatformTheme::ThemeHint hint) const return QVariant(gtkSetting("gtk-double-click-distance")); case QPlatformTheme::MouseDoubleClickInterval: return QVariant(gtkSetting("gtk-double-click-time")); - case QPlatformTheme::MousePressAndHoldInterval: - return QVariant(gtkSetting("gtk-long-press-time")); + case QPlatformTheme::MousePressAndHoldInterval: { + QVariant v = gtkGetLongPressTime(); + if (!v.isValid()) + v = QGnomeTheme::themeHint(hint); + return v; + } case QPlatformTheme::PasswordMaskDelay: return QVariant(gtkSetting("gtk-entry-password-hint-timeout")); case QPlatformTheme::StartDragDistance: -- cgit v1.2.3