mirror of https://code.videolan.org/videolan/vlc
qml: fix ControlButtonPopup.qml
- Remove unnecessary placement logic. - Correct unqualified access (root). - Correctly override content item.
This commit is contained in:
parent
3d1addbfef
commit
d59aa6169e
|
@ -29,16 +29,9 @@ import "qrc:///util/Helpers.js" as Helpers
|
||||||
|
|
||||||
Widgets.IconControlButton {
|
Widgets.IconControlButton {
|
||||||
id: control
|
id: control
|
||||||
// Properties
|
|
||||||
|
|
||||||
// Private
|
|
||||||
|
|
||||||
readonly property bool _isCurrentViewPlayer: History.match(History.viewPath, ["player"])
|
|
||||||
|
|
||||||
// Aliases
|
// Aliases
|
||||||
|
|
||||||
property alias popupContent: popup.contentItem
|
|
||||||
|
|
||||||
property alias popup: popup
|
property alias popup: popup
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
|
@ -69,49 +62,22 @@ Widgets.IconControlButton {
|
||||||
|
|
||||||
onClicked: popup.open()
|
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() {
|
|
||||||
const parent = popup.parent
|
|
||||||
|
|
||||||
const position = parent.mapFromItem(root, x, y)
|
|
||||||
|
|
||||||
const popupX = Math.round(position.x - ((popup.width - width) / 2))
|
|
||||||
|
|
||||||
const minimum = VLCStyle.applicationHorizontalMargin + VLCStyle.margin_xxsmall
|
|
||||||
|
|
||||||
const maximum = parent.width - popup.width - minimum
|
|
||||||
|
|
||||||
popup.x = Helpers.clamp(popupX, minimum, maximum)
|
|
||||||
|
|
||||||
popup.y = position.y - popup.height - VLCStyle.margin_xxsmall
|
|
||||||
}
|
|
||||||
|
|
||||||
// Children
|
// Children
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
id: popup
|
id: popup
|
||||||
|
|
||||||
parent: (root._isCurrentViewPlayer) ? rootPlayer : g_mainInterface
|
x: (parent.width - width) / 2
|
||||||
|
y: -height - VLCStyle.margin_xxxsmall
|
||||||
|
|
||||||
padding: VLCStyle.margin_small
|
padding: VLCStyle.margin_small
|
||||||
|
|
||||||
z: 1
|
|
||||||
|
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
|
// This popup should not exceed the boundaries of the scene.
|
||||||
|
// Setting margins to >=0 makes it sure that this is satisfied.
|
||||||
|
margins: 0
|
||||||
|
|
||||||
modal: true
|
modal: true
|
||||||
|
|
||||||
// NOTE: Popup.CloseOnPressOutside doesn't work with non-model Popup on Qt < 5.15.
|
// NOTE: Popup.CloseOnPressOutside doesn't work with non-model Popup on Qt < 5.15.
|
||||||
|
@ -122,24 +88,19 @@ Widgets.IconControlButton {
|
||||||
// Events
|
// Events
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
root._updatePosition()
|
control.requestLockUnlockAutoHide(true)
|
||||||
|
|
||||||
root.requestLockUnlockAutoHide(true)
|
control.menuOpened(popup)
|
||||||
|
|
||||||
root.menuOpened(popup)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosed: {
|
onClosed: {
|
||||||
root.requestLockUnlockAutoHide(false)
|
control.requestLockUnlockAutoHide(false)
|
||||||
|
|
||||||
root.forceActiveFocus()
|
control.forceActiveFocus()
|
||||||
|
|
||||||
root.menuOpened(null)
|
control.menuOpened(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
onWidthChanged: if (visible) root._updatePosition()
|
|
||||||
onHeightChanged: if (visible) root._updatePosition()
|
|
||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
ColorContext {
|
ColorContext {
|
||||||
id: popupTheme
|
id: popupTheme
|
||||||
|
|
|
@ -31,7 +31,7 @@ ControlButtonPopup {
|
||||||
|
|
||||||
text: I18n.qtr("Playback Speed")
|
text: I18n.qtr("Playback Speed")
|
||||||
|
|
||||||
popupContent: P.PlaybackSpeed {
|
popup.contentItem: P.PlaybackSpeed {
|
||||||
colorContext.palette: root.colorContext.palette
|
colorContext.palette: root.colorContext.palette
|
||||||
|
|
||||||
Navigation.parentItem: root
|
Navigation.parentItem: root
|
||||||
|
|
|
@ -36,7 +36,7 @@ ControlButtonPopup {
|
||||||
|
|
||||||
text: I18n.qtr("Teletext")
|
text: I18n.qtr("Teletext")
|
||||||
|
|
||||||
popupContent: TeletextWidget {
|
popup.contentItem: TeletextWidget {
|
||||||
colorContext.palette: root.colorContext.palette
|
colorContext.palette: root.colorContext.palette
|
||||||
|
|
||||||
Navigation.parentItem: root
|
Navigation.parentItem: root
|
||||||
|
|
Loading…
Reference in New Issue