Future of KPrinter

Thomas Zander Thomas.Zander at trolltech.com
Tue Sep 11 12:18:10 BST 2007


On Saturday 08 September 2007 21:29:08 Alex Merry wrote:
> Thomas Zander suggested we kill off KPrinter in favour of QPrinter
> (http://lists.kde.org/?l=kde-core-devel&m=118918127627566&w=2).
>
> Here's a list of the features provided by the KDE printing system that
> the Qt printing system doesn't provide:
>
> * Customisable print dialogs 

In Qt4.4 we are looking to add a method on QAbstractPrintDialog to add a 
widget to it.  This would then appear as a tab in the expected place on 
the different platforms.
Since KDE4.0 will probably not depend on Qt4.4 we (TT) can make sure an 
exported symbol will be available in 4.3.2

> * Straightforward printer options (try clicking "properties" for a
> printer in the print dialog of the Qt assistant program, and doing the
> same in kolourpaint), ie: integration with KDE print management system

Yeah, I kind of like the Gui in KDE and the richness of features. The 
thing is; there need not be any difference between Qt and KDE in this 
respect.
The Qt dialog has issues, for sure, and those need fixing. So my 
suggestion is that we do that in a way that both Qt and KDE like the 
newly created QPrintDialog. Saves a lot of duplication :)

> * Printing a list of pages (such as 1,4,6-8) or the current page -
> would required extending QPrinter and implementing our own
> KPrintDialog, or we could just tell people to get this info from
> KPrintDialog (it's only needed by the application, not by the printing
> system)

QPrinter already has this. As does the QPrintDialog.
See QPrinter::fromPage(), QPrinter::toPage()

For the people just tuning in; the following (pseudo) code sample is what 
the majority of the applications will actually do.

// this method will be called when the user presses the 'print' button.
void MyApp::print() {
  // create a printer that the print dialog will set all the options on.
  QPrinter *printer = new QPrinter();
  // create a dialog to show the printer option.
  QPrintDialog *dia = new QPrintDialog(printer, parentWidget);
  // optionally apps can have their own options widget.
  MyOptionsWidget *options = new MyOptionsWidget();
  dia->addOptionsPane(options);
  dia->exec();
  // at this point the QPrinter object is initialized with size / etc by
  // the dialog.
  printer->setFoo(options->bar());  // process my own options

  myQTextDocument->print(printer): // do the actual printing.
}

This gives you a feel what we can do.
So, all 'weird' options like page ranges and other stuff has to be handled 
by the actual printing code.  QTextDocument::print IIRC does already 
handle this.

> * Custom margins - would require extending QPrinter and implementing
> our own backends (which might use a Qt builtin backend)

I'm going to try to get a setPageRect(const QRect &contentSize) on 
QPrinter, not for 4.3 though.

> * Pre-print filtering - would require extending QPrinter and
> implementing our own backends (which might use a Qt builtin backend)

This is for things like the filter tab in the KDE3 print dialog, right?
I'm not so sure we should still have that, at least in the normal print 
dialog; all those options are only useful if we print to postscript. And 
we can't assume that anymore.
For example, on Windows the output format is defined by the 
printer-driver.  And even on Unix/Mac the output format can be PDF.
So this feature really should be re-thought.

> * "Special" printers (like Send Fax via KFax) independent of eg: CUPS -
> would require extending QPrinter and implementing our own backends
> (which might use a Qt builtin backend when not printing to the special
> printers)

I'm thinking this can actually be done using the 
  QPrinter::setPrintProgram (const QString &)
method already.

> * Print preview - more complicated.

We looked at this and we have a preview dialog that will be available on 
the labs soon, and will likely be added to 4.4.

Bottom line;
* for kde4.0 we can use QPrinter completely, we can use the (ugly) 
QPrintDialog as well since its fully functional, just not that pretty.
* We will add the missing features in Qt for 4.4 and later versions to 
make sure that the KDE printing experience is just as good as the KDe3 
one, and probably even better.
* We still need the kde control panel to configure printing,
-- 
Thomas Zander
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070911/40ba3ead/attachment.sig>


More information about the kde-core-devel mailing list