Skip to content
Snippets Groups Projects
Commit d695e4fa authored by Benjamin Arnaud's avatar Benjamin Arnaud Committed by Jean-Baptiste Kempf
Browse files

qml: Safeguard Keys.onReleased events

fix #25598
parent 470005c7
No related branches found
No related tags found
1 merge request!2075qml: Safeguard Keys.onReleased events
Pipeline #233170 passed with stage
in 14 minutes and 54 seconds
......@@ -32,6 +32,8 @@ FocusScope {
property alias coverWidth: coverContainer.width
property alias coverHeight: coverContainer.height
property bool _keyPressed: false
Column {
anchors.verticalCenter: parent.verticalCenter
width: root.width
......@@ -86,11 +88,23 @@ FocusScope {
}
Keys.priority: Keys.AfterItem
Keys.onPressed: Navigation.defaultKeyAction(event)
Keys.onPressed: {
_keyPressed = true
Navigation.defaultKeyAction(event)
}
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (KeyHelper.matchOk(event)) {
History.push(["mc", "network"])
}
Navigation.defaultKeyReleaseAction(event)
}
}
......@@ -56,6 +56,8 @@ FocusScope {
readonly property VLCColors colors: (MainCtx.hasEmbededVideo) ? VLCStyle.nightColors
: VLCStyle.colors
property bool _keyPressed: false
// Events
Component.onCompleted: MainCtx.preferHotkeys = true
......@@ -65,6 +67,9 @@ FocusScope {
Keys.onPressed: {
if (event.accepted)
return
_keyPressed = true
rootPlayer.Navigation.defaultKeyAction(event)
//unhandled keys are forwarded as hotkeys
......@@ -73,8 +78,11 @@ FocusScope {
}
Keys.onReleased: {
if (event.accepted)
if (event.accepted || _keyPressed === false)
return
_keyPressed = false
if (event.key === Qt.Key_Menu) {
toolbarAutoHide.toggleForceVisible()
} else {
......
......@@ -31,6 +31,10 @@ import "qrc:///widgets/" as Widgets
T.MenuItem {
id: control
property Item parentMenu: null
property bool _keyPressed: false
//implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
// implicitContentWidth + leftPadding + rightPadding)
implicitHeight: contentId.implicitHeight + topPadding + bottomPadding
......@@ -46,8 +50,6 @@ T.MenuItem {
leftPadding: VLCStyle.applicationHorizontalMargin
property Item parentMenu: null
//workaround QTBUG-7018 for Qt < 5.12.2
activeFocusOnTab: control.enabled
......@@ -128,9 +130,17 @@ T.MenuItem {
event.accepted = false
}
Keys.onPressed: _keyPressed = true
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (KeyHelper.matchCancel(event)) {
event.accepted = true
parentMenu.dismiss()
}
}
......
......@@ -36,19 +36,30 @@ AbstractButton {
readonly property real minimumWidth: cover.width + (leftPadding + rightPadding)
property bool _keyPressed: false
padding: VLCStyle.focus_border
Keys.onPressed: {
if (KeyHelper.matchOk(event))
if (KeyHelper.matchOk(event)) {
event.accepted = true
Navigation.defaultKeyAction(event)
_keyPressed = true
} else {
Navigation.defaultKeyAction(event)
}
}
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (KeyHelper.matchOk(event)) {
g_mainDisplay.showPlayer()
event.accepted = true
g_mainDisplay.showPlayer()
}
}
......
......@@ -93,6 +93,8 @@ T.Pane {
property real _clamp: 0.01
property bool _keyPressed: false
from: 0
to: maxvolpos
opacity: _player.muted ? 0.5 : 1
......@@ -102,12 +104,19 @@ T.Pane {
Keys.onPressed: {
if (KeyHelper.matchOk(event)) {
event.accepted = true
_keyPressed = true
} else {
Navigation.defaultKeyAction(event)
}
}
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (KeyHelper.matchOk(event)) {
Player.muted = !Player.muted
}
......
......@@ -62,6 +62,10 @@ FocusScope {
GridView {
id: view
property int _colCount: Math.floor(width / cellWidth)
property bool _keyPressed: false
anchors.fill: parent
clip: true
......@@ -72,8 +76,6 @@ FocusScope {
//key navigation is reimplemented for item selection
keyNavigationEnabled: false
property int _colCount: Math.floor(width / cellWidth)
Util.FlickableScrollHandler { }
Keys.onPressed: {
......@@ -101,6 +103,8 @@ FocusScope {
} else if (KeyHelper.matchOk(event) || event.matches(StandardKey.SelectAll) ) {
//these events are matched on release
event.accepted = true
_keyPressed = true
}
if (newIndex >= 0 && newIndex < modelCount && newIndex != currentIndex) {
......@@ -115,6 +119,11 @@ FocusScope {
}
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (event.matches(StandardKey.SelectAll)) {
event.accepted = true
selectAll()
......
......@@ -92,6 +92,10 @@ ListView {
}
}
// Private
property bool _keyPressed: false
// Aliases
//forward view properties
......@@ -227,9 +231,11 @@ ListView {
}
}
if (KeyHelper.matchOk(event) || event.matches(StandardKey.SelectAll) ) {
//these events are matched on release
// these events are matched on release
if (event.matches(StandardKey.SelectAll) || KeyHelper.matchOk(event)) {
event.accepted = true
_keyPressed = true
}
var oldIndex = currentIndex
......@@ -256,10 +262,15 @@ ListView {
}
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (event.matches(StandardKey.SelectAll)) {
event.accepted = true
selectAll()
} else if ( KeyHelper.matchOk(event) ) { //enter/return/space
} else if (KeyHelper.matchOk(event)) { //enter/return/space
event.accepted = true
actionAtIndex(currentIndex)
}
......
......@@ -135,6 +135,9 @@ FocusScope {
}
FocusScope {
id: presentation
property bool _keyPressed: false
Layout.fillHeight: true
Layout.fillWidth: true
focus: true
......@@ -176,7 +179,14 @@ FocusScope {
root.Navigation.defaultNavigationLeft()
}
Keys.onPressed: _keyPressed = true
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
if (KeyHelper.matchOk(event)) {
itemDoubleClicked(event.key, event.modifiers)
}
......
......@@ -102,6 +102,8 @@ FocusScope {
TextField {
id: textField
property bool _keyPressed: false
anchors.top: parent.top
anchors.bottom: parent.bottom
......@@ -140,17 +142,27 @@ FocusScope {
}
Keys.priority: Keys.AfterItem
Keys.onPressed: {
_keyPressed = true
//we don't want Navigation.cancelAction to match Backspace
if (event.matches(StandardKey.Backspace))
event.accepted = true
Navigation.defaultKeyAction(event)
}
Keys.onReleased: {
if (_keyPressed === false)
return
_keyPressed = false
//we don't want Navigation.cancelAction to match Backspace
if (event.matches(StandardKey.Backspace))
event.accepted = true
Navigation.defaultKeyReleaseAction(event)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment