Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
42cefbca by Benjamin Arnaud at 2022-09-09T11:26:42+00:00
qml/Player: Add the 'applyMenu' function
- - - - -
7247f1ae by Benjamin Arnaud at 2022-09-09T11:26:42+00:00
qml/LangButton: Update to 'Player.applyMenu'
- - - - -
9f1abc57 by Benjamin Arnaud at 2022-09-09T11:26:42+00:00
qml: Create ControlButtonPopup
- - - - -
94d5ad6e by Benjamin Arnaud at 2022-09-09T11:26:42+00:00
qml/PlaybackSpeedButton: Update to ControlButtonPopup
- - - - -
3de5b7f1 by Benjamin Arnaud at 2022-09-09T11:26:42+00:00
qml/TeletextButton: Update to ControlButtonPopup
- - - - -
7 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/player/qml/Player.qml
- + modules/gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml
- modules/gui/qt/player/qml/controlbarcontrols/LangButton.qml
- modules/gui/qt/player/qml/controlbarcontrols/PlaybackSpeedButton.qml
- modules/gui/qt/player/qml/controlbarcontrols/TeletextButton.qml
- modules/gui/qt/vlc.qrc
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -883,6 +883,7 @@ libqt_plugin_la_QML = \
gui/qt/player/qml/controlbarcontrols/BookmarkButton.qml \
gui/qt/player/qml/controlbarcontrols/ChapterNextButton.qml \
gui/qt/player/qml/controlbarcontrols/ChapterPreviousButton.qml \
+ gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml \
gui/qt/player/qml/controlbarcontrols/DvdMenuButton.qml \
gui/qt/player/qml/controlbarcontrols/ExpandingSpacerWidget.qml \
gui/qt/player/qml/controlbarcontrols/ExtendedSettingsButton.qml \
=====================================
modules/gui/qt/player/qml/Player.qml
=====================================
@@ -103,6 +103,19 @@ FocusScope {
toolbarAutoHide.setVisibleControlBar(true)
}
+ // Functions
+
+ function applyMenu(menu) {
+ if (rootPlayer.menu === menu)
+ return
+
+ // NOTE: When applying a new menu we hide the previous one.
+ if (menu)
+ dismiss()
+
+ rootPlayer.menu = menu
+ }
+
function dismiss() {
if ((typeof menu === undefined) || !menu)
return
@@ -117,6 +130,8 @@ FocusScope {
console.assert(_lockAutoHide >= 0)
}
+ // Private
+
function _onNavigationCancel() {
if (rootPlayer.hasEmbededVideo && controlBarView.state === "visible") {
toolbarAutoHide.setVisibleControlBar(false)
=====================================
modules/gui/qt/player/qml/controlbarcontrols/ControlButtonPopup.qml
=====================================
@@ -0,0 +1,150 @@
+/*****************************************************************************
+ * Copyright (C) 2019 VLC authors and VideoLAN
+ *
+ * Authors: Benjamin Arnaud <bun...@omega.gg>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301,
USA.
+ *****************************************************************************/
+
+import QtQuick 2.11
+import QtQuick.Controls 2.4
+
+import org.videolan.vlc 0.1
+
+import "qrc:///style/"
+import "qrc:///widgets/" as Widgets
+import "qrc:///util/Helpers.js" as Helpers
+
+Widgets.IconControlButton {
+ // Properties
+
+ // Private
+
+ readonly property bool _isCurrentViewPlayer: (History.current.name ===
"player")
+
+ // Aliases
+
+ property alias popupContent: popup.contentItem
+
+ property alias popup: popup
+
+ // Signals
+
+ signal requestLockUnlockAutoHide(bool lock)
+
+ // Settings
+
+ color: (popup.visible) ? colors.accent : colors.playerControlBarFg
+
+ // FIXME: We can't use upItem because a Popup is not an Item.
+ Navigation.upAction: function() {
+ if (popup.visible) {
+ popup.forceActiveFocus(Qt.TabFocusReason)
+
+ return
+ }
+
+ var parent = Navigation.parentItem;
+
+ if (parent)
+ parent.Navigation.defaultNavigationUp()
+ }
+
+ // Events
+
+ onClicked: popup.open()
+
+ // Connections
+
+ Connections {
+ target: (popup.visible) ? popup.parent : null
+
+ onWidthChanged: _updatePosition()
+ onHeightChanged: _updatePosition()
+ }
+
+ // Functions
+
+ // Private
+
+ // NOTE: coordinates are based on the popup parent view.
+ function _updatePosition() {
+ var parent = popup.parent
+
+ var position = parent.mapFromItem(root, x, y)
+
+ var popupX = Math.round(position.x - ((popup.width - width) / 2))
+
+ var minimum = VLCStyle.applicationHorizontalMargin +
VLCStyle.margin_xxsmall
+
+ var maximum = parent.width - popup.width - minimum
+
+ popup.x = Helpers.clamp(popupX, minimum, maximum)
+
+ popup.y = position.y - popup.height - VLCStyle.margin_xxsmall
+ }
+
+ // Children
+
+ Popup {
+ id: popup
+
+ parent: (root._isCurrentViewPlayer) ? rootPlayer : g_root
+
+ padding: VLCStyle.margin_small
+
+ z: 1
+
+ focus: true
+
+ modal: true
+
+ // NOTE: Popup.CloseOnPressOutside doesn't work with non-model Popup
on Qt < 5.15.
+ closePolicy: (Popup.CloseOnPressOutside | Popup.CloseOnEscape)
+
+ Overlay.modal: null
+
+ // Events
+
+ onOpened: {
+ root._updatePosition()
+
+ root.requestLockUnlockAutoHide(true)
+
+ if (root._isCurrentViewPlayer)
+ rootPlayer.applyMenu(popup)
+ }
+
+ onClosed: {
+ root.requestLockUnlockAutoHide(false)
+
+ root.forceActiveFocus()
+
+ if (root._isCurrentViewPlayer)
+ rootPlayer.applyMenu(null)
+ }
+
+ onWidthChanged: if (visible) root._updatePosition()
+ onHeightChanged: if (visible) root._updatePosition()
+
+ background: Rectangle {
+ radius: VLCStyle.dp(8, VLCStyle.scale)
+
+ opacity: 0.85
+
+ color: colors.bg
+ }
+ }
+}
=====================================
modules/gui/qt/player/qml/controlbarcontrols/LangButton.qml
=====================================
@@ -52,14 +52,14 @@ Widgets.IconControlButton {
onOpened: {
langBtn.requestLockUnlockAutoHide(true)
if (!!rootPlayer)
- rootPlayer.menu = menu
+ rootPlayer.applyMenu(menu)
}
onClosed: {
langBtn.requestLockUnlockAutoHide(false)
langBtn.forceActiveFocus()
if (!!rootPlayer)
- rootPlayer.menu = undefined
+ rootPlayer.applyMenu(null)
}
}
}
=====================================
modules/gui/qt/player/qml/controlbarcontrols/PlaybackSpeedButton.qml
=====================================
@@ -17,126 +17,34 @@
*****************************************************************************/
import QtQuick 2.11
-import QtQuick.Controls 2.4
import QtQuick.Templates 2.4 as T
import org.videolan.vlc 0.1
-import "qrc:///widgets/" as Widgets
import "qrc:///style/"
import "qrc:///player/" as P
-import "qrc:///util/Helpers.js" as Helpers
-Widgets.IconControlButton {
+ControlButtonPopup {
id: root
- signal requestLockUnlockAutoHide(bool lock)
-
- readonly property bool _isCurrentViewPlayer: !paintOnly &&
(History.current.name === "player")
+ popup.width: VLCStyle.dp(256, VLCStyle.scale)
text: I18n.qtr("Playback Speed")
- color: (popup.visible) ? colors.accent : colors.playerControlBarFg
-
- // FIXME: We can't use upItem because a Popup is not an Item.
- Navigation.upAction: function() {
- if (popup.visible) {
- popup.forceActiveFocus(Qt.TabFocusReason)
+ popupContent: P.PlaybackSpeed {
+ colors: root.colors
- return
- }
+ Navigation.parentItem: root
- var parent = Navigation.parentItem;
-
- if (parent)
- parent.Navigation.defaultNavigationUp()
+ // NOTE: Mapping the right direction because the down action triggers
the ComboBox.
+ Navigation.rightItem: root
}
- onClicked: popup.open()
-
- Popup {
- id: popup
-
- parent: root.paintOnly
- ? root // button is not part of main display
(ToolbarEditorDialog)
- : root._isCurrentViewPlayer ? rootPlayer : g_root
-
- width: VLCStyle.dp(256, VLCStyle.scale)
- height: implicitHeight
-
- padding: VLCStyle.margin_small
-
- z: 1
-
- focus: true
-
- // Popup.CloseOnPressOutside doesn't work with non-model Popup on Qt <
5.15
- closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
-
- modal: true
-
- onOpened: {
- // update popup coordinates
- //
- // mapFromItem is affected by various properties of source and
target objects which
- // can't be represented in a binding expression so a initial
setting in object
- // definition (x: clamp(...)) doesn't work, so we set x and y on
initial open
- x = Qt.binding(function () {
- // coords are mapped through root.parent so that binding is
- // generated based on root.x
- var position = parent.mapFromItem(root.parent, root.x, 0)
-
- var minimum = VLCStyle.margin_xxsmall +
VLCStyle.applicationHorizontalMargin
-
- var maximum = parent.width -
VLCStyle.applicationHorizontalMargin
- - VLCStyle.margin_xxsmall - width
-
- return Helpers.clamp(position.x - ((width - root.width) / 2),
minimum, maximum)
- })
-
- y = Qt.binding(function () {
- // coords are mapped through root.parent so that binding is
- // generated based on root.y
- var position = parent.mapFromItem(root.parent, 0, root.y)
-
- return position.y - popup.height - VLCStyle.margin_xxsmall
- })
-
- // player related --
- root.requestLockUnlockAutoHide(true)
-
- if (root._isCurrentViewPlayer)
- rootPlayer.menu = popup
- }
-
- onClosed: {
- root.requestLockUnlockAutoHide(false)
-
- root.forceActiveFocus()
-
- if (root._isCurrentViewPlayer)
- rootPlayer.menu = undefined
- }
-
- Overlay.modal: null
-
- background: Rectangle {
- color: colors.bg
- opacity: .85
- }
-
- contentItem: P.PlaybackSpeed {
- colors: root.colors
-
- Navigation.parentItem: root
-
- // NOTE: Mapping the right direction because the down action
triggers the ComboBox.
- Navigation.rightItem: root
- }
- }
+ // Children
T.Label {
anchors.centerIn: parent
+
font.pixelSize: VLCStyle.fontSize_normal
text: !root.paintOnly ? I18n.qtr("%1x").arg(+Player.rate.toFixed(2))
=====================================
modules/gui/qt/player/qml/controlbarcontrols/TeletextButton.qml
=====================================
@@ -24,24 +24,10 @@ import QtQuick.Controls 2.4
import org.videolan.vlc 0.1
import "qrc:///style/"
-import "qrc:///widgets/" as Widgets
-import "qrc:///util/Helpers.js" as Helpers
-Widgets.IconControlButton {
+ControlButtonPopup {
id: root
- // Signals
-
- signal requestLockUnlockAutoHide(bool lock)
-
- // Properties
-
- // Private
-
- readonly property bool _isCurrentViewPlayer: (paintOnly === false
- &&
- History.current.name ===
"player")
-
// Settings
enabled: Player.isTeletextAvailable
@@ -50,111 +36,10 @@ Widgets.IconControlButton {
text: I18n.qtr("Teletext")
- color: (popup.visible) ? colors.accent : colors.playerControlBarFg
-
- // FIXME: We can't use upItem because a Popup is not an Item.
- Navigation.upAction: function() {
- if (popup.visible) {
- popup.forceActiveFocus(Qt.TabFocusReason)
-
- return
- }
-
- var parent = Navigation.parentItem;
-
- if (parent)
- parent.Navigation.defaultNavigationUp()
- }
-
- // Events
-
- onClicked: popup.open()
-
- // Connections
-
- Connections {
- target: (popup.visible) ? popup.parent : null
-
- onWidthChanged: _updatePosition()
- onHeightChanged: _updatePosition()
- }
-
- // Functions
-
- // Private
-
- function _updatePosition() {
- var parent = popup.parent
-
- var position = parent.mapFromItem(root, x, y)
-
- var popupX = Math.round(position.x - ((popup.width - width) / 2))
-
- var minimum = VLCStyle.applicationHorizontalMargin +
VLCStyle.margin_xxsmall
-
- var maximum = parent.width - popup.width - minimum
-
- popup.x = Helpers.clamp(popupX, minimum, maximum)
-
- popup.y = position.y - popup.height - VLCStyle.margin_xxsmall
- }
-
- // Children
-
- Popup {
- id: popup
-
- parent: (root._isCurrentViewPlayer) ? rootPlayer : g_root
-
- width: VLCStyle.dp(256, VLCStyle.scale)
- height: implicitHeight
-
- padding: VLCStyle.margin_small
-
- z: 1
-
- focus: true
-
- modal: true
-
- // NOTE: Popup.CloseOnPressOutside doesn't work with non-model Popup
on Qt < 5.15.
- closePolicy: (Popup.CloseOnPressOutside | Popup.CloseOnEscape)
-
- Overlay.modal: null
-
- onOpened: {
- root._updatePosition()
-
- root.requestLockUnlockAutoHide(true)
-
- if (root._isCurrentViewPlayer)
- rootPlayer.menu = popup
- }
-
- onClosed: {
- root.requestLockUnlockAutoHide(false)
-
- root.forceActiveFocus()
-
- if (root._isCurrentViewPlayer)
- rootPlayer.menu = undefined
- }
-
- onWidthChanged: if (visible) root._updatePosition()
- onHeightChanged: if (visible) root._updatePosition()
-
- background: Rectangle {
- opacity: 0.85
-
- color: colors.bg
- }
-
- contentItem: TeletextWidget {
- colors: root.colors
-
- Navigation.parentItem: root
+ popupContent: TeletextWidget {
+ colors: root.colors
- Navigation.downItem: root
- }
+ Navigation.parentItem: root
+ Navigation.downItem: root
}
}
=====================================
modules/gui/qt/vlc.qrc
=====================================
@@ -316,6 +316,7 @@
<file
alias="BookmarkButton.qml">player/qml/controlbarcontrols/BookmarkButton.qml</file>
<file
alias="ChapterNextButton.qml">player/qml/controlbarcontrols/ChapterNextButton.qml</file>
<file
alias="ChapterPreviousButton.qml">player/qml/controlbarcontrols/ChapterPreviousButton.qml</file>
+ <file
alias="ControlButtonPopup.qml">player/qml/controlbarcontrols/ControlButtonPopup.qml</file>
<file
alias="DvdMenuButton.qml">player/qml/controlbarcontrols/DvdMenuButton.qml</file>
<file
alias="ExpandingSpacerWidget.qml">player/qml/controlbarcontrols/ExpandingSpacerWidget.qml</file>
<file
alias="ExtendedSettingsButton.qml">player/qml/controlbarcontrols/ExtendedSettingsButton.qml</file>
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/28e2f45929eb9f8ccb2d86f44cbc66fa3abc14d0...3de5b7f1ee932d2b61235ebe6490c31da7727548
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/28e2f45929eb9f8ccb2d86f44cbc66fa3abc14d0...3de5b7f1ee932d2b61235ebe6490c31da7727548
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits