Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP3:GA
libqt5-qtbase.8050
0007-CUPS-Fix-advanced-options-cancel-of-the-pr...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0007-CUPS-Fix-advanced-options-cancel-of-the-print-properties-dialog.patch of Package libqt5-qtbase.8050
From 6efbd4381ade816515bbde59f9d31df0241e1340 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid <albert.astals.cid@kdab.com> Date: Thu, 21 Dec 2017 16:37:14 +0100 Subject: [PATCH] CUPS: Fix advanced options cancel of the print properties dialog When the user changes the advanced settings we call setProperty PDPK_PpdOption so if the user cancels we need to set them back to what they were originally Change-Id: Idd0cb413fb1e68dd28cf66f7f66f7e0afb38393e Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io> --- src/printsupport/dialogs/qprintdialog_unix.cpp | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp index a9745d7..3b1c492 100644 --- a/src/printsupport/dialogs/qprintdialog_unix.cpp +++ b/src/printsupport/dialogs/qprintdialog_unix.cpp @@ -139,6 +139,9 @@ public: void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; +private slots: + void reject() Q_DECL_OVERRIDE; + private: friend class QUnixPrintWidgetPrivate; QPrinter *m_printer; @@ -270,6 +273,7 @@ public: } int selected; + int originallySelected; const char *selDescription; }; @@ -289,6 +293,7 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE; void setCupsOptionsFromItems(QPrinter *printer) const; + void reject(); QPrintDevice *currentPrintDevice() const; QTextCodec *cupsCodec() const; @@ -299,6 +304,7 @@ private: void parseChoices(QOptionTreeItemOption *parent); void setCupsOptionsFromItems(QPrinter *printer, QOptionTreeItem *parent) const; + void reject(QOptionTreeItem *item); QPrintDevice *m_currentPrintDevice; QTextCodec *m_cupsCodec; @@ -399,6 +405,14 @@ void QPrintPropertiesDialog::showEvent(QShowEvent *event) QDialog::showEvent(event); } +void QPrintPropertiesDialog::reject() +{ +#if QT_CONFIG(cups) + m_cupsOptionsModel->reject(); +#endif + QDialog::reject(); +} + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -1297,6 +1311,7 @@ void QPPDOptionsModel::parseChoices(QOptionTreeItemOption *parent) parent->selected = i; parent->selDescription = option->choices[i].text; } + parent->originallySelected = parent->selected; parent->childItems.append(choice); } } @@ -1316,6 +1331,27 @@ QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) co return QVariant(); } +void QPPDOptionsModel::reject() +{ + reject(m_rootItem); +} + +void QPPDOptionsModel::reject(QOptionTreeItem *item) +{ + if (item->type == QOptionTreeItem::Option) { + QOptionTreeItemOption *itemOption = static_cast<QOptionTreeItemOption *>(item); + + const ppd_option_t *option = static_cast<const ppd_option_t*>(item->ptr); + const char *choice = itemOption->originallySelected != -1 ? option->choices[itemOption->originallySelected].choice + : option->defchoice; + const auto values = QStringList{} << QString::fromLatin1(option->keyword) << QString::fromLatin1(choice); + m_currentPrintDevice->setProperty(PDPK_PpdOption, values); + } + + for (QOptionTreeItem *child : qAsConst(item->childItems)) + reject(child); +} + //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// -- 2.7.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