qml: don't connect to onEnabledChanged signals in Connections

Connection already have an `enabled` property so it is confusing
regarding which object is targeted.

with the `function onXXX()` syntax binding to this signal will fail
This commit is contained in:
Pierre Lamot 2024-04-10 15:48:35 +02:00 committed by Steve Lhomme
parent 865a825dd7
commit 9e6ef484e8
3 changed files with 8 additions and 25 deletions

View File

@ -94,6 +94,12 @@ Repeater {
if (item.menuOpened)
item.menuOpened.connect(repeater.menuOpened)
//can't connect to enabledChanged in a Connections
item.onEnabledChanged.connect(() => {
if (loader.activeFocus && !item.enabled) // Loader has focus but item is not enabled
recoverFocus()
})
}
// Connections
@ -103,11 +109,6 @@ Repeater {
enabled: loader.status === Loader.Ready
onEnabledChanged: {
if (activeFocus && !item.enabled) // Loader has focus but item is not enabled
recoverFocus()
}
onVisibleChanged: {
if (activeFocus && !item.visible)
recoverFocus()

View File

@ -128,16 +128,6 @@ T.Control {
// Childs
Component {
id: enabledConnection
Connections {
onEnabledChanged: root._countEnabled += (target.enabled ? 1 : -1)
}
}
// Childs
contentItem: Column {
spacing: root.spacing
@ -147,7 +137,7 @@ T.Control {
onItemAdded: (index, item) => {
if (item.enabled) root._countEnabled += 1;
enabledConnection.createObject(item, { target: item });
item.onEnabledChanged.connect(() => { root._countEnabled += (target.enabled ? 1 : -1) });
item.Navigation.upAction = function() {
let i = index;

View File

@ -134,14 +134,6 @@ T.Control {
// Childs
Component {
id: enabledConnection
Connections {
onEnabledChanged: root._countEnabled += (target.enabled ? 1 : -1)
}
}
contentItem: Row {
spacing: root.spacing
@ -151,7 +143,7 @@ T.Control {
onItemAdded: (index, item) => {
if (item.enabled) root._countEnabled += 1;
enabledConnection.createObject(item, { target: item });
item.onEnabledChanged.connect(() => { root._countEnabled += (target.enabled ? 1 : -1) })
item.Navigation.parentItem = root;