Add support for selecting the printer plugin via the env var
Task-number: QTBUG-57260 Change-Id: I046c8ce5af242cdc7efd23468bbe670d782bdfc0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
parent
e51173a2b2
commit
4aebbef8ab
@ -42,6 +42,7 @@
|
||||
#include "qprinterinfo.h"
|
||||
#include "private/qfactoryloader_p.h"
|
||||
#include <qcoreapplication.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
|
||||
@ -79,8 +80,17 @@ QPlatformPrinterSupport *QPlatformPrinterSupportPlugin::get()
|
||||
{
|
||||
if (!printerSupport) {
|
||||
const QMultiMap<int, QString> keyMap = loader()->keyMap();
|
||||
if (!keyMap.isEmpty())
|
||||
printerSupport = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), keyMap.constBegin().value());
|
||||
QMultiMap<int, QString>::const_iterator it = keyMap.cbegin();
|
||||
if (!qEnvironmentVariableIsEmpty("QT_PRINTER_MODULE")) {
|
||||
QString module = QString::fromLocal8Bit(qgetenv("QT_PRINTER_MODULE"));
|
||||
QMultiMap<int, QString>::const_iterator it2 = std::find_if(keyMap.cbegin(), keyMap.cend(), [module](const QString &value){ return value == module; });
|
||||
if (it2 == keyMap.cend())
|
||||
qWarning() << "Unable to load printer plugin" << module;
|
||||
else
|
||||
it = it2;
|
||||
}
|
||||
if (it != keyMap.cend())
|
||||
printerSupport = qLoadPlugin<QPlatformPrinterSupport, QPlatformPrinterSupportPlugin>(loader(), it.value());
|
||||
if (printerSupport)
|
||||
qAddPostRoutine(cleanupPrinterSupport);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user