Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
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)
16#elif defined(Q_OS_WIN)
18#endif
19
21
22using namespace Qt::StringLiterals;
23
24Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
25 (QPlatformPrinterSupportFactoryInterface_iid, "/printsupport"_L1, Qt::CaseInsensitive))
26
27QPlatformPrinterSupportPlugin::QPlatformPrinterSupportPlugin(QObject *parent)
28 : QObject(parent)
29{
30}
31
32QPlatformPrinterSupportPlugin::~QPlatformPrinterSupportPlugin()
33{
34}
35
36static QPlatformPrinterSupport *printerSupport = nullptr;
37
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*/
52QPlatformPrinterSupport *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
73QT_END_NAMESPACE
74
75#include "moc_qplatformprintplugin.cpp"
76
77#endif
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 } }))
static QPlatformPrinterSupport * printerSupport
static void cleanupPrinterSupport()
#define QPlatformPrinterSupportFactoryInterface_iid