Skip to content

Drop "Advanced Power Settings" KCM in favor of a new QML page

A QML port of kcmodule/global a.k.a. kcm_powerdevilglobalconfig a.k.a. "Advanced Power Settings", which gets dropped and replaced by a child page within the "Energy Saving" KCM (accessible via header action).

Update: There's been a few changes since I originally submitted this MR, so the original screenshot isn't fully representative anymore. It's mostly the same but with some tweaks following reviewer comments. Prominently the "Configure Notifications" button went back down into a regular form field as "Related Pages" ToolButton. Also it obviously looks a little different when properly themed with Breeze. I'll keep the original screenshots for now because I don't have new ones for one or two related reasons.

BUG: 449254 CCBUG: 450276 CCBUG: 459081


Original KCM (QWidgets):

Screenshot_20230824_114923

After applying this commit (Qt Quick) - not fully up to date after making the old KCM a child page of "Energy Savings":

Screenshot_20230825_002247

While screenshots are always nice to look at, I encourage any reviewer to actually apply the patch and play with the interactions to get a full sense especially of how the charge limit stuff is working now.

Updated commit message below:


Drop "Advanced Power Settings" KCM in favor of a new QML page

This commit removes the QWidgets-based KCM in kcmodule/global, and instead adds a new QML page accessible via header action in the existing "Energy Saving" (QML) KCM a.k.a. profiles config. Renaming folder and class names of the profiles KCM to reflect its combined scope is left for a later commit.

I modified the "Energy Saving" KCM's JSON file to declare it on the top level of System Settings, and merged extra keywords from the now deleted kcm_powerdevilglobalconfig.json. We'll have to remove the "power-management" category from System Settings after this, as only a single KCM is left.

New C++ KCM backend code is mostly moved from GeneralPage.{h,cpp}:

  • PowerDevil::GlobalSettings provides kcm.settings.global for QML.
  • KAuth-powered ChargeThresholdHelper settings are accessible via kcm.externalServiceSettings & left out of non-default highlighting.
  • "Supports $X" properties are added to the KCM class directly.

All in all, it's a fairly straight port that doesn't change the underlying data representation apart from the obvious C++/QML split. Only the magic value -1 gets replaced by a constant named ChargeThresholdUnsupported, plus functions for checking support.

The UI is also roughly the same. That said, there are some differences:

  • I replaced the "Configure Notifications" button with a column of two ToolButtons in the style of Quick Settings' "Most used pages".

  • The start-charging threshold, i.e. the lower bound, previously had a weirdly long spinbox field because it needed to fit the "special value" text "Always charge when plugged in". This looks awkward and is not easily discoverable. Furthermore, QQC2.SpinBox doesn't have a concept of a "special value" and doesn't pre-allocate item width for any given space. I decided to represent this state with numeric percentages only.

    • "Special value" means display text for the minimum value ("from") of a QSpinBox. The start-charging threshold QSpinBox had no minimum set in generalPage.ui, so its "special value" would have been 0. This makes little sense, "Always charge" for the start threshold is conceptually more similar to "start threshold equals stop threshold".
    • Hence, the start threshold SpinBox now starts at 1, not 0, and the maximum allowed value is that of the stop threshold from the other field above. If the maximum value is selected, we write the "special value" 0 to the backend. If the backend value changes to 0, we set the UI to the stop threshold value.
Edited by Jakob Petsovits

Merge request reports