Skip to content

qml: accessing unavailable properties when control bar is made invisible or out of scope

to reproduce:

  • start a video playback, volume widget should be in the controlbar
  • click on a button in the control bar (repeat for instance)
  • before the control bar disapear, click on another window so the focus leaves VLC
  • wait for the control bar to disapear

this leads to error messages in the console

qml: focusReason is not available in VolumeWidget_QMLTYPE_141(0x7f23d9cafa90)!

@fuzun said there

Until a focusable item is found in the controlbar, it tries every control. If there is no control available for focusing, progress slider is focused. These are done within the controlbar, on top of that there are external checks when the miniplayer gets hidden overall to set the focus to another component. Because setting visible to false in Miniplayer affects all child items, the focus restoring mechanism starts regardless (there may be a race situation here, I'm not sure). I think this may need to be added to function recoverFocus if (!controlLayout.visible) return;

On the other hand, I propose adding a attached property for the things that can be controlled in C++ but not in QML. For example, setting item flags such as making item a focus scope.

When migrating to Control from FocusScope, because Control is not a focus scope, additional logic needs to be added.

For example onActiveFocusChanged: if (activeFocus) listView.forceActiveFocus(focusReason), this is used to set contentItem focus in Playlist. Maybe this would be unnecessary if it retained focus scope feature. (focusReason: listView.focusReason may still be needed to set in contentItem)

When I check Qt Quick Control derivatives, I see that they don't really set active focus in contentItem, but rather activeFocus stop at Control level, and the active focus is queried by accessing control.activeFocus in property bindings. This approach does not look suitable here, because many times external items are used as or in contentItem.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information