Skip to content

kcm/[core/qml]: Rework save logic to handle "default printer" properly

Mike Noe requested to merge work/noee/rework-save-printer into master

CUPS treats the default attribute independently from other printer attributes. Also, CUPS makes sure it's exclusive, only one can be default and there is no api for setting "Not default". You simply call setDefault on the printer you want to be default. Currently, the save logic does not differentiate setting default for specifically adding vs. changing the printer.

This change to saving solves:

  • If it is checked, Default printer is set regardless of any other attributes changing
  • When changing an existing printer that is the default, unchecking the Default checkbox is not allowed (this was allowed before and was a NOOP)
  • When changing an existing printer, if there are no attributes changed, do not call the CUPS modify printer api. Calling modify printer with no changes causes superfluous model updates

User Facing (kcm):

If a printer is default, disable the Default checkbox, only allow the default setting to be changed for a printer that is not default.

Testing:

  1. Add a new printer, set it as default, it should be saved as default and no other printer should be default.
  2. Change an existing printer that is not default to set default true. That printer will now be default and no other printer should be default.
  3. Try to change the default setting for an existing printer that is default. It should be disabled.
Edited by Mike Noe

Merge request reports