Porting guide from PlasmaComponents 2 to PlasmaComponents 3?

One of the changes in Plasma 6 is that PlasmaComponents 2 has been completely removed, so any plasmoids that still use it will need to be ported to PlasmaComponents 3. One such plasmoid is the one KDE Connect provides, so I’m wondering if there is a guide for that, similar to the one for porting plasmoids to KF6 (Porting Plasmoids to KF6 | Developer)? Or, is it considered an advanced task, especially for someone who neither wrote the original plasmoid nor has much experience with QML and whatnot?

That’s weird that the porting guide doesn’t mention this, but all you need to do is look in plasma-framework and see if the PC3-equivalent control exists for whatever was still using PC2. That might exist in the PlasmaExtras module too, but there’s usually an obvious replacement for whatever you need.

2 Likes

Yeah. seems like a good opportunity for improvement.

FWIW Some things don’t have a direct 1:1 name compatibility, e.g. PlasmaExtras.ScrollArea is replaced with PlasmaComponents.ScrollView. We probably do need to improve the documentation here.

Since PlasmaComponents2 is based on Qt Quick Controls 1 and PlasmaComponents3 is based on Qt Quick Controls 2 this overview is also relevant: Differences with Qt Quick Controls 1 | Qt Quick Controls 5.15.15

Ah yeah, I did actually give it a (pretty much blind) go, and the main problem I remember running into was that I couldn’t find direct equivalents between some PC2 and PC3 things, which is why I was hoping there was a proper guide to it that I just missed.

For example, taking the current state of the KDE Connect plasmoid and running it using plasmawindowed, the first error I get is that DeviceDelegate.qml (plasmoid/package/contents/ui/DeviceDelegate.qml · master · Network / KDE Connect · GitLab) is using PC2, and the first thing it uses from PC2 is ListItem. I had a look in Plasma's QML API | Developer, src/declarativeimports · master · Plasma / KDE Plasma Framework · GitLab as well as that differences with QQC1 page and none of them mention ListItem as far as I can see, so it’s not immediately obvious to me what the PC3/QQC2 equivalent is.

In that same file I also see DialogStatus.Open as well as ContextMenu being things from PC2 that I also don’t see an direct equivalent for in PC3 (other than the plain Menu?).

For ListItem use ItemDelegate

For menu there’s an equivalent in PlasmaExtras

So I went about porting the KDE Connect plasmoid to PC3, KF6 and QQC2 as best I can (just renaming things for the most part, except for the actions API), got it to the point where the only error reported by plasmawindowed is Expression depends on non-NOTIFYable properties: RemoteCommandsDbusInterface::canAddCommand, and this is what I see with two devices connected (one Android phone and another PC running Plasma, with the notifications coming from the phone):

Now that I’m guessing is beyond the realm of simple porting lol. If I run it with plasmashell proper, after fixing the metadata the icon does appear in the panel, but it doesn’t do anything when clicked (so it’s even less functional than what I can get via plasmawindowed).

On the bright side, at least some of the functionality seems to work, for example in the per-device menu the share file, ring phone and browse device options do what I’d expect, that + button does bring up the add remote commands dialog in the remote device, and clearing individual notifications by clicking on the X icons does work. It also looks slightly less horrific with just one device connected instead of two.

So, since I have no idea whereabouts to proceed from here, would it be worth it at all for me to put up a merge request with the changes I have to get to this point?

Actually, I did manage to get the plasmoid to appear in plasmashell proper, so I decided to file the MR anyway: Draft: plasmoid: Initial port to KF6/Plasma 6 (!612) · Merge requests · Network / KDE Connect · GitLab

image

Still no clue how to fix the layout problem, but I hope my port attempt would at least be helpful as a base if nothing else.

1 Like