Skip to content

Commit a4ff501

Browse files
TinyTrebuchetabrarnasirjaffari
authored andcommitted
Add support for dynamically loading print plugins
Scraped out CUPS & CPDB specific code from print dialog frontend, and put it in their respective print plugin directories. This allows the print dialog to be able to dynamically select print backends at runtime instead of having to choose one at build time. Change-Id: I8ae53d19d91aa9689ec327fd8077558744e4768b
1 parent 42967e1 commit a4ff501

32 files changed

+1557
-985
lines changed

src/plugins/printsupport/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
if(QT_FEATURE_cpdb AND UNIX AND NOT APPLE)
77
add_subdirectory(cpdb)
8-
elseif(QT_FEATURE_cups AND UNIX AND NOT APPLE)
8+
endif()
9+
if (QT_FEATURE_cups AND UNIX AND NOT APPLE)
910
add_subdirectory(cups)
1011
endif()

src/plugins/printsupport/cpdb/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ qt_internal_add_plugin(QCpdbPrinterSupportPlugin
77
PLUGIN_TYPE printsupport
88
SOURCES
99
main.cpp
10+
qcpdb.cpp qcpdb_p.h
1011
qcpdbprintengine.cpp qcpdbprintengine_p.h
1112
qcpdbprintersupport.cpp qcpdbprintersupport_p.h
1213
qcpdbprintdevice.cpp qcpdbprintdevice.h
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"Keys": [ "cpdbprintersupport" ]
2+
"Keys": [ "cpdbprintersupport" ],
3+
"Priority": 80
34
}

src/printsupport/kernel/qcpdb_p.h renamed to src/plugins/printsupport/cpdb/qcpdb_p.h

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
2020
#include <QtPrintSupport/private/qprint_p.h>
21+
#include <QHash>
22+
#include <QLocale>
2123

2224
#include <cpdb/frontend.h>
2325

@@ -29,16 +31,45 @@ class QPrintDevice;
2931

3032
#define PDPK_CpdbPrinterObj QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 0x10)
3133

32-
class Q_PRINTSUPPORT_EXPORT QCPDBSupport
34+
class QCPDBSupport
3335
{
3436
public:
3537
constexpr static qreal pointsMultiplier = 2.83464566929; // 1mm to points
3638

3739
static const char *translateOption(cpdb_printer_obj_t *printerObj, const char *optionName);
3840
static const char *translateChoice(cpdb_printer_obj_t *printerObj, const char *optionName, const char *choiceName);
3941
static const char *translateGroup(cpdb_printer_obj_t *printerObj, const char *groupName);
42+
43+
const static inline QHash<QByteArray,QByteArray> numUpDist = {
44+
{"1", "1x1"},
45+
{"2", "2x1"},
46+
{"4", "2x2"},
47+
{"6", "2x3"},
48+
{"9", "3x3"},
49+
{"16", "4x4"},
50+
51+
{"1x1", "1"},
52+
{"2x1", "2"},
53+
{"2x2", "4"},
54+
{"2x3", "6"},
55+
{"3x3", "9"},
56+
{"4x4", "16"},
57+
};
58+
59+
const static inline QHash<QByteArray,QPrint::DuplexMode> duplexMap = {
60+
{CPDB_SIDES_ONE_SIDED, QPrint::DuplexNone},
61+
{CPDB_SIDES_TWO_SIDED_SHORT, QPrint::DuplexShortSide},
62+
{CPDB_SIDES_TWO_SIDED_LONG, QPrint::DuplexLongSide}
63+
};
64+
65+
const static inline QHash<QPrint::DuplexMode,QByteArray> qDuplexMap = {
66+
{QPrint::DuplexNone, CPDB_SIDES_ONE_SIDED},
67+
{QPrint::DuplexShortSide, CPDB_SIDES_TWO_SIDED_SHORT},
68+
{QPrint::DuplexLongSide, CPDB_SIDES_TWO_SIDED_LONG}
69+
};
4070
};
4171

72+
4273
QT_END_NAMESPACE
4374

4475
#endif // QCPDBSUPPORT_H

0 commit comments

Comments
 (0)