[Development] Adding CPD support to Qt print dialog

Volker Hilsheimer volker.hilsheimer at qt.io
Mon Sep 26 16:54:43 CEST 2022



> On 25 Sep 2022, at 20:58, Albert Astals Cid <aacid at kde.org> wrote:
> 
> El dissabte, 24 de setembre de 2022, a les 12:45:00 (CEST), Tor Arne Vestbø va 
> escriure:
>>> On 23 Sep 2022, at 19:21+02:00, Gaurav Guleria <gaurav.gen3 at gmail.com>
>>> wrote:
> 
>>> As far as I know, the CUPS is currently implemented in Qt at two different
>>> places: src/plugins/printsupport/cups/ and directly within the dialog
>>> src/printsupport/dialogs/qprintdialog_unix.cpp. By implementing CPDB
>>> support as a plugin, does it mean that we create a similar
>>> src/plugins/printsupport/cpdb which uses CPDB to enumerate printers
>>> instead of CUPS? If so, what about the unix print dialog, don't we need
>>> to add the CPDB code there too (#if QT_CONFIG(cpdb) ... #endif
>>> constructs, just like CUPS)?
>> 
>> The QCupsJobWidget is documented as "a widget to add to QPrintDialog to
>> enable extra CUPS options such as Job Scheduling, Job Priority or Job
>> Billing”, so I don’t think having any CPDB specific code in the UNIX print
>> dialog is required as a first step to bring a CPDB print backend up.
> 
>> Once we get to that point we can look at possibly adding new API for the
>> print engines to deal with the needs of QCupsJobWidget and the like, so
>> that we don’t need CUPS/CPDB specifics in the dialog code.
> 
> The "problem" is not QCupsJobWidget, but the print dialog itself.
> 
> qprintdialog_unix.cpp and qpagesetupdialog_unix.cpp are full of
>  #if QT_CONFIG(cups)
> 
> IMHO for now the same solution of adding ifdefs should be accepted for CPDB.
> 
> Ideally in the future an abstraction so that those ifdefs are not needed 
> should be introduced, but I have the feeling that asking that abstraction to 
> be added now is a bit of "asking too much".
> 
> Cheers,
>  Albert

I think it will be easier to understand what abstraction we need once we have a patch to look at that implements CPDB support. That we don’t have a QPA-level abstraction for print dialogs in Qt shouldn’t block adding CPDB support.

However, rather than throwing more #if’ery complexity into qprintdialog_unix.cpp it might be best to make a dedicated implementation of a CPDB-dialog. Or rather two implementations, as Shawn has pointed out: one for Qt Widgets and one for Qt Quick. And if those two are then based on a common abstraction that provides the logic and is informed by what we already have in QAbstractPrintDialog - but without the dependency to Qt Widgets - then that might perhaps become a basis for what we want in QPA.

Cheers,
Volker



More information about the Development mailing list