KDE developer Michael Goffioul today announced that he is actively addressing an area in KDE that warrants improvement: printing. He has committed source code to KDE CVS for a new KDE printing system to replace the limited Qt printing framework.
Support for LPR, CUPS and PDQ printing systems is already there.
Special emphasis is put on CUPS (Common Unix Printing System). The API is identical to the Qt API to enable developers to make use of it easily, but is significantly more flexible and configurable. For example, developers can easily add additional configuration pages to the print dialog to configure application-specific printing options, and can add filters to the printing structure to process the output. It also aims to provide a friendly user interface, including a print dialog, a KControl configuration module, a job viewer applet for the panel and a preview feature. People interested in supporting other systems should contact Michael and get involved now. His announcement is included below.
Wed, 28 Feb 2001 11:39:47 +0100
KDE Development ,
KDE Core Development
New KDE printing system
As some of you have already noticed, a new component appeared very recently
in kdelibs, called "kdeprint". This is actually a new printing library which
should replace the Qt printing mechanism and the current kprint library.
The goals of this library are:
- prove an API interface identical to Qt to reduce changes for developers
- support several printing systems through a common (as much as possible) the same user interface. It currently supports LPR, CUPS and PDQ.
- prove a user-friendly interface for users
- flexibility and configurability for developers: for example the possibility to plug additional pages in the print dialog for application specific options,
so developers don't need to redesign a print dialog, just use the standard one and add the pages you need.
- useful tools: KControl module for configuration, job viewer which docks itself in kicker, small print application allowing dropping file on it (network transparent), preview mechanism, ...
The library is currently on the CVS, other parts (like KControl module and smallapps) should appear somewhere very soon. I'm not doing it myself because I
can't access CVS, being behind a firewall (with only HTTP proxy server).
The rest of the message is a short explaination on how to use this library. The
header files of interest are "kprinter.h", "kprintdialogpage.h" and "optionset.h".
1.1 KPrinterFactory class
This class is used to create KPrinter object (see below). Developers shouldn't
construct directly KPrinter object, but use "KPrinterFactory::self()->printer()".
The factory takes care of the user settings and construct an object for the
appropriate underlying printing system. DO NOT delete the KPrinter object, as
it will be reused for other calls.
1.2 KPrinter class
There's a class called "KPrinter". This class provides exactly the same interface
as QPrinter class, with some enhancements. So changing QPrinter to KPrinter
should be OK in most cases. For configuring, use "KPrinter::setup(QWidget*)",
don't use old QPrintDialog calls. If you want to print a PS file that you have
created in your application, you can use "KPrinter::printFile(const QString&)".
The developer has the possibility to plug additional pages in the main print dialog
for application specific options. To do that you have to subclass the KPrintDialogPage
class and implement the virtual members. The communication between the print
dialog and these additional pages is made through an "OptionSet' object which
inherits QMap. So your applications specific options should
have the form "key=value". Of course the value can then be interpreted as the
developer wants to (int, float, string, ...). For internal reasons, the key should have
the form "kde-", but this is not mandatory.
The virtual members to implement are:
- "void setOptions(const OptionSet&)": your page should then update its content according to the option set given. You can retrieve easily your options as this is actually a map.
- "void getOptions(OptionSet&, bool)": your page should then fill the option set with the current settings. The bool flag tells the developer wether default values should be included or not (true == include default).
- "QString pageTitle()": pages are shown in a tab widget in the main dialog. This member return the string to use for tab title.
- "bool isValid()": tells the main dialog if selected options are valid (sometimes you can have comflicting settings). However it is not used yet.
- To plug your page into the dialog, use "KPrinter::addDialogPage(KPrintDialogPage*)". At this moment, you have to provide a page each time you call "setup()" member of KPrinter, as the dialog is deleted when it is closed. However this may change in the future.
The KPrinter class provides some enhancements and configuration possibility. Forexample the possiblity to tell the printer object if the application can handle
selection itself or not (some printing system provide page selection mechanism),the dialo appearance is changed accordingly.
The current library will be rewritten soon. I extended the concepts I used to develop
a generic printing managemnet system for KDE: this means a printing management
tool supporting several printing sytsems through a common interface. This interface
will be heavily based on KUPS. As some important components will be written for
this tool, they can be re-used for the kdeprint library. This means the kdeprint library
will be integrated in this tool. However the API shoudn't change significantly,
developers shouldn't worry. But this management tool will be more generic: common
driver configuration tool, plugin mechanism (no library dependence anymore), ...While developing this tool, I only develop a CUPS plugin. However I'm looking for
people interested in developing plugin for other print systems (LPR+printtool,
LPR+foomatic, PDQ, LPRng, ...), and more generally people interested in making
things going faster.
I hope you'll appreciate and enjoy my KDE contribution. Feel free to send me any comment or suggestion.
Michael Goffioul IMEC-DESICS-MIRA
e-mail: email@example.com (Mixed-Signal and RF Applications)
Tel: +32/16/28-8510 Kapeldreef, 75
Fax: +32/16/28-1515 3001 HEVERLEE, BELGIUM