Trying to create a Plasmoid which retrieves a specific Category of apps

I am new to this; all I have done so far is modifying a few existing plasmoids to my needs.

Now I am trying to put together a plasmoid that will retrieve the “content” of one and only one category of apps: “internet”, “games”, etc.

I have been trying to figure out this by studying the kickoff Application Launchers available on Plasma, but they all seem very intricate.

If I understand it correctly, the system provides a mixed list of apps and categories, among which I discriminate using the isCategory property?

Even if this is true, scouting the code I have seen so far, I cannot pinpoint where and how such mixed list of apps is loaded.

Can someone give me a nudge in the right direction?
(or is there a more specific forum for plasmoid development I should go to?)

I’ve made some research and here’s what I’ve found :

  1. I’ve search inside the KickoffListView.qml because that was the most logical thing IMO.
    On line 21 we can see that the actual list model is just an alias property, so we need to find where it is defined.

  2. Using this site I’ve searched for a file with qml in its name and KickoffListView in its content. Once you’ve find what you want, check the file directly on gitlab, it’s more up to date. Looking at it I’ve found the DropAreaListView which pretty much a wrapper for the KickoffListView.

  3. Using the same method I’ve searched for a file with qml in its name and DropAreaListView in its content, and the only match is ApplicationsPage (I could have find it before but that’s part of the game I guess :sweat_smile: ). And in it we can see on line 84 the model being defined as the property rootModel of kickoff.

  4. Let’s check the kickoff.qml file then ! On line 44 we have the rootModel being defined. Its type is Kicker.RootModel, and we can guess that Kicker is a module being imported at the top of the page. On line 20 kicker is imported, it’s coming from org.kde.plasma.private.kicker

  5. Let’s search for that ! We know that module are exposed to QML using C++ file, so I’ve search for a file with cpp in its name and org.kde.plasma.private.kicker in its content, and I’ve found the only match. We can clearly see that this is the C++ file defining this module. Now what I wanted was the RootModel , it’s pretty easy to spot it directly at line 44 (no need to go in gitlab this time).

  6. We can see that rootModel is an object of type rootModel (qmlRegisterType<RootModel>) and by clicking on RootModel between bracket, we finally arrive to this page.

Finally, let’s try to find it on Gitlab, and here it is.

This was long, sorry, but I wanted to show you how I usually handle those kind of problems where I need to find code, I hope this has been helpful !

1 Like

This was impressive, and thank you. I had searched for clues in some of the same files.

Unfortunately I cannot really wrap my head around rootModel in relation to creating a plasmoid menu. Way over my head.

Not sure and can’t check. But isn’t there a setting in the default app launcher that allows to show only what you want on a certain desktop?
In either case, I’m not really sure what exactly you want to achieve.

I want to achieve a popup menu, separate from the default Application Launcher, which would be added on the panel by the user, and which would automatically show the content from only one category, for example “Internet” or “Office”, as selected by the user. Popup Launcher comes close, but you have to manually add each application to the menu.

Alright, let’s dig a little bit deeper, just as last time :

Coming back to the ApplicationsPage, on line 154 we see some property being set "currentSection": sectionName, that seems interresting, let’s check what this is all about !

The property is for a component called applicationsSectionViewComponent which is the component define on line 120, perfect, let’s see what kind of model it uses ! Line 124 model: stackView.appsModel.sections, so it’s the appModel of a component called stackView let’s see where this is defined. (Btw, appsModel.sections, we might be on the good path here)

Line 26 stackView is defined, let’s search it’s appModel , line 73, and that’s something interresting, we still use a rootModel but we call a method called modelForRow which take an int as argument.

Right now we can deduce that you could get the correct section by passing the correct int to this method and call it a day.

:grin:

But what if I want to learn more about how this method work ? It’s sometimes important to fully understand the code, so let’s do this as an exemple !
We’re gonna go on the rootmodel.cpp file once again and search for modelForRow. No result… That’s weird… Maybe rootModel is a subclass and the method is defined elsewhere then ?

Let’s check the header file of root model to see if it’s a subclass of something else ! Line 34 RootModel is in fact an AppsModel, sweet, maybe modelForRow is in appmodel.cpp. And yep, line 285, we can see how this works
:sunglasses:

This time I only use the Ctrl + F function of my web browser and navigate a bit inside gitlab to find this, nothing crazy. I hope this was helpful :wink:

Btw, I don’t test what I find, so I might be wrong, I’m mainly pointing out what I think could work and showing how I usually work around those kind of problem

1 Like