Bug 176999 - Print dialog does not remember properties
Summary: Print dialog does not remember properties
Status: RESOLVED UPSTREAM
Alias: None
Product: kdelibs
Classification: Unclassified
Component: print-dialog (show other bugs)
Version: unspecified
Platform: Ubuntu Packages Linux
: NOR normal with 60 votes (vote)
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
: 187482 201652 217021 223692 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-12-05 17:53 UTC by doc.evans
Modified: 2014-01-23 18:38 UTC (History)
15 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
OSX User Settings (52.12 KB, image/png)
2008-12-09 22:17 UTC, John Layt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description doc.evans 2008-12-05 17:53:33 UTC
Version:            (using KDE 4.1.3)
OS:                Linux
Installed from:    Ubuntu Packages

Consistent behaviour here:

1. Open document in okular.
2. Select Print.
3. Select Print Properties.
4. The page size is always set to A4.
5. Set page size to US Letter.
6. Print.
7. Close document.
8. Go through steps 1 to 4 again... the page size will again be A4.
Comment 1 Albert Astals Cid 2008-12-08 17:46:00 UTC
Changing subject as it happens for any program using qprinter and friends
Comment 2 András Manţia 2008-12-08 21:36:19 UTC
I'm not sure it is a Qt bug, as I recently wrote a Qt only app where it behaves like this: as long as you keep the QPrinter object, it will store the settings. So if okular deletes it and creates a new one when a new document is opened, it needs to store itself the printer settings somewhere.
Comment 3 Albert Astals Cid 2008-12-08 21:53:08 UTC
Are you sure this is the intended usage? assistant and designed have the problem described here too.
Comment 4 András Manţia 2008-12-08 22:01:38 UTC
This is my experience, but the documentation doesn't clarify how it should behave. Only the source (or Qt support) could clarify it. ;)
But somewhat it makes sense, the settings are in the QPrinter object, the dialog just configures it.
BTW, I'm talking about the Properties dialog that can be invoked from the Print dialog, and just tested with assistant, it remembers the setting until it is started.
Comment 5 Albert Astals Cid 2008-12-08 22:20:57 UTC
Not here:

 * Open assistant
 * Bring up print dialog
 * Press Properties
 * Change page size to Letter (was A4)
 * Press close
 * Press print
 * Bring up print dialog
 * Press Properties
 * Page size is A4 not Letter
Comment 6 András Manţia 2008-12-09 09:36:30 UTC
Tried again with qt-copy and 4.4.4 from the opensuse packages and in both cases it works as expected. Can't test okular as I don't have a real printer and I cannot select to print into a file. 
Comment 7 John Layt 2008-12-09 22:15:54 UTC
There's two issues at play here.  The first is there does appear to be a bug affecting persistence of Page Size in the Properties/Paper tab but not in the Properties/Advanced tab.  The second is that settings don't persist between runs.

As mentioned, if you keep the same QPrinter instance around, then the settings persist between print jobs.  However, quitting the app will lose those settings.  What is needed is Qt to add two methods to QPrinter to serialise and reload the full settings including selected printer.  Apps could then use this to save the settings either at application or document level.  I would like to see direct support for users able to save and load settings in the QPrintDialog like OSX does (see attached), but cross-platform support issues would need to be thought through.

As for the apparent bug, if I go into Properties/Paper/Page Size and change it from A4 to Letter, print, and then come back in, the Page Size is reset to A4.  But if I go into Properties/Advanced/Media Size and change it there (i.e. the PPD setting for page size) then this does persist, and next time the Properties/Paper/Page Size gets set to that value as well.  Also, changing either value does not reflect in the other at the time, which could be seen as a bug as well.  Perhaps there's a matching issue there with the PPD option name?

So that's 1 bug and 1 feature request to go upstream.
Comment 8 John Layt 2008-12-09 22:17:25 UTC
Created attachment 29193 [details]
OSX User Settings
Comment 9 Albert Astals Cid 2008-12-09 23:36:57 UTC
John can you take these two issues to Qt people that you've been working/battling with printing?
Comment 10 ietc 2008-12-30 02:57:46 UTC
May I suggest that this bug may be the same as that described in Bug #177360 ?
Comment 11 John Layt 2008-12-30 11:18:37 UTC
Nope, as explained, there are two other issues here:

1) where the Properties/Page paper size setting and the Properties/Advanced paper size are not kept in sync by Qt, 

2) where Qt does not provide a means of persisting print settings between application runs.

Both these need feature requests to Qt.
Comment 12 Roderick Johnstone 2009-02-04 15:58:53 UTC
I'm seeing the same behaviour with the print Duplex option in eg kate or okular, ie in Print Properties/Advanced it detects the default printer setting of 2-sided printing = Long-Edge Binding correctly, but in Options/Options Duplex printing shows as None, although it does print as duplex.

Is this close enough to the original bug to stay here or would you like me open a new bug for this issue.
Comment 13 James Richard Tyrer 2009-02-13 00:41:13 UTC
This is not limited to Okular and I don't think that it has been determined that this is a Qt problem.
Comment 14 Pino Toscano 2009-02-13 00:54:49 UTC
See comment #5 and #7. Qt problem indeed (missing ability of QPrinter to store/save settings).
Comment 15 James Richard Tyrer 2009-02-13 01:08:58 UTC
Re: Comment #14

It is not possible for Qt to store these settings.  The storage must occur in KDELibs.  To be specific, Qt contains the classes QPrint and QPrintDialog, but there is no way that a class can store information.  Only an instance of a class can store information.  Since the instances of the classes are deconstructed after printing and a new instance is constructed next time printing occurs, there can be no storage at the Qt level.
Comment 16 James Richard Tyrer 2009-02-13 01:13:50 UTC
Slight change in title for clarity.
Comment 17 Pino Toscano 2009-02-13 01:19:10 UTC
(In reply to comment #15)
> It is not possible for Qt to store these settings. [...]
> To be specific, Qt contains the classes QPrint and QPrintDialog, but
> there is no way that a class can store information.

This is _exactly_ what is being discussed here: those classes have no such
functionalities, so they should be requested for addition in Qt.

> The storage must occur in KDELibs.

Given the amount of internal settings (both general and platform-related) in
the Qt printing system, it is simply impossible to do a complete save/restore
of the whole settings provided by that. That's why it should be done in Qt.
Comment 18 James Richard Tyrer 2009-02-13 01:38:31 UTC
Qt provides these methods:

void setCollateCopies ( bool collate ) 
void setColorMode ( ColorMode newColorMode ) 
void setCreator ( const QString & creator ) 
void setDocName ( const QString & name ) 
void setDoubleSidedPrinting ( bool doubleSided ) 
void setDuplex ( DuplexMode duplex ) 
void setFontEmbeddingEnabled ( bool enable ) 
void setFromTo ( int from, int to ) 
void setFullPage ( bool fp ) 
void setNumCopies ( int numCopies ) 
void setOrientation ( Orientation orientation ) 
void setOutputFileName ( const QString & fileName ) 
void setOutputFormat ( OutputFormat format ) 
void setPageMargins ( qreal left, qreal top, qreal right, qreal bottom, Unit unit ) 
void setPageOrder ( PageOrder pageOrder ) 
void setPaperSize ( PaperSize newPaperSize ) 
void setPaperSize ( const QSizeF & paperSize, Unit unit ) 
void setPaperSource ( PaperSource source ) 
void setPrintProgram ( const QString & printProg ) 
void setPrintRange ( PrintRange range ) 
void setPrinterName ( const QString & name ) 
void setPrinterSelectionOption ( const QString & option ) 
void setResolution ( int dpi ) 
void setWinPageSize ( int pageSize )

For, KDELibs to have a method that calls these using data stored in a KDE configuration files is far from impossible.  In fact, it is the correct way to do it as stated in the Qt documentation.  Yes, this method could be in Qt rather than KDELibs, however, KDELibs would still have to provide the data since, as I stated, the Qt library cannot store the information.  The information must be in a configuration file and that would best be done in KDELibs.
Comment 19 Pino Toscano 2009-02-13 01:49:23 UTC
It seems you are quite new to the Qt printing system, and that explains why you are trying to find solutions that are actually impossible to be done.
I'll just give you one example from the list you rolled up:

> void setNumCopies ( int numCopies ) 

The correct getter for this would be numCopies(), do we agree?
Ok, try to query numCopies() on a X11 system with CUPS: you will always get 1.
This is because Qt is smart enough to just tell to applications to print one copy, while making use of CUPS' copies feature.
As you can imagine, in such configuration is basically impossible for anything out of Qt getting the exact printing information.

> since, as I stated, the Qt library cannot store the information.

Sure it can: for example, look at your ~/.config/Trolltech.conf and ~/.config/Trolltech/*.
Comment 20 James Richard Tyrer 2009-02-13 02:42:50 UTC
"The correct getter for this would be numCopies(), do we agree?"

Most certainly not.  Yes, there is an issue with number of copies.  However, this is not where that issue will have to be addressed.  What you have brought up is the question of what is going to happen to the information the user provided when they set the number of copies in QPrintDialog's widget.  This is an issue, but it is not the same issues as the fact that when this widget opens that the information in it should be the user's defaults and the the user's defaults are best provided by KDELibs.

Yes, there are Qt configuration files.  I don't think that it is best to store user supplied information that way, but I already said that it could be done.  What I said was that the library (the software, specifically the QPrint class) can't remember this information because it does not persist.  Either way, when instances of the QPrint and QPrintDialog is constructed, the information must be read into it, the class cannot store this data.

Now, we could have an abstract discussion of whether it would be best for Qt or KDELibs to have the method to store and retrieve the user's print defaults.  However, the question before us is whether we ask Trolltech to implement features and continue to ship a defective product until they do (if they ever do) or to implement it in KDELibs (which should have been done before 4.0.0 shipped).

Also note that we are talking about the users defaults which would be selected somewhere other than the Print Dialog.  We are not talking about the user being able to save the settings that they select in the Print Dialog.  That is a feature that Qt does not support and we should consider that a Qt bug.
Comment 21 Pino Toscano 2009-02-13 11:56:04 UTC
> What you have brought
> up is the question of what is going to happen to the information the user
> provided when they set the number of copies in QPrintDialog's widget.  This is
> an issue, but it is not the same issues as the fact that when this widget opens

No, it is the same issue, as all the printing information are provided by QPrinter/QPrintEngine.
The options provided by QAbstractPrintDialog are just for the configuration widgets, but actually provided via QPrinter.

> What I said was that the library (the software, specifically the QPrint class)
> can't remember this information because it does not persist.  Either way, when
> instances of the QPrint and QPrintDialog is constructed, the information must
> be read into it, the class cannot store this data.

Exactly, _exactly_. QPrinter is missing functionalities here, ie at least the possibility to save/restore its settings, even if the actual saving job is done externally of it.
Until QPrinter cannot do that, saving its information externally (querying it via the getters) will always give partial and incorrect information.

> However, the question before us is whether we ask Trolltech to implement
> features and continue to ship a defective product until they do (if they ever
> do) or to implement it in KDELibs (which should have been done before 4.0.0
> shipped).

Since KDE decided to rely on the Qt printing facilities, the only acceptable solution is to push QtSoftware to implement them, telling they are vital for KDE. There are not others.
Comment 22 James Richard Tyrer 2009-02-13 12:16:41 UTC
Re:Comment #21

"Since KDE decided to rely on the Qt printing facilities"

Perhaps this was a bad decision and it is really this decision that is the bug!

Comment 23 Andreas Pakulat 2009-02-13 14:05:12 UTC
(In reply to comment #22)
> Re:Comment #21
> 
> "Since KDE decided to rely on the Qt printing facilities"
> 
> Perhaps this was a bad decision and it is really this decision that is the bug!

It actually wasn't a "decision", it was simply the fact that there was nobody willing to port the kde3 printing code to KDE4 and make it work across all platforms. Implementing printing support is apparently a rather boring, tedious and time-consuming thing to work on.
Comment 24 András Manţia 2009-02-13 14:36:28 UTC
I saw a task was created for this: 
http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=244538

But 100% this won't happen in 4.5.0, I doubt they will introduce new functionality in the 4.5.x lines, so IMO the earliest we can see the fix is 4.6 sometime in the future.

So if you ask me, I'd say having a KPrinter or whatever class in KDE that saves/restores what is possible makes sense. In the future the implementation for those can just call QPrinter's save/restore methods. Yes, it introduces some API that will add no value in the future, but at least would give users a better KDE experience.
Comment 25 James Richard Tyrer 2009-03-07 23:37:08 UTC
Re:Comment #24

I would suggest that the task be clarified since Qt already has operators to save and restore "settings".  For example:

void QPrinter::setPaperSize ( const QSizeF & paperSize, Unit unit )
PaperSize QPrinter::paperSize () const

What is needed are KDE methods to read a file and set them and then to obtain them and write to a file.

That isn't all of it however since the Qt Print Dialog does not display all of the printing paramaters (such as resolution and mode [photo/text]).  So, we really need a KPrintDialog class that adds the additional functionality.  This would make it simple to read the file when the instance of the class was created and write it in the destructor.
Comment 26 Pino Toscano 2009-03-18 10:52:23 UTC
*** Bug 187482 has been marked as a duplicate of this bug. ***
Comment 27 John Layt 2009-07-28 19:43:37 UTC
*** Bug 201652 has been marked as a duplicate of this bug. ***
Comment 28 Christoph Feck 2009-12-02 14:16:01 UTC
*** Bug 217021 has been marked as a duplicate of this bug. ***
Comment 29 Albert Astals Cid 2009-12-02 18:31:34 UTC
I've created the two Qt bugs/wishes John mentioned

QPrintDialog for unix has multiple settings for paper size
http://bugreports.qt.nokia.com/browse/QTBUG-6468

QPrinter should provide a way to store/restore the settings
http://bugreports.qt.nokia.com/browse/QTBUG-6469

Please feel free to watch/vote at yuor discretion
Comment 30 Toralf Förster 2010-01-21 22:24:51 UTC
*** Bug 223692 has been marked as a duplicate of this bug. ***
Comment 31 emilio.recio@jefferson.edu 2014-01-23 18:38:13 UTC
I think this is related: I have three printers. GTK/Gnome based apps maintain the OS default. KDE apps default to the first printer alphabetically in my printer list, and there's no way to set a default printer in KDE. This is annoying because I end up sending my print jobs to another office.