D28467: Converted to Page with a PlasmoidHeading in the heading

Nathaniel Graham noreply at phabricator.kde.org
Tue Apr 14 14:41:11 BST 2020


ngraham added inline comments.

INLINE COMMENTS

> niccolove wrote in FullRepresentation.qml:31
> I though that was done by
> 
>   toolbar.visible = (state == "DevicesState" || state == "NoDevicesState");
> 
> At the end of the file. If you try to use the widget standalone, you will notice that it does disappear. Problem is, system tray doesn't notice. I can't understand why it doesn't read the ".visible" property.

It's because the binding is broken.

In QML, there are two ways to change a property: with a binding, or imperatively.

A binding uses a colon, and looks like this: `visible: (state == "DevicesState" || state == "NoDevicesState")` You want to use binding as much as possible because the property being bound (`visible`) will auto-update when the condition changes.

Imparative code uses an equals sign: `toolbar.visible = (state == "DevicesState" || state == "NoDevicesState");`

This breaks any existing bindings, which means you become responsible for manually updating the property in question `toolbar.visible` whenever you want it to change. Theoretically that's taken care of by `onStateChanged:` but for some reason it doesn't seem to be working. Perhaps there's a state not accounted for there? In general I don't like using explicit `State`s though. I find that it leads to messy, imperative code.

REPOSITORY
  R97 Bluedevil

REVISION DETAIL
  https://phabricator.kde.org/D28467

To: niccolove, #plasma, ngraham
Cc: ngraham, plasma-devel, Orage, LeGast00n, The-Feren-OS-Dev, cblack, jraleigh, zachus, fbampaloukas, ragreen, ZrenBot, himcesjf, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, ahiemstra, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20200414/c4b392d0/attachment-0001.html>


More information about the Plasma-devel mailing list