Add a new template for KCMs
Needs RevisionPublic

Authored by tcanabrava on Nov 4 2019, 11:18 PM.

Details

Reviewers
mart
ervin
Group Reviewers
Plasma
Frameworks
Summary

Starting a new KCM from scratch is currently a time consuming task,
you have to copy files or mount the correct hierarchy in disk and pray that it's correct, create files in the correct places and reference them in .desktop files,
the metadata file also references files or classes that are supposed to be in the project.
if you look at some KCM's, the code does not help as sometimes they reference as kcm_ other as KCM within the CMake.
As I'm porting KCM's from C++ to Qml, I realized that I'd spend *more* time just creating the initial skeleton than actually creating the code to handle the settings,
this will sabe my time, and hopefully, others.

Test Plan

Created a new project via KAppTemplate, compiled, run the kcm stuvb

Diff Detail

Repository
R242 Plasma Framework (Library)
Branch
kcm_template
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 18509
Build 18527: arc lint + arc unit
tcanabrava created this revision.Nov 4 2019, 11:18 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptNov 4 2019, 11:18 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
tcanabrava requested review of this revision.Nov 4 2019, 11:18 PM
tcanabrava edited the summary of this revision. (Show Details)Nov 4 2019, 11:21 PM
tcanabrava updated this revision to Diff 69296.Nov 4 2019, 11:24 PM
  • Update readme
ervin added a subscriber: ervin.Nov 5 2019, 7:22 AM

What about having the template use kcfg and ManagedConfigModule as well? It'd give better behaving modules by default and is a better practice than starting without them. I'd rather have people make the conscious decision to remove them because it turns out it's a KCM with no KConfig at all than people overlooking proper KConfig use by default.

ognarb added a subscriber: ognarb.Nov 6 2019, 12:19 AM

Another related todo would be to update/rewrite https://techbase.kde.org/Development/Tutorials/KCM_HowTo after this template is merged and include information about it ;)

A very sensible idea. ++

templates/kcm-qml/qml-plasmoid.png

What's this about?

templates/kcm-qml/package/contents/ui/main.qml
27

lets not encourage this import

yurchor added a subscriber: yurchor.Nov 6 2019, 6:24 AM
yurchor added inline comments.
templates/kcm-qml/package/contents/ui/main.qml
38

Typo: Exemple -> Example

tcanabrava updated this revision to Diff 69400.Nov 7 2019, 3:44 PM
  • Add KConfigXT

A very sensible idea. ++

templates/kcm-qml/qml-plasmoid.png

What's this about?

We need a better icon. it's the icon for the Plasmoid template.

ngraham retitled this revision from Add a new Template for KCM's. to Add a new template for KCMs.Nov 7 2019, 4:16 PM
GB_2 added a subscriber: GB_2.Nov 10 2019, 9:25 AM

We need a better icon. it's the icon for the Plasmoid template.

Why not use the system settings icon as it's a KCM template?

GB_2 added a project: Plasma.
GB_2 added a subscriber: Plasma.
tcanabrava updated this revision to Diff 69649.Nov 12 2019, 6:45 PM
tcanabrava marked 2 inline comments as done.
  • Add KConfigXT
  • Remove wrong icon
mart accepted this revision.Nov 13 2019, 8:23 PM
This revision is now accepted and ready to land.Nov 13 2019, 8:23 PM
ervin requested changes to this revision.Nov 13 2019, 9:59 PM
ervin added inline comments.
templates/kcm-qml/%{APPNAMELC}settings.kcfgc
5 ↗(On Diff #69649)

You also want "ParentInConstructor=true" in here.

templates/kcm-qml/kcm.cpp
33

Pass this as parent here (currently you're leaking it)

44

Shouldn't be needed anymore (and likely wrong in most cases).

templates/kcm-qml/kcm.h
27

This should inherit from ManagedConfigModule now.

37

None of those slots are needed with a ManagedConfigModule (except if you need to do something outside the realm of the settings of course, which is not the case by default.

templates/kcm-qml/package/contents/ui/main.qml
40

What about disabling it if the setting is immutable?

This revision now requires changes to proceed.Nov 13 2019, 9:59 PM
tcanabrava added inline comments.Nov 14 2019, 7:42 AM
templates/kcm-qml/kcm.cpp
44

What's the correct form then? No need to connect the settings *at all*?

templates/kcm-qml/package/contents/ui/main.qml
40

The default fake setting will not be immutable, or you mean that you want me to do one mutable and one immutable settings for the example?

ervin added inline comments.Nov 14 2019, 9:13 AM
templates/kcm-qml/kcm.cpp
44

No need indeed... it's *magic*! ;-)

templates/kcm-qml/package/contents/ui/main.qml
40

In fact you can't predict that, any setting can be made immutable (it's user and sysadmin controlled). No need to introduce another one.

tcanabrava updated this revision to Diff 69941.Nov 18 2019, 5:19 PM
tcanabrava marked an inline comment as done.
  • Adapt to ManagedConfigModule
tcanabrava updated this revision to Diff 69942.Nov 18 2019, 5:29 PM
  • Handle immutability
ervin added inline comments.Nov 19 2019, 8:35 AM
templates/kcm-qml/kcm.cpp
38

Nitpick: indentation looks broken here, I think it wasn't earlier.

tcanabrava updated this revision to Diff 71009.Dec 6 2019, 12:39 PM
tcanabrava marked an inline comment as done.
  • Fix indentation
tcanabrava marked 6 inline comments as done.Dec 6 2019, 12:40 PM
tcanabrava marked 2 inline comments as done.
ervin requested changes to this revision.Dec 12 2019, 8:40 AM
ervin added inline comments.
templates/kcm-qml/%{APPNAMELC}settings.kcfg
8 ↗(On Diff #71009)

Now that I think about it, what about using both key and name here? To have a nice property name and a "stranger" storage key?
Most people seem to miss that feature somehow, that'd make it more obvious.

templates/kcm-qml/Messages.sh
4

I'm talking mostly out of ignorance here, but shouldn't that harvest also the qml files somehow?

templates/kcm-qml/kcm.cpp
31

Ditto

37

Ditto

Beside that could use auto

templates/kcm-qml/kcm.h
33

Nitpick: space should be before * and & not after.

This revision now requires changes to proceed.Dec 12 2019, 8:40 AM