Well it's Easter, and rather than being somewhere warm or interesting (or both), I'm stuck here in cold and wet London. This is partly due to my own lack of organisation, but also due to some dodgy fraudster types who managed to clone my debit card and withdraw large sums of my cash from an ATM in Tunisia (I haven't even been there!). Ironic really, given the number of banking security projects I've worked on :-) Well the cash has been refunded, I've been waiting two weeks for the replacement card to arrive, and without easy access to cash I'm reluctant to board a plane or train to anywhere, let alone even being able to book anything online. The one consolation is that I've actually been able to watch it snow in London, a rare occurrence.
So what's a geek to do on a miserable long weekend when he's trapped at home? No surprises really :-) I've been busy lately with The Real World with concerts and gigs and parties and work and starting on one of my irregular get-fit-quick kicks and so haven't had much time to spare for the promised work on KDE printing. So this weekend I've mostly devoted myself to sorting it out. It helps too that my landlady is away for the weekend and so hasn't been gently chiding me that a "young" man such as myself really should be outside enjoying myself more instead of being chained to this laptop :-)
I've been slowly reviewing the Qt4.4 printing system over the last few weeks to see what new stuff has made it, what hasn't, and what we still need / can provide in KDE4.1. Below I've detailed a list of what was missing in Qt4.3, where it's at in Qt4.4, and made some decisions on what we can do in KDE4.1, what we need to request for Qt4.5, and what I don't have a clue on. My initial aim is to work on the application side of things (i.e. the print dialog), before moving on to the printer management side.
So here's the first results of my efforts extending QPrintDialog:
Qt 4.4 - Print Dialog - Cups Pages options: KDE specific CUPS Page Options added to QPrintDialog
Yes, that's full support for n-up printing, page borders, banner pages, and page mirroring using CUPS on *nix. The tab is an entirely self-contained private widget added to the QPrintDialog by the KdePrint::createPrintDIalog() method, and not part of the public API. There's quite a bit of polishing to do (pretty icons, layout, etc), but it all works. Suggestions welcome of course :-)
There's two problems here, the first being that Qt doesn't initialise the list of CUPS Options until after the QPrintDialog signals Accepted(), so I can't make the tab dynamically update the settings itself. Instead, the app programmer needs to make a call to KdePrint::setupPrinter() after the QPrintDialog exec() returns, which while not the most elegant of solutions is not too onerous seeing as they already have to call KdePrint::createPrintDialog() to start with.
The second and major problem that is I can't tell at runtime when Qt is using CUPS for printing and when it has had to fall back to LPR. Obviously, we don't want to be showing these CUPS Options if they won't work, but the new Qt QPrinterInfo class unfortunately doesn't tell us if a printer uses CUPS or LPR. We aso need to know the CUPS version so we can add/remove version-dependent features. I also need to know this in FilePrinter. It's the one thing I can see that we _must_ have in Qt4.4, so I'll try requesting Trolltech add it before the RC comes out (not much time left, so fingers crossed).
Next step is to add another tab for the Job Scheduling and user added CUPS Options, then I'll move onto FilePrinter, and look at KStandardActions for Print to E-mail and Print to Fax, before returning to the Printer Management side of things. I see riddell has proposed an alternative python based system, I'll try do a feature compare on them to see if it's a direction worth going.
For those interested, the magic code to add extra CUPS options to QPrinter is as follows, and can be used by any app to set anything they like after calling exec() on the QPrintDialog:
void setCupsOption( QPrinter *printer, const QString option, const QString value )
{
QStringList cupsOptions = printer->printEngine()->property(QPrintEngine::PrintEnginePropertyKey(0xfe00)).toStringList();
if ( cupsOptions.contains( option ) ) {
cupsOptions.replace( cupsOptions.indexOf( option ) + 1, value );
} else {
cupsOptions.append( option );
cupsOptions.append( value );
}
printer->printEngine()->setProperty(QPrintEngine::PrintEnginePropertyKey(0xfe00), QVariant(cupsOptions));
}
KDEPrint3 vs Qt4.3 vs Qt4.4
* = available in Qt4.4 x = not available in Qt4.4, not to be added in KDE4.1 + = not available in Qt4.4, support to be added in KDE4.1 ? for unknown or incomplete support
Usability and General improvements:
* Drag QPrintDialog into the 21st century :-) * Applications able to add custom tabs to dialog * Selection of Print to File through Printer combo instead of knowing to type .ps/.pdf ? Use KFileDialog when selecting destination for Print To File ? Printer / Print System Infomation x Printer PPD options dialog improved x Special / Virtual Printers in Printer selction combo (i.e. fax/e-mail) x Persistance of settings
Advanced page range selection:
x Non-continuous page ranges x Current Page x Page set All/Odd/Even Pages x QList pageList() method
Advanced page manipulation
* Duplex Long-edge / Short-edge * Custom margins + N-Up Printing + Banner Printing x Reverse Landscape / Reverse Portrait x Pamphlet printing x Poster printing
Advanced Options:
* API Read access to Cups options selected in dialog preferences */+ API/GUI write access to add extra Cups options + Job scheduling x Apply filters to output file x File printing
Notes:
N-up / Banner / Job scheduling : I'm adding these to KDE4.1 as *nix / CUPS only options.
Use KFileDialog : ThomasZ mentioned this is now possible, need to check with him how.
Advanced Print Range Selection and Reverse Landscape/Portrait: I could add these in KDE4.1 for CUPS only, but the UI and API would just be too awkward, and it's far better to work at having them natively supported cross-platform in Qt 4.5.
Persistance Of Settings : Apps can still manually persist most settings, but KDEPrint made it far less work. Open question, perhaps a couple of KdePrint methods to save/restore all settings.
Printer / Print System Info : Cool new API for this, but could expose more info, primarily we need to know if using CUPS or LPR, and what version of CUPS.
PPD Options Dialog : Works OK, but is not obvious to newbie how you can actually change the settings, and doesn't size properly. One for Qt4.5.
Apply Filters (which gave us pamplet/poster printing): Personally I think pamphlet and poster printing should be supported inside CUPS, but there are other possible uses for filters so the whole issue is an open one. I do see the kprinter utility being resurrected in kdebase or extragear as say KPrintShop using the old KDEPrint engines and dialog as a *nix only solution. Sure, it becomes a 2 step process of Print to PDF then run KPrintShop, but it's better than nothing.
File Printing: I'll be working on improving the interim *nix-only code I wrote for Okular, but it's another open question. I'll be adding support for all options chosen in the dialog, and proper CUPS support, and looking at moving to kdelibs. I really don't see a cross-platform solution any time soon (yes we could use gv, but really...). [Note to self, follow up Alex's suggestion to see how Scribus copes with cross-platform PDF printing]
Add Special / Virtual Printers : I personally see Export to Fax and Export to E-Mail better implemented as KStandardActions selected from the File menu due to being more user discoverable, but that does require every app to decide if they want to add them or not, whereas having it in the print dialog is universal. The actions could launch a reduced functionality QPrintDialog and use the setOutputProgam() method to set the destination program, but I don't think Qt provides the flexability to do this properly (can't block/hide all invalid options, only works for PS output, etc). Instead, in the background a PDF or PS file would be printed and then the file sent to the required program (i.e. as KPrintPreview does). The drawback here is the user will not be able to choose valid options like page ranges, but a simple private dialog could provide this.
P.S. Why does TinyMCE keep stripping the whitespace from my pre marked code and throwing away the code tag??? Apologies if the layout goes nuts again.
Comments
Re: Easter progress on printng
If I may make a suggestion, I think icons should be added to quickly identify what the buttons do. For example, for the portrait option an icon of an upright paper shold be included, for the option of landscape, an icon of a horizontal paper should be included. Even if the exampled options are the easy ones, there are oprions like for duplexing: Long Side, Short side; or for Output Settings: Collate, Reverse; that I have no idea what they do (I don't print much). So icons for them would greately help. Again, just a suggestion. Cheers,
LJ
Re: Easter progress on printng
For the page range stuff, have you looked into adding a simple dropdown for even/odd pages? That shouldn't suck too much UI-wise and it'll make life a lot easier for people who want or need to print duplex on a non-duplex-capable printer.
Re: Easter progress on printng
Oops, I forgot to sign the parent comment.
-- Kevin Kofler
Re: Easter progress on printng
A small preview box is useful too. For example if I set two pages per sheet and set landscape, does that mean the sub-page thing is landscape, or tha the whole sheet is landscape?
Re: Easter progress on printng
I'm planning to add a "preview" icon to show the layout, possibly with arrows or numbers to show the direction (top to bottom, etc), but hadn't thought about the portrait/landscape thing. So 6 page options with 8 possible directions and 2 possible rotations, gives, um, 96 icons required? Eeep! Well, not quite, 1 page per sheet needs only 2 icons, 2 pages needs 4 icons, so maybe 70? Hmmm, will need to think that through more :-)
Re: Easter progress on printng
Suggestion:
Add option for 8 pages per sheet
Re: Easter progress on printng
Unfortunately, CUPS does not support 8 pages per sheet, not sure why as it seems an obvious one.
Re: Easter progress on printng
Persistance of settings: If you keep QPrinter around, the settings will
stay IIRC. The dialog doesn't keep the settings, the printer does, so
that you can remember specific settings for different types of
documents in the same app. -- Andreas
Re: Easter progress on printng
Yes, the settings will persist if you keep the QPrinter, but that only works for the current instance of the app. IIRC, KDEPrint stored the settings between runs of the program. Easy enough to do, but obviously low priority.