Unix print dialog: Properly initialize duplex
In case the user has explicitly selected a value for the duplex mode in the print dialog before, select this one when another printer is selected and the newly selected printer supports it. Otherwise, always set to the default value of the respective device that was selected. This way, default values that the user (or admin) has set for a CUPS printer (or printer instance) are honored, but an explicit user choice made in the dialog takes precedence. Previously, the duplex values was always reset to "None" every time the printer was changed. Change-Id: Id9683a05b10cf7a4b842f8b6c8452e80cdc6ff91 Reviewed-by: Andy Shaw <andy.shaw@qt.io>bb10
parent
8b098e6544
commit
fa854f214a
|
|
@ -249,6 +249,10 @@ public:
|
|||
QDialogButtonBox *buttons;
|
||||
QPushButton *collapseButton;
|
||||
QPrinter::OutputFormat printerOutputFormat;
|
||||
private:
|
||||
void setExplicitDuplexMode(QPrint::DuplexMode duplexMode);
|
||||
// duplex mode explicitly set by user, QPrint::DuplexAuto otherwise
|
||||
QPrint::DuplexMode explicitDuplexMode;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -588,7 +592,8 @@ bool QPrintPropertiesDialog::anyAdvancedOptionConflict() const
|
|||
|
||||
*/
|
||||
QPrintDialogPrivate::QPrintDialogPrivate()
|
||||
: top(nullptr), bottom(nullptr), buttons(nullptr), collapseButton(nullptr)
|
||||
: top(nullptr), bottom(nullptr), buttons(nullptr), collapseButton(nullptr),
|
||||
explicitDuplexMode(QPrint::DuplexAuto)
|
||||
{
|
||||
initResources();
|
||||
}
|
||||
|
|
@ -650,6 +655,10 @@ void QPrintDialogPrivate::init()
|
|||
|
||||
QObject::connect(collapseButton, SIGNAL(released()), q, SLOT(_q_collapseOrExpandDialog()));
|
||||
|
||||
QObject::connect(options.noDuplex, &QAbstractButton::clicked, q, [this] { setExplicitDuplexMode(QPrint::DuplexNone); });
|
||||
QObject::connect(options.duplexLong, &QAbstractButton::clicked, q, [this] { setExplicitDuplexMode(QPrint::DuplexLongSide); });
|
||||
QObject::connect(options.duplexShort, &QAbstractButton::clicked, q, [this] { setExplicitDuplexMode(QPrint::DuplexShortSide); });
|
||||
|
||||
#if QT_CONFIG(cups)
|
||||
QObject::connect(options.noDuplex, &QAbstractButton::toggled, q, [this] { updatePpdDuplexOption(options.noDuplex); });
|
||||
QObject::connect(options.duplexLong, &QAbstractButton::toggled, q, [this] { updatePpdDuplexOption(options.duplexLong); });
|
||||
|
|
@ -674,13 +683,20 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
|
|||
else
|
||||
options.grayscale->setChecked(true);
|
||||
|
||||
switch (p->duplex()) {
|
||||
case QPrinter::DuplexNone:
|
||||
// keep duplex value explicitly set by user, if any, and selected printer supports it;
|
||||
// use device default otherwise
|
||||
QPrint::DuplexMode duplex;
|
||||
if (explicitDuplexMode != QPrint::DuplexAuto && supportedDuplexMode.contains(explicitDuplexMode))
|
||||
duplex = explicitDuplexMode;
|
||||
else
|
||||
duplex = top->d->m_currentPrintDevice.defaultDuplexMode();
|
||||
switch (duplex) {
|
||||
case QPrint::DuplexNone:
|
||||
options.noDuplex->setChecked(true); break;
|
||||
case QPrinter::DuplexLongSide:
|
||||
case QPrint::DuplexLongSide:
|
||||
case QPrinter::DuplexAuto:
|
||||
options.duplexLong->setChecked(true); break;
|
||||
case QPrinter::DuplexShortSide:
|
||||
case QPrint::DuplexShortSide:
|
||||
options.duplexShort->setChecked(true); break;
|
||||
}
|
||||
options.copies->setValue(p->copyCount());
|
||||
|
|
@ -795,6 +811,11 @@ void QPrintDialogPrivate::updatePpdDuplexOption(QRadioButton *radio)
|
|||
|
||||
#endif
|
||||
|
||||
void QPrintDialogPrivate::setExplicitDuplexMode(const QPrint::DuplexMode duplexMode)
|
||||
{
|
||||
explicitDuplexMode = duplexMode;
|
||||
}
|
||||
|
||||
void QPrintDialogPrivate::setupPrinter()
|
||||
{
|
||||
// First setup the requested OutputFormat, Printer and Page Size first
|
||||
|
|
|
|||
Loading…
Reference in New Issue