QPrinter/Windows: Fix handling of native paper source ids.
On Windows, it is possible to pass native Windows paper source ids >= DMBIN_USER to QPrinter::setPaperSource() and they are listed by supportedPaperSources(). Task-number: QTBUG-38897 Task-number: QTBUG-38888 Change-Id: I8f1264e80ce5bdddd3873602200b24eabee00502 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Andy Shaw <andy.shaw@digia.com>
This commit is contained in:
parent
d3d8ade87b
commit
9a2dbcab7e
@ -78,6 +78,7 @@ static QPrint::InputSlot paperBinToInputSlot(int windowsId, const QString &name)
|
|||||||
}
|
}
|
||||||
slot.key = inputSlotMap[i].key;
|
slot.key = inputSlotMap[i].key;
|
||||||
slot.id = inputSlotMap[i].id;
|
slot.id = inputSlotMap[i].id;
|
||||||
|
slot.windowsId = windowsId;
|
||||||
return slot;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the QtGui module of the Qt Toolkit.
|
** This file is part of the QtGui module of the Qt Toolkit.
|
||||||
@ -972,6 +972,24 @@ void QWin32PrintEnginePrivate::doReinit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < inputSlots.size(); ++i) {
|
||||||
|
if (inputSlots.at(i).id == id)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int indexOfWindowsId(const QList<QPrint::InputSlot> &inputSlots, int windowsId)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < inputSlots.size(); ++i) {
|
||||||
|
if (inputSlots.at(i).windowsId == windowsId)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
|
void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
|
||||||
{
|
{
|
||||||
Q_D(QWin32PrintEngine);
|
Q_D(QWin32PrintEngine);
|
||||||
@ -1114,14 +1132,12 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
|
|||||||
case PPK_PaperSource: {
|
case PPK_PaperSource: {
|
||||||
if (!d->devMode)
|
if (!d->devMode)
|
||||||
break;
|
break;
|
||||||
QPrint::InputSlotId inputSlotId = QPrint::InputSlotId(value.toInt());
|
const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots();
|
||||||
foreach (const QPrint::InputSlot &inputSlot, d->m_printDevice.supportedInputSlots()) {
|
const int paperSource = value.toInt();
|
||||||
if (inputSlot.id == inputSlotId) {
|
const int index = paperSource >= DMBIN_USER ?
|
||||||
d->devMode->dmDefaultSource = inputSlot.windowsId;
|
indexOfWindowsId(inputSlots, paperSource) : indexOfId(inputSlots, QPrint::InputSlotId(paperSource));
|
||||||
d->doReinit();
|
d->devMode->dmDefaultSource = index >= 0 ? inputSlots.at(index).windowsId : DMBIN_AUTO;
|
||||||
break;
|
d->doReinit();
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1337,12 +1353,12 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
|||||||
if (!d->devMode) {
|
if (!d->devMode) {
|
||||||
value = d->m_printDevice.defaultInputSlot().id;
|
value = d->m_printDevice.defaultInputSlot().id;
|
||||||
} else {
|
} else {
|
||||||
value = QPrint::Auto;
|
if (d->devMode->dmDefaultSource >= DMBIN_USER) {
|
||||||
foreach (const QPrint::InputSlot inputSlot, d->m_printDevice.supportedInputSlots()) {
|
value = int(d->devMode->dmDefaultSource);
|
||||||
if (inputSlot.windowsId == d->devMode->dmDefaultSource) {
|
} else {
|
||||||
value = inputSlot.id;
|
const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots();
|
||||||
break;
|
const int index = indexOfWindowsId(inputSlots, d->devMode->dmDefaultSource);
|
||||||
}
|
value = index >= 0 ? inputSlots.at(index).id : QPrint::Auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1371,7 +1387,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
|
|||||||
case PPK_PaperSources: {
|
case PPK_PaperSources: {
|
||||||
QList<QVariant> out;
|
QList<QVariant> out;
|
||||||
foreach (const QPrint::InputSlot inputSlot, d->m_printDevice.supportedInputSlots())
|
foreach (const QPrint::InputSlot inputSlot, d->m_printDevice.supportedInputSlots())
|
||||||
out << inputSlot.id;
|
out << QVariant(inputSlot.id == QPrint::CustomInputSlot ? inputSlot.windowsId : int(inputSlot.id));
|
||||||
value = out;
|
value = out;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the test suite of the Qt Toolkit.
|
** This file is part of the test suite of the Qt Toolkit.
|
||||||
@ -474,6 +474,15 @@ void PrintDialogPanel::retrieveSettings(const QPrinter *printer)
|
|||||||
setComboBoxValue(m_panel.m_colorModeCombo, printer->colorMode());
|
setComboBoxValue(m_panel.m_colorModeCombo, printer->colorMode());
|
||||||
m_panel.m_resolution->setValue(printer->resolution());
|
m_panel.m_resolution->setValue(printer->resolution());
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QString availPaperSources;
|
||||||
|
foreach (QPrinter::PaperSource ps, printer->supportedPaperSources())
|
||||||
|
availPaperSources += QString::number(int(ps)) + QLatin1Char(' ');
|
||||||
|
m_panel.availPaperSourceLabel->setText(availPaperSources);
|
||||||
|
#else
|
||||||
|
m_panel.availPaperSourceLabel->setText(QLatin1String("N/A"));
|
||||||
|
#endif
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050300
|
#if QT_VERSION >= 0x050300
|
||||||
m_pageLayout = printer->pageLayout();
|
m_pageLayout = printer->pageLayout();
|
||||||
#else
|
#else
|
||||||
|
@ -527,24 +527,24 @@
|
|||||||
<item row="7" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QComboBox" name="m_paperSourceCombo"/>
|
<widget class="QComboBox" name="m_paperSourceCombo"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="label_23">
|
<widget class="QLabel" name="label_23">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Color Mode:</string>
|
<string>Color Mode:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QComboBox" name="m_colorModeCombo"/>
|
<widget class="QComboBox" name="m_colorModeCombo"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="10" column="0">
|
||||||
<widget class="QLabel" name="label_28">
|
<widget class="QLabel" name="label_28">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Resolution:</string>
|
<string>Resolution:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="10" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="m_resolution">
|
<widget class="QSpinBox" name="m_resolution">
|
||||||
@ -584,6 +584,16 @@
|
|||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="m_pageOrderCombo"/>
|
<widget class="QComboBox" name="m_pageOrderCombo"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
|
<widget class="QLabel" name="availPaperSourceDescLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Available Paper Sources:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
|
<widget class="QLabel" name="availPaperSourceLabel"/>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user