Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:15.5:Update
libqt5-qtbase.18762
0001-Unix-print-dialog-Properly-initialize-dupl...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Unix-print-dialog-Properly-initialize-duplex.patch of Package libqt5-qtbase.18762
From 654f241724b4e58bfb004bb72415728dcecc8697 Mon Sep 17 00:00:00 2001 From: Mischa Salle <msalle@nikhef.nl> Date: Wed, 26 Sep 2018 16:49:03 +0200 Subject: [PATCH] Unix print dialog: Properly initialize duplex This is a backport of https://codereview.qt-project.org/#/c/226881/ and fixes https://bugzilla.suse.com/show_bug.cgi?id=1096328 --- src/printsupport/dialogs/qprintdialog_unix.cpp | 37 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index 12c19b213b..1ce961620f 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -238,6 +238,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; }; #if QT_CONFIG(cups) @@ -469,7 +473,8 @@ void QPrintPropertiesDialog::accept() */ QPrintDialogPrivate::QPrintDialogPrivate() - : top(0), bottom(0), buttons(0), collapseButton(0) + : top(0), bottom(0), buttons(0), collapseButton(0), + explicitDuplexMode(QPrint::DuplexAuto) { initResources(); } @@ -531,6 +536,10 @@ void QPrintDialogPrivate::init() q, SLOT(_q_togglePageSetCombo(bool))); 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); }); } // initialize printer options @@ -540,18 +549,31 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma QPrinter *p = q->printer(); printerOutputFormat = outputFormat; + // printer supports duplex mode? + const auto supportedDuplexMode = top->d->m_currentPrintDevice.supportedDuplexModes(); + options.duplexLong->setEnabled(supportedDuplexMode.contains(QPrint::DuplexLongSide)); + options.duplexShort->setEnabled(supportedDuplexMode.contains(QPrint::DuplexShortSide)); + if (p->colorMode() == QPrinter::Color) options.color->setChecked(true); 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()); @@ -647,6 +669,11 @@ static bool isValidPagesString(const QString &pagesString) Q_DECL_NOTHROW } #endif +void QPrintDialogPrivate::setExplicitDuplexMode(const QPrint::DuplexMode duplexMode) +{ + explicitDuplexMode = duplexMode; +} + void QPrintDialogPrivate::setupPrinter() { // First setup the requested OutputFormat, Printer and Page Size first -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor