Bug 216746 - It should be possible to save the print configuration for kst
Summary: It should be possible to save the print configuration for kst
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 2.0.0
Platform: unspecified Linux
: NOR wishlist
Target Milestone: 2.0.0
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-30 00:29 UTC by Nicolas Brisset
Modified: 2010-11-12 10:42 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Brisset 2009-11-30 00:29:07 UTC
Version:           2.0.0_devel (using unspecified)
Compiler:          gcc 4.4.1 
OS:                Linux

In kst 1.x (using KDE, while kst2 is so far a Qt4-only app) it was possible to save print settings so that printing from kst to PDF would always be in landscape mode with small margins. That possibility is no longer given, so that batch printing large numbers of files from the command line is no longer usable.

As a matter of fact, it does not seem to work from KDE4 apps (e.g. kwrite: lots of settings, no save button). So the issue seems to be quite general; I hope there is a workaround (even a dirty hack, until all KDE3 features are back).
Comment 1 Nicolas Brisset 2010-01-15 00:22:46 UTC
I've been researching a bit why it is no longer possible to save printer settings between jobs or even sessions. Here are the most interesting things I've found:
1) it seems that Qt4 does not (yet, seems to be planned for 4.7) provide this possibility, as found in a message on a KDE list (http://markmail.org/message/abaeotvug7k6vgfs). Although the message is a bit old, I believe the problem and explanations are still current. Most interesting parts:
   - "One such missing feature is KDE no longer automatically saves the last used printer settings for each application, it is now up to each app to save and restore the settings"
   - "Also, if the app keeps the same QPrinter instance to use each time the dialog is called, then the settings will persist so long as the app is running". 
Those two tips may provide a usable workaround for the short term...

2) we have a printing guru in KDE land: the author of the above mentioned post, John Layt. John, if you're there and could give us a short status it would be very much appreciated

3) from the QPrinter documentation (Qt 4.6) there are setPaperSize(), setPageMargins() and setOrientation() methods so I guess we could combine that with QSettings to save the printer settings locally until there is a more global solution
Comment 2 Nicolas Brisset 2010-01-15 08:22:33 UTC
I realize you asked on the list for details on what I want, not how to achieve it. So here goes a quick outline:

- The problem:
today's displays are mostly used in "landscape" mode. Sometimes you prepare a plot (in the global sense, i.e. a few windows with a couple of plots each), tune font sizes, legends etc and then print. What happens? The layout is completely broken as it prints in portrait mode and relayouts everything for printing. Plus, paper sizes don't have the same aspect ratio as screens and print margins are added, and they seem to be very large on all my installations. Setting reasonable margins and switching to landscape mode more or less does the trick (minus some distortion effects due to the different aspect ratios), but *it has to be done manually for each print request*, be it within a session or from session to session. That is extremely annoying in interactive mode and a no-go for batch printing to PDF, which is one of our favorite use cases :-(

- The solution(s):
1) change the default printing orientation to landscape, I guess that would already solve part of the problem and probably costs only one line of code
2) clarify what to expect from Qt and in the meantime save minimal print settings as kst settings, so that for each installed printer including "Print to file" (PS/PDF) at least orientation and margins are saved (apparently the other options are CUPS options under Linux, and are better handled by installing many instances of the printer with different defaults, as suggested by John in the mailing list post referred to in a previous comment)
3) think about adding an option to preserve aspect ratios globally when printing (longer term)

If anybody has different use cases, please comment...
Comment 3 Netterfield 2010-02-01 21:16:50 UTC
Since the primary use case here is command line/script use, how about if we just add command line options to set the relevant print settings, rather than relying on the the user having first set it up in the UI.

eg:

kst coolness.kst --orientation Landscape --pagesize A4 --margins .5,.5 -print coolness.pdf
Comment 4 Netterfield 2010-02-01 21:21:42 UTC
SVN commit 1083715 by netterfield:

Finish up UI changes for revised font specifications
BUG: 221749

Change \_ to _ in data mode line display.

Demo of setting print mode from the command line (syntax will likely change)
CCBUG: 216746 




 M  +1 -2      devel-docs/Kst2Specs/Bugs  
 M  +8 -0      devel-docs/Kst2Specs/FixedBugs  
 M  +26 -0     devel-docs/Kst2Specs/Wishlist  
 M  +7 -1      src/libkst/namedobject.cpp  
 M  +2 -1      src/libkst/namedobject.h  
 M  +9 -7      src/libkstapp/applicationsettings.cpp  
 M  +7 -1      src/libkstapp/commandlineparser.cpp  
 M  +4 -2      src/libkstapp/commandlineparser.h  
 M  +0 -1      src/libkstapp/defaultlabelpropertiestab.cpp  
 M  +17 -1     src/libkstapp/defaultlabelpropertiestab.ui  
 M  +15 -16    src/libkstapp/generaltab.ui  
 M  +9 -3      src/libkstapp/mainwindow.cpp  
 M  +1 -1      src/libkstapp/mainwindow.h  
 M  +2 -2      src/libkstapp/plotrenderitem.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1083715
Comment 5 Nicolas Brisset 2010-02-02 09:49:21 UTC
(In reply to comment #3)
> Since the primary use case here is command line/script use, how about if we
> just add command line options to set the relevant print settings, rather than
> relying on the the user having first set it up in the UI.
> 
> eg:
> 
> kst coolness.kst --orientation Landscape --pagesize A4 --margins .5,.5 -print
> coolness.pdf
Command line options are fine, but I believe not enough: there are also times where you look at data interactively and want to print stuff out to show other people. Having to go through the settings each time is a major pain.
As I said in the original report, I'd suggest defaulting to landscape but I really believe being able to specify the orientation and margins in the settings is needed. What we may possibly simplify is having only global settings (for all types of printed output: PDF, printer, etc...) instead of per-printer as used to be possible with kst 1.x / KDE3.
Comment 6 Netterfield 2010-02-04 04:05:01 UTC
SVN commit 1084951 by netterfield:

BUG: 216746

Add command line options for orientation and paper size.
Make orientation, paper size, and margins sticky.

Also, unrelated, make 'p' be an accelerator for pause.



 M  +5 -1      devel-docs/Kst2Specs/Wishlist  
 M  +24 -1     src/libkstapp/commandlineparser.cpp  
 M  +2 -1      src/libkstapp/commandlineparser.h  
 M  +38 -8     src/libkstapp/mainwindow.cpp  
 M  +3 -1      src/libkstapp/mainwindow.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1084951
Comment 7 Nicolas Brisset 2010-02-04 09:36:03 UTC
OK, nice addition. Thanks a lot.
How about the possibility to set some properties in the preferences, to avoid having to set them manually each time we want to print?

I have tested it a bit in interactive mode and from what I could see:
- the orientation property is remembered from one print action to the next, though I don't know whether Qt defaults to doing that or if it's done on purpose. But that's nice.
- the default margins are extremely large (top/bottom: each 25.4 mm, right/left: each 31.75 mm, or for A4 landscape 24% and 21% of the paper estate!!) for any reason that's totally unclear to me. And worse: they are not remembered => I have to set all four values to something more reasonable each time, which is *very* painful and definitely has to be avoided.

Interestingly, in batch mode the margins are more reasonable. I suspect you have set a better default there.

So to sum up, I would still recommend one of the two following options:
1) add a "Printing" section in the settings where we can set the margins and orientation (and use that to initialize the print dialog) 
2) remember the last used values in the settings and restore that. It is even less obtrusive UI-wise and should fit most people's needs. That would also work for batch printing: you could print once interactively to set the settings and then fire it from the command line
Comment 8 Netterfield 2010-02-04 15:32:16 UTC
Short version:
	the last set margins are sticky for all future printing, until changed by the 
Print->options dialog.  Set them to 5mm, and they will stay that way.
	However: the last set margins are not reflected in the Print->options dialog 
defaults.  Instead some giant dimensions are used (1 and 1.5 inches)  These 
appear to be un-settable.  (bug/deficiency in Qt)  So everytime you want to 
change paper size or orientation, you also have to reset the margins.

------------------
Longer version

Actually, everything works as you want it to, *except* for an apparent 
bug/deficiency in in Qt: 

We do store the margins set in the print dialog->options dialog, and it is 
sticky for all future printing, including from the command line.

However, there seems to be no way to set the defaults in the options dialog, 
so this fact is not discoverable.  The page size and orientation settings are 
picked up from the QPrinter we pass to the QPrintDialog, and reflected as 
defaults in the options dialog, but the margins are not.  

If you don't 'ok' or 'apply' in the print->options dialog the last set margins 
are still used.  But if you enter the print->options dialog, say, to change 
the paper size, the 1 and 1.5" defaults get set into the dialog, and will be 
applied as the new margin size.  There appears to be no way to set these 
defaults, or change them in any way, or to remove them from the dialog.  So, 
if you want to change the paper size or the orientation with the Print-
>options dialog, you *also* have to re-enter the margins to what you actually 
want.

This really bugs me, but I don't see a way forward short of re-writing or 
patching the Qt print dialog (which I am not keen to do, since 4.7 is 
coming...).

If someone knows something I don't, I would love to hear it.

so,

Go to the print -> options dialog.  Set the margins to something good (say 
5mm).  Set your orientation and paper size to what you want.  apply.

From now on, until you re-enter and 'apply' the print->options dialog, what 
you just set will be used. 

cbn

On Thursday 04 February 2010 03:36:06 Nicolas Brisset wrote:
> https://bugs.kde.org/show_bug.cgi?id=216746
> 
> 
> 
> 
> 
> --- Comment #7 from Nicolas Brisset <nicolas brisset eurocopter com> 
>  2010-02-04 09:36:03 --- OK, nice addition. Thanks a lot.
> How about the possibility to set some properties in the preferences, to
>  avoid having to set them manually each time we want to print?
> 
> I have tested it a bit in interactive mode and from what I could see:
> - the orientation property is remembered from one print action to the next,
> though I don't know whether Qt defaults to doing that or if it's done on
> purpose. But that's nice.
> - the default margins are extremely large (top/bottom: each 25.4 mm,
> right/left: each 31.75 mm, or for A4 landscape 24% and 21% of the paper
> estate!!) for any reason that's totally unclear to me. And worse: they are
>  not remembered => I have to set all four values to something more
>  reasonable each time, which is *very* painful and definitely has to be
>  avoided.
> 
> Interestingly, in batch mode the margins are more reasonable. I suspect you
> have set a better default there.
> 
> So to sum up, I would still recommend one of the two following options:
> 1) add a "Printing" section in the settings where we can set the margins
>  and orientation (and use that to initialize the print dialog)
> 2) remember the last used values in the settings and restore that. It is
>  even less obtrusive UI-wise and should fit most people's needs. That would
>  also work for batch printing: you could print once interactively to set
>  the settings and then fire it from the command line
>
Comment 9 Peter Kümmel 2010-08-14 12:14:25 UTC
Change version from 2.0.0_devel to 2.0.0 to simplify version numbering.
Comment 10 Peter Kümmel 2010-11-12 10:42:12 UTC
These bugs are solved with 2.0.0