Bug 438610

Summary: When a device connects, it is positioned too far down for a moment, causing it to overlap the separator line
Product: [Plasma] Bluedevil Reporter: Piotr Mierzwinski <piotr.mierzwinski>
Component: system trayAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: aronkvh, guimarcalsilva, herzenschein, isma.af, natalie_clarius, nate, piotr.mierzwinski, plasma-bugs, postix, rybak.a.v, sitter
Priority: HI    
Version: 5.22.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In: 5.27.5
Sentry Crash Report:
Attachments: plasma-bluetooth-separating_line (incorrect)
plasma-bluetooth-separating_line (incorrect,dark)
Plasma-font
plasma-bluetooth-separating_line (incorrect)-Neon
how-to-achieve-incorrect-separator-in_blutooth
The glitch in Breeze dark

Description Piotr Mierzwinski 2021-06-14 11:46:18 UTC
Created attachment 139306 [details]
plasma-bluetooth-separating_line (incorrect)

SUMMARY
I have paired couple BT devices.
After connecting device to bluetooth, line which separates them in Bluetooth panel partially crosses out connected device when I close it (panel) before connection has been established. If I will wait till connection will be established this line is correctly displayed.
Details please find in attached screenshot.

STEPS TO REPRODUCE
1.  Click connect in Bluetooth panel/applet
2. Don't wait till connection will be established only click into desktop, closing Bluetooth panel
3. If connection becomes established open Bluetooth panel
4. Look at  separating line

OBSERVED RESULT
line partially crosses out connected device

EXPECTED RESULT
line should not cross out connected device

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: YES
(available in About System)
KDE Plasma Version: 5.22
KDE Frameworks Version: 5.82
Qt Version: 5.15.2 (+kde patches)

ADDITIONAL INFORMATION
Comment 1 Piotr Mierzwinski 2021-06-14 11:49:49 UTC
Created attachment 139307 [details]
plasma-bluetooth-separating_line (incorrect,dark)
Comment 2 Piotr Mierzwinski 2021-06-14 12:06:53 UTC
In case of bright plasma I used Plasma Style calling: Breeze
In case of dark plasma I used Plasma Style calling: ROUNDED COLOR
Comment 3 Nate Graham 2021-06-15 20:41:43 UTC
Works for me. What font and font size are you using? Are you overriding the font DPI in any way?
Comment 4 Piotr Mierzwinski 2021-06-15 20:52:34 UTC
(In reply to Nate Graham from comment #3)
> Works for me. What font and font size are you using? Are you overriding the
> font DPI in any way?

Fixed width: Hack 10pt
All other: Noto Sans 10pt
DPI is not overridden. Other details in attached screen.

As I mentioned for me also works, but only when I wait till connection will be established, otherwise always this line is drawn in incorrect place (as in attachment).
Comment 5 Piotr Mierzwinski 2021-06-15 20:54:41 UTC
Created attachment 139346 [details]
Plasma-font
Comment 6 Nate Graham 2021-06-15 20:59:50 UTC
Hmm that's strange, then.
Comment 7 Piotr Mierzwinski 2021-06-16 15:10:25 UTC
(In reply to Nate Graham from comment #6)
I'm not sure, but I think you are doing something wrong and that's why you cannot replicate it.
I just did it on KDE Neon (Unstable edition) using newly created user account. So having couple BT devices please click "Connect" on first and immediately click into desktop. After connection will be established please open Bluetooth panel.

I will attach another screen shot coming from Neon.

Plasma 5.22.80; 
    Style: ROUNDED COLOR; Color: Dark Breeze; Font: Noto Sans 10pt with forced DPI (120)
KF 5.83
Qt 5.15.3
X11

Let me know if you need more details.
Comment 8 Nate Graham 2021-06-16 15:22:33 UTC
Could you attach a screen recording so I can be sure I'm testing in the same way?
Comment 9 Piotr Mierzwinski 2021-06-16 16:26:55 UTC
Created attachment 139394 [details]
plasma-bluetooth-separating_line (incorrect)-Neon
Comment 10 Piotr Mierzwinski 2021-06-16 16:51:38 UTC
Created attachment 139396 [details]
how-to-achieve-incorrect-separator-in_blutooth
Comment 11 Nate Graham 2021-06-16 17:11:51 UTC
Thanks, can reproduce now. It's actually not that the line is positioned incorrectly, but rather that the connected item is positioned incorrectly. For me, I can see that it overlaps the line when it connects, but then in a moment, it jumps up to its correct location.

I'll see what I can do about it.
Comment 12 Nate Graham 2021-06-16 17:57:50 UTC
The bug is somewhere here: https://invent.kde.org/plasma/bluedevil/-/blob/master/src/applet/package/contents/ui/FullRepresentation.qml#L76

I suspect that the conditions get evaluated at different times, which causes the UI to not update both elements simultaneously, as expected.

Prooooooobably this line in particular:

height: active ? PlasmaCore.Units.gridUnit : 0
Comment 13 Nate Graham 2021-06-16 18:02:21 UTC
Yeah it's that line, but without it, the loader for the section delegate that we're trying to hide is invisibly there with too much height.

Can't figure it out right now, giving up. Hopefully someone smarter than me can figure it out.
Comment 14 Piotr Mierzwinski 2021-06-16 20:06:29 UTC
(In reply to Nate Graham from comment #13)
> Yeah it's that line, but without it, the loader for the section delegate
> that we're trying to hide is invisibly there with too much height.
> 
> Can't figure it out right now, giving up. Hopefully someone smarter than me
> can figure it out.

Thank you for your effort.
I think this was redesigned comparing to 5.21, so maybe author this change will be know something more.
Comment 15 Nate Graham 2021-06-16 20:50:01 UTC
It was, and I was the author. :/
Comment 16 Andrei Rybak 2021-11-26 18:49:52 UTC
Created attachment 143976 [details]
The glitch in Breeze dark
Comment 17 Nate Graham 2022-01-11 21:35:22 UTC
*** Bug 447189 has been marked as a duplicate of this bug. ***
Comment 18 Nate Graham 2022-01-13 04:36:16 UTC
*** Bug 448158 has been marked as a duplicate of this bug. ***
Comment 19 Nate Graham 2022-05-02 03:41:11 UTC
Ah, the problem is that Logic.conectedDevicesCount() is imperative, and not a property. So when that changes, the UI code doesn't get notified and updated itself as it should.
Comment 20 Ismael Asensio 2022-06-04 11:54:11 UTC
(In reply to Nate Graham from comment #19)
> Ah, the problem is that Logic.conectedDevicesCount() is imperative, and not
> a property. So when that changes, the UI code doesn't get notified and
> updated itself as it should.

I've been playing with this for a bit, and I'm mostly convinced that this is an upstream issue on how sections are created, possible due to optimizations.

It seems that when creating the new "Connected" section, a copy of the other one is first made, and then the properties get updated, which results in the visual glitch. This is what happens when connecting a new device. 

// This is the "Available" section loader
qml: ** Loader.onActiveChanged() ID: QQuickLoader(0x55c6450a4800) section: Available connectedDevices: 1 active: true
// This is the "Connected" section loader. But it starts as "Available"
qml: ** Loader.onActiveChanged() ID: QQuickLoader(0x55c6450a3480) section: Available connectedDevices: 1 active: true
qml: ** Loader.onActiveChanged() ID: QQuickLoader(0x55c6450a3480) section: Connected connectedDevices: 1 active: false

All the things I've tried didn't make the glitch go away:
- Refactoring the applet to use properties instead of imperative code doesn't fix the issue.
- Playing with the height and active properties to change the order of evaluation
- Using the Connected property instead of the proxy Section, so we're sure the sorting and the sections are in sync.
Comment 21 Harald Sitter 2023-04-25 11:21:34 UTC
https://bugreports.qt.io/browse/QTBUG-29148
Comment 22 Bug Janitor Service 2023-04-25 11:28:16 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/bluedevil/-/merge_requests/123
Comment 23 Harald Sitter 2023-04-25 15:06:30 UTC
Git commit 6201245c45b96fd6f06cca9e532cd7a184f4c743 by Harald Sitter.
Committed on 25/04/2023 at 11:27.
Pushed by ngraham into branch 'master'.

applet: introduce a brief animation for section height estimates

section delegates changing height is a bit buggy.
as a simple bandaid try to delay the height change a bit via a behavior.
NOTE: this doesn't actually animate, it's purely there for the delay
aspect

huge hack but it gives the view a better chance of figuring out a layout
that works from my testing

QTBUG-29148

M  +4    -0    src/applet/package/contents/ui/FullRepresentation.qml

https://invent.kde.org/plasma/bluedevil/commit/6201245c45b96fd6f06cca9e532cd7a184f4c743
Comment 24 Nate Graham 2023-04-25 15:07:19 UTC
Git commit 1956411588dbed54acb672d89ca003d8806684c4 by Nate Graham, on behalf of Harald Sitter.
Committed on 25/04/2023 at 15:07.
Pushed by ngraham into branch 'Plasma/5.27'.

applet: introduce a brief animation for section height estimates

section delegates changing height is a bit buggy.
as a simple bandaid try to delay the height change a bit via a behavior.
NOTE: this doesn't actually animate, it's purely there for the delay
aspect

huge hack but it gives the view a better chance of figuring out a layout
that works from my testing

QTBUG-29148


(cherry picked from commit 6201245c45b96fd6f06cca9e532cd7a184f4c743)

M  +4    -0    src/applet/package/contents/ui/FullRepresentation.qml

https://invent.kde.org/plasma/bluedevil/commit/1956411588dbed54acb672d89ca003d8806684c4