Save and load page margins
ClosedPublic

Authored by hoffmannrobert on Jul 24 2019, 1:31 PM.

Details

Summary

Adapt and reapply former fix from
https://cgit.kde.org/kate.git/commit/?id=1aa12bace62fffbcad357623842a0fc01607b3c0
which was removed when migrating to Qt5.

Test Plan

Modify page margins in Printer Settings. Click OK and Print.
Without the patch, the changes disappear, with the patch applied the changed
margins are remembered in ~/.config/katerc and survive the restart of kate.

Diff Detail

Repository
R39 KTextEditor
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
hoffmannrobert created this revision.Jul 24 2019, 1:31 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJul 24 2019, 1:31 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
hoffmannrobert requested review of this revision.Jul 24 2019, 1:31 PM
cullmann requested changes to this revision.Jul 24 2019, 2:30 PM
cullmann added a subscriber: cullmann.

I think this is a good idea.

Instead of

KSharedConfig::openConfig()

one should use

KTextEditor::EditorPrivate::config()

otherwise this is fine for me.

This revision now requires changes to proceed.Jul 24 2019, 2:30 PM
  • Use KTextEditor::EditorPrivate::config()
cullmann accepted this revision.Jul 24 2019, 2:59 PM

Thanks!

This revision is now accepted and ready to land.Jul 24 2019, 2:59 PM
This revision was automatically updated to reflect the committed changes.

Since the former patch was originally from me: I agree to accept it, but it has it's drawbacks: if you have multiple printers, having different margins is not possible, since this is not saved per printer.

Btw, I recently wrote a mail to John Layt with the following content. The linked bug may be closed with this change:

Hi John,

quick question to the QPrinter: We still have issues in Kate (and other KDE apps I assume), that the margins of the QPrintDialog are not displayed / remembered correctly.

I once committed a workaround in the KDE 4 times [1], but removed this workaround again for KF5 / Qt5 thinking that this was fixed. But it seems it isn't:

Do you have any quick pointers to this? It seems the QPrinter/QPrintDialog still do not correctly read info from CUPS, neither does it correctly remember print settings, is that correct?

Do you happen to have a good solution to this?
On stackoverflow [2] I can find that others also have this issue - and a solution is to load/save each property of QPrinter. But I am not sure this works well if you have multiple printers.

Any pointers welcome [3].

Best regards

[1] https://cgit.kde.org/kate.git/commit/?id=1aa12bace62fffbcad357623842a0fc01607b3c0
[2] https://stackoverflow.com/a/14979437/2224190
[3] https://xkcd.com/138/

Should we add the printer name to the settings keys?

I think @aacid recently (well, some time ago) worked on the Qt printing code and he may at least have an idea of the status of this.

aacid added a comment.Jul 27 2019, 2:31 PM

It seems the QPrinter/QPrintDialog still do not correctly read info from CUPS

E_NEEDS_MORE_INFO

neither does it correctly remember print settings

This is by design AFAIK, but maybe a patch would be accepted if people would submit one. I'm still not convinced that it makes sense to be honest, the fact that 3 months ago i printed and A5 page in b&w has nothing to do with todays printing session.

I think adding the printer name makes sense. We could go the full road, see: https://stackoverflow.com/a/14979437/2224190