[vlc-commits] qml: allow flickering in local menu group when enough space is not available
Prince Gupta
git at videolan.org
Fri Nov 27 14:52:26 CET 2020
vlc | branch: master | Prince Gupta <guptaprince8832 at gmail.com> | Fri Nov 20 23:17:40 2020 +0530| [30cc7461dddb5200c2669d9eac8d60114d6ec174] | committer: Pierre Lamot
qml: allow flickering in local menu group when enough space is not available
Signed-off-by: Pierre Lamot <pierre at videolabs.io>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=30cc7461dddb5200c2669d9eac8d60114d6ec174
---
modules/gui/qt/maininterface/qml/BannerSources.qml | 104 ++++++++++++++-------
modules/gui/qt/network/qml/NetworkAddressbar.qml | 7 +-
2 files changed, 75 insertions(+), 36 deletions(-)
diff --git a/modules/gui/qt/maininterface/qml/BannerSources.qml b/modules/gui/qt/maininterface/qml/BannerSources.qml
index 50572ec303..eaa6db3ee1 100644
--- a/modules/gui/qt/maininterface/qml/BannerSources.qml
+++ b/modules/gui/qt/maininterface/qml/BannerSources.qml
@@ -283,45 +283,81 @@ Widgets.NavigableFocusScope {
navigationUpItem: globalMenuGroup
}
- Loader {
- id: localMenuGroup
-
- anchors.centerIn: parent
- focus: !!item && item.focus && item.visible
- visible: !!item
-
- onVisibleChanged: {
- //reset the focus on the global group when the local group is hidden,
- //this avoids losing the focus if the subview changes
- if (!visible && localMenuGroup.focus) {
- localMenuGroup.focus = false
- globalMenuGroup.focus = true
+ Flickable {
+ id: localMenuView
+
+ readonly property int availableWidth: parent.width
+ - (localContextGroup.width + playlistGroup.width)
+ - (VLCStyle.applicationHorizontalMargin * 2)
+ - (VLCStyle.margin_xxsmall * 2)
+ readonly property bool _alignHCenter: ((localToolbar.width - width) / 2) + width < playlistGroup.x
+
+ width: Math.min(contentWidth, availableWidth)
+ height: VLCStyle.localToolbar_height
+ clip: true
+ contentWidth: localMenuGroup.width
+ contentHeight: VLCStyle.localToolbar_height // don't allow vertical flickering
+ anchors.rightMargin: VLCStyle.margin_xxsmall // only applied when right aligned
+
+ on_AlignHCenterChanged: {
+ if (_alignHCenter) {
+ anchors.horizontalCenter = localToolbar.horizontalCenter
+ anchors.right = undefined
+ } else {
+ anchors.horizontalCenter = undefined
+ anchors.right = playlistGroup.left
}
}
- onItemChanged: {
- if (!item)
- return
- if (item.hasOwnProperty("navigationParent")) {
- item.navigationParent = root
- item.navigationLeftItem = localContextGroup.enabled ? localContextGroup : undefined
- item.navigationRightItem = playlistGroup.enabled ? playlistGroup : undefined
- item.navigationUpItem = globalMenuGroup
- } else {
- item.KeyNavigation.left = localContextGroup.enabled ? localContextGroup : undefined
- item.KeyNavigation.right = playlistGroup.enabled ? playlistGroup : undefined
- item.KeyNavigation.up = globalMenuGroup
- item.Keys.pressed.connect(function (event) {
- if (event.accepted)
- return
- if (KeyHelper.matchDown(event)) {
- root.navigationDown()
- event.accepted = true
- }
- })
+ Loader {
+ id: localMenuGroup
+
+ focus: !!item && item.focus && item.visible
+ visible: !!item
+ y: (VLCStyle.localToolbar_height - item.height) / 2
+ width: !!item
+ ? clamp(localMenuView.availableWidth
+ , localMenuGroup.item.minimumWidth || localMenuGroup.item.implicitWidth
+ , localMenuGroup.item.maximumWidth || localMenuGroup.item.implicitWidth)
+ : 0
+
+ function clamp(num, min, max) {
+ return num <= min ? min : num >= max ? max : num;
}
- }
+ onVisibleChanged: {
+ //reset the focus on the global group when the local group is hidden,
+ //this avoids losing the focus if the subview changes
+ if (!visible && localMenuGroup.focus) {
+ localMenuGroup.focus = false
+ globalMenuGroup.focus = true
+ }
+ }
+
+ onItemChanged: {
+ if (!item)
+ return
+ if (item.hasOwnProperty("navigationParent")) {
+ item.navigationParent = root
+ item.navigationLeftItem = localContextGroup.enabled ? localContextGroup : undefined
+ item.navigationRightItem = playlistGroup.enabled ? playlistGroup : undefined
+ item.navigationUpItem = globalMenuGroup
+ } else {
+ item.KeyNavigation.left = localContextGroup.enabled ? localContextGroup : undefined
+ item.KeyNavigation.right = playlistGroup.enabled ? playlistGroup : undefined
+ item.KeyNavigation.up = globalMenuGroup
+ item.Keys.pressed.connect(function (event) {
+ if (event.accepted)
+ return
+ if (KeyHelper.matchDown(event)) {
+ root.navigationDown()
+ event.accepted = true
+ }
+ })
+ }
+ }
+
+ }
}
Widgets.NavigableRow {
diff --git a/modules/gui/qt/network/qml/NetworkAddressbar.qml b/modules/gui/qt/network/qml/NetworkAddressbar.qml
index 59d4da14e4..33de4e8f17 100644
--- a/modules/gui/qt/network/qml/NetworkAddressbar.qml
+++ b/modules/gui/qt/network/qml/NetworkAddressbar.qml
@@ -33,10 +33,13 @@ Control {
property var _contentModel
property var _menuModel
+ readonly property int maximumWidth: VLCStyle.bannerTabButton_width_large * 4
+ readonly property int minimumWidth: VLCStyle.bannerTabButton_width_large
+
onPathChanged: createContentModel()
onAvailableWidthChanged: createContentModel()
- width: VLCStyle.bannerTabButton_width_large * 4
- height: VLCStyle.dp(24, VLCStyle.scale)
+ implicitWidth: VLCStyle.bannerTabButton_width_large * 4
+ implicitHeight: VLCStyle.dp(24, VLCStyle.scale)
focus: true
onActiveFocusChanged: if (activeFocus)
contentItem.forceActiveFocus()
More information about the vlc-commits
mailing list