summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2014-07-31 18:10:33 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2022-10-18 20:22:32 +0200
commitbb1f616ff19586225cd712195ca78bfc64944103 (patch)
tree86d8ef46cca86151e9c4cd3d3b928bb62030ea84 /src/gui/kernel
parent942abaae595ea620bdeacba0f4a18b759785d61b (diff)
Add flicking behavior hints to platform integration and theme
These will be used in QtQuick Flickable. Flickable.flickDeceleration is a sort of friction, the rate at which a flick will decelerate when the user is flicking on a touchscreen or rolling a clicky mouse wheel, and then flicking stops. So far, the default has always been 1500 (defined in qtdeclarative), which (everyone seems to agree) prevents Flickable from slowing down reasonably fast when scrolling stops. So let's try 5000 logical pixels / secĀ² as a default, and each platform will be able to customize it. The docs already say "The default value is platform dependent"; now it can come from StyleHint::FlickDeceleration. FlickMaximumVelocity: the units are in logical pixels / sec. The default has always been 2500 in qtdeclarative, but there were some early complaints that Flickable was too slow on Android, for example (which were somewhat mitigated by DPI conversions). So now that also becomes adjustable on each platform (although really, it should be mainly the DPI that matters, because the user's perception is in actual distance moved per second). FlickStartDistance is how many logical pixels the Flickable must be dragged by a finger before it begins the animation to keep moving when the finger is lifted. (Analogous to StartDragDistance for mouse-drags) [ChangeLog][QPA] Added platform FlickStartDistance, FlickMaximumVelocity and FlickDeceleration hints for the benefit of QtQuick Flickable Task-number: QTBUG-35608 Task-number: QTBUG-35609 Task-number: QTBUG-52643 Task-number: QTBUG-97055 Change-Id: If50c1de895c127f4b0ab0634c865f469a38e08ba Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qplatformintegration.cpp6
-rw-r--r--src/gui/kernel/qplatformintegration.h5
-rw-r--r--src/gui/kernel/qplatformtheme.cpp12
-rw-r--r--src/gui/kernel/qplatformtheme.h5
4 files changed, 26 insertions, 2 deletions
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 29dfba8155..aa4fe078a1 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -410,6 +410,12 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseQuickSelectionThreshold);
case MouseDoubleClickDistance:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseDoubleClickDistance);
+ case FlickStartDistance:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickStartDistance);
+ case FlickMaximumVelocity:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickMaximumVelocity);
+ case FlickDeceleration:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickDeceleration);
}
return 0;
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index cc617faca9..f718e1e45b 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -161,7 +161,10 @@ public:
WheelScrollLines,
ShowShortcutsInContextMenus,
MouseQuickSelectionThreshold,
- MouseDoubleClickDistance
+ MouseDoubleClickDistance,
+ FlickStartDistance,
+ FlickMaximumVelocity,
+ FlickDeceleration
};
virtual QVariant styleHint(StyleHint hint) const;
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 83022fbb69..fb1c27a15a 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -513,6 +513,12 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus);
case QPlatformTheme::SetFocusOnTouchRelease:
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SetFocusOnTouchRelease);
+ case QPlatformTheme::FlickStartDistance:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickStartDistance);
+ case QPlatformTheme::FlickMaximumVelocity:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity);
+ case QPlatformTheme::FlickDeceleration:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration);
default:
return QPlatformTheme::defaultThemeHint(hint);
}
@@ -613,6 +619,12 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
case SetFocusOnTouchRelease:
return false;
+ case FlickStartDistance:
+ return QVariant(15);
+ case FlickMaximumVelocity:
+ return QVariant(2500);
+ case FlickDeceleration:
+ return QVariant(5000);
}
return QVariant();
}
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 7462daa2a4..1fa8c12b48 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -88,7 +88,10 @@ public:
ShowDirectoriesFirst,
PreselectFirstFileInDirectory,
ButtonPressKeys,
- SetFocusOnTouchRelease
+ SetFocusOnTouchRelease,
+ FlickStartDistance,
+ FlickMaximumVelocity,
+ FlickDeceleration
};
Q_ENUM(ThemeHint)