Skip to content

kcms/recentFiles: Fixing issue with config save value (Bug #397487) + adding log category

This is an attempt to fix the bug 397487: In short, it tweaks kcms/recentFiles to have a custom setting value for whatToRemember widget in order to also write the correct value in ~/.config/kactivitymanagerd-pluginsrc

To my understanding, what is happening is that by default when we have QGroupBox with QRadioButtons underneath, kconfigdialogmanager will set the value of that config section to the index of the QRadioButton currently checked. For recent files settings this would be (in order of appearance in the layout):

  • "For all applications" : 0
  • "Do not remember" : 1
  • "Only for specific applications:" : 2

However, if you check the enum in both kactivitymanagerd and kcm_recentFiles.h it reads:

enum WhatToRemember {
    AllApplications = 0,
    SpecificApplications = 1,
    NoApplications = 2,
};

As such, we need to ensure that we write the correct value in the config file which in this case is not the index of the QRadioButton. Reading a bit the code in KConfigDialogManager, I do the following:

  1. Set the property kcfg_property=kcfg_value on the QGroupBox. This should force the KConfigDialogManager to use that to retrieve that value that needs to be stored (the value of the setting)
  2. Introduce RecentFilesKcm::whatToRememberWidgetChanged which figures out the correct value of "what-to-remember" and sets it under the property kcfg_value. This will also emit the changed singal if needed (activates the Save/Reset buttons)
  3. Link the above slot to the QAbstractButton::clicked signals of the radio buttons

Essentially what the above does is that every time the user changes the value of the radio buttons, the whatToRemember is recalculated and set as the setting value to be stored.

A much simpler solution would be to reorder the radio buttons in the RecentFiles.ui but this was not choosen because (a) it doesn't look nice on the UI and (b) feels like a hack that will break silently in the future.

Tests

  • Tested locally by changing the value and grepping the config file
  • Tested reset and restore defaults
  • Built on master. For Plasma/5.27 see Plasma5.27/fix_kamd_stats_config

Let me know how this looks and how I would build it on master if needed. I see some pipeline jobs failing also (not sure they are related)

BUG: 397487

Edited by Andreas Bontozoglou

Merge request reports

Loading