forked from pool/libqt5-qtbase
00088d9d89
OBS-URL: https://build.opensuse.org/request/show/572065 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=73
111 lines
3.7 KiB
Diff
111 lines
3.7 KiB
Diff
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) override;
|
|
|
|
+private slots:
|
|
+ void reject() 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 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
|
|
|