diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-08-03 11:42:27 +0200 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2017-08-09 09:06:47 +0000 |
commit | 37f3ed96eb6f41d2b9fc34f64725dd754bb627a8 (patch) | |
tree | 2bf0c335194cf6e8175078cbcec7b34b1610c1f5 | |
parent | e029923c6041bd0ed5565a16c03382b065d22e83 (diff) |
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 <mitya57@gmail.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-rw-r--r-- | src/plugins/platformthemes/gtk3/qgtk3theme.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
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<guint>(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<gint>("gtk-double-click-distance")); case QPlatformTheme::MouseDoubleClickInterval: return QVariant(gtkSetting<gint>("gtk-double-click-time")); - case QPlatformTheme::MousePressAndHoldInterval: - return QVariant(gtkSetting<guint>("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<guint>("gtk-entry-password-hint-timeout")); case QPlatformTheme::StartDragDistance: |