Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qplatformprintplugin.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
include
"qplatformprintplugin.h"
6
#
include
"qplatformprintersupport.h"
7
#
include
"qprinterinfo.h"
8
#
include
"private/qfactoryloader_p.h"
9
#
include
<
qcoreapplication
.
h
>
10
#
include
<
qdebug
.
h
>
11
12
#
ifndef
QT_NO_PRINTER
13
14
#
if
defined
(
Q_OS_MACOS
)
15
Q_IMPORT_PLUGIN
(
QCocoaPrinterSupportPlugin
)
16
#
elif
defined
(
Q_OS_WIN
)
17
Q_IMPORT_PLUGIN
(
QWindowsPrinterSupportPlugin
)
18
#
endif
19
20
QT_BEGIN_NAMESPACE
21
22
using
namespace
Qt::StringLiterals;
23
24
Q_GLOBAL_STATIC_WITH_ARGS
(QFactoryLoader, loader,
25
(
QPlatformPrinterSupportFactoryInterface_iid
,
"/printsupport"_L1
, Qt::CaseInsensitive))
26
27
QPlatformPrinterSupportPlugin::QPlatformPrinterSupportPlugin(QObject *parent)
28
: QObject(parent)
29
{
30
}
31
32
QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
33
{
34
}
35
36
static
QPlatformPrinterSupport *
printerSupport
=
nullptr
;
37
38
static
void
cleanupPrinterSupport
()
39
{
40
delete
printerSupport
;
41
printerSupport
=
nullptr
;
42
}
43
44
/*!
45
\internal
46
47
Returns a lazily-initialized singleton. Ownership is granted to the
48
QPlatformPrinterSupportPlugin, which is never unloaded or destroyed until
49
application exit, i.e. you can expect this pointer to always be valid and
50
multiple calls to this function will always return the same pointer.
51
*/
52
QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
53
{
54
if
(!printerSupport) {
55
const
QMultiMap<
int
, QString> keyMap = loader()->keyMap();
56
QMultiMap<
int
, QString>::const_iterator it = keyMap.cbegin();
57
if
(!qEnvironmentVariableIsEmpty(
"QT_PRINTER_MODULE"
)) {
58
QString module = qEnvironmentVariable(
"QT_PRINTER_MODULE"
);
59
QMultiMap<
int
, QString>::const_iterator it2 = std::find_if(keyMap.cbegin(), keyMap.cend(), [module](
const
QString &value){
return
value == module; });
60
if
(it2 == keyMap.cend())
61
qWarning() <<
"Unable to load printer plugin"
<< module;
62
else
63
it = it2;
64
}
65
if
(it != keyMap.cend())
66
printerSupport = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), it.value());
67
if
(printerSupport)
68
qAddPostRoutine(cleanupPrinterSupport);
69
}
70
return
printerSupport;
71
}
72
73
QT_END_NAMESPACE
74
75
#
include
"moc_qplatformprintplugin.cpp"
76
77
#
endif
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
Q_GLOBAL_STATIC_WITH_ARGS
Q_GLOBAL_STATIC_WITH_ARGS(PermissionStatusHash, g_permissionStatusHash,({ { qMetaTypeId< QCameraPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QMicrophonePermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QBluetoothPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QContactsPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QCalendarPermission >(), Qt::PermissionStatus::Undetermined }, { qMetaTypeId< QLocationPermission >(), Qt::PermissionStatus::Undetermined } }))
printerSupport
static QPlatformPrinterSupport * printerSupport
Definition
qplatformprintplugin.cpp:36
cleanupPrinterSupport
static void cleanupPrinterSupport()
Definition
qplatformprintplugin.cpp:38
QPlatformPrinterSupportFactoryInterface_iid
#define QPlatformPrinterSupportFactoryInterface_iid
Definition
qplatformprintplugin.h:28
qtbase
src
printsupport
kernel
qplatformprintplugin.cpp
Generated on
for Qt by
1.18.0