From kde-core-devel Wed Feb 28 10:39:47 2001 From: Michael Goffioul Date: Wed, 28 Feb 2001 10:39:47 +0000 To: kde-core-devel Subject: New KDE printing system X-MARC-Message: https://marc.info/?l=kde-core-devel&m=98336023209786 Hi all, 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 small apps) 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) API ----- 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&)". 2) Flexibility --------- 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. 3) Misc ------ The KPrinter class provides some enhancements and configuration possibility. For example the possiblity to tell the printer object if the application can handle page selection itself or not (some printing system provide page selection mechanism), the dialo appearance is changed accordingly. 4) Printing magament ---------------- 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, so 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. Regards. Michael. -- ------------------------------------------------------------------ Michael Goffioul IMEC-DESICS-MIRA e-mail: goffioul@imec.be (Mixed-Signal and RF Applications) Tel: +32/16/28-8510 Kapeldreef, 75 Fax: +32/16/28-1515 3001 HEVERLEE, BELGIUM ------------------------------------------------------------------