1
0
forked from pool/libqt5-qtbase

Accepting request 611696 from KDE:Qt5

- Update to 5.11.0
  * New bugfix release
  * For more details please see:
  * http://code.qt.io/cgit/qt/qtbase.git/plain/dist/changes-5.11.0/?h=v5.11.0
- Remove patches, now upstream:
  * 0001-Do-a-static_cast-in-bit-blasts-that-are-UB.patch
  * 0001-sqlite-Check-that-there-are-values-to-be-set-when-bi.patch
  * 0002-sqlite-Bind-duplicated-named-placeholders-correctly.patch
  * 0003-sqlite-Prevent-a-crash-when-sqlite-does-not-detect-a.patch

- Update to 5.11.0-rc
  * New bugfix release
  * No changelog available

- Update to 5.11.0-beta4
  * New bugfix release
  * No changelog available
- Refresh patches:
  * force-cmake-private-headers.patch
- Remove patches, now upstream:
  * 0001-Extend-the-MariaDB-define-check-to-cover-the-later-v.patch

- Update to 5.11.0-beta3
  * New bugfix release
  * No changelog available

- Update to 5.11.0-beta2
  * New bugfix release
  * No changelog available (forwarded request 611481 from Vogtinator)

OBS-URL: https://build.opensuse.org/request/show/611696
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/libqt5-qtbase?expand=0&rev=81
This commit is contained in:
Dominique Leuenberger 2018-06-02 09:52:22 +00:00 committed by Git OBS Bridge
parent 24f02395f2
commit 8d99fc9a15
44 changed files with 195 additions and 5198 deletions

View File

@ -18,10 +18,10 @@ a Change-Id: Ib70715d331e8f380a3c9039011bb8521986652aa
src/plugins/printsupport/cups/qppdprintdevice.cpp | 33 +++++++-
4 files changed, 160 insertions(+), 11 deletions(-)
Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintengine.cpp
Index: qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qcupsprintengine.cpp
===================================================================
--- qtbase-everywhere-src-5.10.0.orig/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintengine.cpp
--- qtbase-everywhere-src-5.11.0-beta1.orig/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -48,6 +48,7 @@
#include <qbuffer.h>
#include "private/qcups_p.h" // Only needed for PPK_CupsOptions
@ -30,11 +30,11 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintengi
#include <cups/cups.h>
@@ -241,8 +242,40 @@ void QCupsPrintEnginePrivate::closePrint
// Print the file.
@@ -243,8 +244,40 @@ void QCupsPrintEnginePrivate::closePrint
const auto parts = printerName.splitRef(QLatin1Char('/'));
const auto printerOriginalName = parts.at(0);
cups_option_t* optPtr = cupsOptStruct.size() ? &cupsOptStruct.first() : 0;
- cupsPrintFile(printerName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
- cupsPrintFile(printerOriginalName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
+
+ bool fallbackToLocal = false;
+ cups_dest_t *cupsDest = NULL;
@ -42,7 +42,7 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintengi
+ if (!qEnvironmentVariableIsSet("QT_ENABLE_PRINTER_DISCOVERY")) {
+ fallbackToLocal = true;
+ } else {
+ cupsDest = cupsGetDest(printerName.toLocal8Bit(), NULL, QCupsPrinterSupport::cupsPrintersCount(), QCupsPrinterSupport::cupsPrinters());
+ cupsDest = cupsGetDest(printerOriginalName.toLocal8Bit(), NULL, QCupsPrinterSupport::cupsPrintersCount(), QCupsPrinterSupport::cupsPrinters());
+ }
+
+ if (cupsDest) {
@ -66,16 +66,16 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintengi
+ }
+
+ if (fallbackToLocal) {
+ cupsPrintFile(printerName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
+ cupsPrintFile(printerOriginalName.toLocal8Bit().constData(), tempFile.toLocal8Bit().constData(),
+ title.toLocal8Bit().constData(), cupsOptStruct.size(), optPtr);
+ }
QFile::remove(tempFile);
}
Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersupport.cpp
Index: qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qcupsprintersupport.cpp
===================================================================
--- qtbase-everywhere-src-5.10.0.orig/src/plugins/printsupport/cups/qcupsprintersupport.cpp
+++ qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersupport.cpp
--- qtbase-everywhere-src-5.11.0-beta1.orig/src/plugins/printsupport/cups/qcupsprintersupport.cpp
+++ qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qcupsprintersupport.cpp
@@ -52,6 +52,35 @@
# include <cups/language.h>
#endif
@ -206,10 +206,10 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersu
+
+
QT_END_NAMESPACE
Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersupport_p.h
Index: qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qcupsprintersupport_p.h
===================================================================
--- qtbase-everywhere-src-5.10.0.orig/src/plugins/printsupport/cups/qcupsprintersupport_p.h
+++ qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersupport_p.h
--- qtbase-everywhere-src-5.11.0-beta1.orig/src/plugins/printsupport/cups/qcupsprintersupport_p.h
+++ qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qcupsprintersupport_p.h
@@ -56,6 +56,8 @@
#include <QtCore/qstringlist.h>
@ -220,8 +220,8 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersu
class QCupsPrinterSupport : public QPlatformPrinterSupport
@@ -71,8 +73,14 @@ public:
QStringList availablePrintDeviceIds() const Q_DECL_OVERRIDE;
QString defaultPrintDeviceId() const Q_DECL_OVERRIDE;
QStringList availablePrintDeviceIds() const override;
QString defaultPrintDeviceId() const override;
+ static void fillCupsPrinters();
+ static cups_dest_t *cupsPrinters() { return qt_cups_printers; };
@ -234,10 +234,10 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qcupsprintersu
};
QT_END_NAMESPACE
Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qppdprintdevice.cpp
Index: qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qppdprintdevice.cpp
===================================================================
--- qtbase-everywhere-src-5.10.0.orig/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qppdprintdevice.cpp
--- qtbase-everywhere-src-5.11.0-beta1.orig/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ qtbase-everywhere-src-5.11.0-beta1/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -39,6 +39,7 @@
#include "qppdprintdevice.h"
@ -246,20 +246,20 @@ Index: qtbase-everywhere-src-5.10.0/src/plugins/printsupport/cups/qppdprintdevic
#include <QtCore/QMimeDatabase>
#include <qdebug.h>
@@ -451,10 +452,38 @@ void QPpdPrintDevice::loadPrinter()
@@ -493,10 +494,38 @@ void QPpdPrintDevice::loadPrinter()
m_cupsDest = 0;
}
+ bool enablePrinterDiscovery = qEnvironmentVariableIsSet("QT_ENABLE_PRINTER_DISCOVERY");
+
// Get the print instance and PPD file
- m_cupsDest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, m_cupsName, m_cupsInstance);
- m_cupsDest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, m_cupsName, m_cupsInstance.isNull() ? nullptr : m_cupsInstance.constData());
+
+ if (!enablePrinterDiscovery) {
+ m_cupsDest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, m_cupsName, m_cupsInstance);
+ m_cupsDest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, m_cupsName, m_cupsInstance.isNull() ? nullptr : m_cupsInstance.constData());
+ } else {
+ cups_dest_t *cupsDest = cupsGetDest( m_cupsName,
+ (m_cupsInstance.isEmpty() ? NULL : m_cupsInstance.data()),
+ (m_cupsInstance.isEmpty() ? nullptr : m_cupsInstance.data()),
+ QCupsPrinterSupport::cupsPrintersCount(),
+ QCupsPrinterSupport::cupsPrinters() );
+ cupsCopyDest(cupsDest, 0, &m_cupsDest);

View File

@ -1,68 +0,0 @@
From d196036024697a75868c1f1626525710495ca428 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Thu, 23 Nov 2017 14:25:04 +0100
Subject: [PATCH] Avoid providing bad pixelDeltas on X11
With libinput we now get a hardcoded resolution that is unrelated to
the hardware. So avoid using that as a real pixel delta and document
pixel deltas as being driver specific and unreliable on X11.
Task-number: QTBUG-59261
Change-Id: I9fe86d80e7ccd290ed2e4091d7eafa52cb537d34
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Marco Martin <mart@kde.org>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
---
src/gui/kernel/qevent.cpp | 1 +
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 14 ++++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 06d52aa..c68f9af 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -971,6 +971,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
\li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
\li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
\endlist
+ \note On X11 this value is driver specific and unreliable, use angleDelta() instead
*/
/*!
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index d1d97af..94f543f 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -953,10 +953,12 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
double delta = scrollingDevice.lastScrollPosition.y() - value;
scrollingDevice.lastScrollPosition.setY(value);
angleDelta.setY((delta / scrollingDevice.verticalIncrement) * 120);
- // We do not set "pixel" delta if it is only measured in ticks.
- if (scrollingDevice.verticalIncrement > 1)
+ // With most drivers the increment is 1 for wheels.
+ // For libinput it is hardcoded to a useless 15.
+ // For a proper touchpad driver it should be in the same order of magnitude as 120
+ if (scrollingDevice.verticalIncrement > 15)
rawDelta.setY(delta);
- else if (scrollingDevice.verticalIncrement < -1)
+ else if (scrollingDevice.verticalIncrement < -15)
rawDelta.setY(-delta);
}
}
@@ -965,10 +967,10 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin
double delta = scrollingDevice.lastScrollPosition.x() - value;
scrollingDevice.lastScrollPosition.setX(value);
angleDelta.setX((delta / scrollingDevice.horizontalIncrement) * 120);
- // We do not set "pixel" delta if it is only measured in ticks.
- if (scrollingDevice.horizontalIncrement > 1)
+ // See comment under vertical
+ if (scrollingDevice.horizontalIncrement > 15)
rawDelta.setX(delta);
- else if (scrollingDevice.horizontalIncrement < -1)
+ else if (scrollingDevice.horizontalIncrement < -15)
rawDelta.setX(-delta);
}
}
--
2.7.4

View File

@ -1,103 +0,0 @@
From 5a53a9893c50cf01fb3b93d256bbc669f99c16ea Mon Sep 17 00:00:00 2001
From: Ville Voutilainen <ville.voutilainen@qt.io>
Date: Fri, 12 Jan 2018 16:29:00 +0200
Subject: [PATCH] Do a static_cast in bit-blasts that are UB
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Without this, building Qt and Qt applications fails with GCC 8.
The errors look like this:
writing to an object of type class QPointer<QQuickPointerHandler> with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
Task-number: QTBUG-65691
Change-Id: Ie5a30814125deca7a160b9a61f5aa3f944ee1ac9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
---
src/gui/painting/qmatrix.h | 4 ++--
src/gui/painting/qtransform.h | 6 +++---
src/gui/text/qtextengine_p.h | 8 ++++----
src/gui/text/qtextobject.h | 4 ++--
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 15e0ab5be1..dafb746bc6 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -65,10 +65,10 @@ public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// ### Qt 6: remove; the compiler-generated ones are fine!
QMatrix &operator=(QMatrix &&other) Q_DECL_NOTHROW // = default
- { memcpy(this, &other, sizeof(QMatrix)); return *this; }
+ { memcpy(static_cast<void *>(this), static_cast<void *>(&other), sizeof(QMatrix)); return *this; }
QMatrix &operator=(const QMatrix &) Q_DECL_NOTHROW; // = default
QMatrix(QMatrix &&other) Q_DECL_NOTHROW // = default
- { memcpy(this, &other, sizeof(QMatrix)); }
+ { memcpy(static_cast<void *>(this), static_cast<void *>(&other), sizeof(QMatrix)); }
QMatrix(const QMatrix &other) Q_DECL_NOTHROW; // = default
#endif
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index 06ae611861..efb0fd7e83 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -78,14 +78,14 @@ public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// ### Qt 6: remove; the compiler-generated ones are fine!
QTransform &operator=(QTransform &&other) Q_DECL_NOTHROW // = default
- { memcpy(this, &other, sizeof(QTransform)); return *this; }
+ { memcpy(static_cast<void *>(this), static_cast<void *>(&other), sizeof(QTransform)); return *this; }
QTransform &operator=(const QTransform &) Q_DECL_NOTHROW; // = default
QTransform(QTransform &&other) Q_DECL_NOTHROW // = default
: affine(Qt::Uninitialized)
- { memcpy(this, &other, sizeof(QTransform)); }
+ { memcpy(static_cast<void *>(this), static_cast<void *>(&other), sizeof(QTransform)); }
QTransform(const QTransform &other) Q_DECL_NOTHROW // = default
: affine(Qt::Uninitialized)
- { memcpy(this, &other, sizeof(QTransform)); }
+ { memcpy(static_cast<void *>(this), static_cast<const void *>(&other), sizeof(QTransform)); }
#endif
bool isAffine() const;
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 89f1328241..90c1a12acd 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -236,13 +236,13 @@ struct QGlyphLayout
last = numGlyphs;
if (first == 0 && last == numGlyphs
&& reinterpret_cast<char *>(offsets + numGlyphs) == reinterpret_cast<char *>(glyphs)) {
- memset(offsets, 0, (numGlyphs * SpaceNeeded));
+ memset(static_cast<void *>(offsets), 0, (numGlyphs * SpaceNeeded));
} else {
const int num = last - first;
- memset(offsets + first, 0, num * sizeof(QFixedPoint));
+ memset(static_cast<void *>(offsets + first), 0, num * sizeof(QFixedPoint));
memset(glyphs + first, 0, num * sizeof(glyph_t));
- memset(advances + first, 0, num * sizeof(QFixed));
- memset(justifications + first, 0, num * sizeof(QGlyphJustification));
+ memset(static_cast<void *>(advances + first), 0, num * sizeof(QFixed));
+ memset(static_cast<void *>(justifications + first), 0, num * sizeof(QGlyphJustification));
memset(attributes + first, 0, num * sizeof(QGlyphAttributes));
}
}
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index a5030de112..4cc2535b58 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -154,9 +154,9 @@ public:
iterator(const iterator &o) Q_DECL_NOTHROW; // = default
iterator &operator=(const iterator &o) Q_DECL_NOTHROW; // = default
iterator(iterator &&other) Q_DECL_NOTHROW // = default
- { memcpy(this, &other, sizeof(iterator)); }
+ { memcpy(static_cast<void *>(this), static_cast<void *>(&other), sizeof(iterator)); }
iterator &operator=(iterator &&other) Q_DECL_NOTHROW // = default
- { memcpy(this, &other, sizeof(iterator)); return *this; }
+ { memcpy(static_cast<void *>(this), static_cast<void *>(&other), sizeof(iterator)); return *this; }
#endif
QTextFrame *parentFrame() const { return f; }
--
2.16.2

View File

@ -1,35 +0,0 @@
From b2bd1eef198b9d4774e1f10c77d6622813938543 Mon Sep 17 00:00:00 2001
From: Andy Shaw <andy.shaw@qt.io>
Date: Wed, 27 Sep 2017 09:23:10 +0200
Subject: [PATCH] Extend the MariaDB define check to cover the later versions
too
Change-Id: Ide89b4e07feb116bf152cbf3f5630d313e8ba0f1
---
src/plugins/sqldrivers/mysql/qsql_mysql.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index d9aebff700..7694698bff 100644
--- a/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -1160,14 +1160,14 @@ static void qLibraryInit()
# endif // MYSQL_VERSION_ID
#endif // Q_NO_MYSQL_EMBEDDED
-#ifdef MARIADB_BASE_VERSION
+#if defined(MARIADB_BASE_VERSION) || defined(MARIADB_VERSION_ID)
qAddPostRoutine(mysql_server_end);
#endif
}
static void qLibraryEnd()
{
-#if !defined(MARIADB_BASE_VERSION)
+#if !defined(MARIADB_BASE_VERSION) && !defined(MARIADB_VERSION_ID)
# if !defined(Q_NO_MYSQL_EMBEDDED)
# if MYSQL_VERSION_ID > 40000
# if (MYSQL_VERSION_ID >= 40110 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50003
--
2.16.1

View File

@ -1,170 +0,0 @@
From 4a7771f206d4b29be549d3827c36a46679d90de6 Mon Sep 17 00:00:00 2001
From: Eike Hein <hein@kde.org>
Date: Sun, 7 Jan 2018 13:02:01 +0900
Subject: [PATCH] QSimpleDrag: Fix mouse release coords for delayed event
transmission
On platforms such as XCB, the drag cursor pixmap is shown via a window
(a QShapedPixmapWindow) under the cursor.
The mouse button release event at the end of the drag is received in
this QXcbWindow, but intercepted by an event filter that QSimpleDrag
installs on the QApplication. It then resends it unmodified(!) after
the drag has ended and the drag pixmap window destroyed, causing it to
be delivered to the new top-level window.
The local coordinates in the unmodified QMouseEvent are local to the
drag pixmap window and don't match the window it is delayed-transmitted
to.
This ends up having fatal, user-visible effects particularly in Qt
Quick: QQuickWindow synthesizes a hover event once per frame using
the last received mouse coordinates, here: the release posted by
QSimpleDrag. This is done to update the hover event state for items
under the cursor when the mouse hasn't moved (e.g. QQuickMouseArea::
containsMouse). The bogus event coordinates in the release event then
usually end up causing an item near the top-left of the QQuickWindow
to assume it is hovered (because drag pixmap windows tend to be small),
even when the mouse cursor is actually far away from it at the end of
the drag.
This shows up e.g. in the Plasma 5 desktop, where dragging an icon
on the desktop will cause the icon at the top-left of the screen (if
any) to switch to hovered state, as the release coordinates on the
drag pixmap window (showing a dragged icon) fall into the geometry
of the top-left icon.
QSimpleDrag contains a topLevelAt() function to find the top-level
window under the global cursor coordinates that is not the drag
pixmap window. This is used by the drop event delivery code.
This patch uses this function to find the relevant top-level window,
then asks it to map the global cusor coordinates to its local
coordinate system, then synthesizes a new QMouseEvent with local
coordinates computed in this fashion. As a result the window now
gets a release event with coordinates that make sense and are
correct.
Task-number: QTBUG-66103
Change-Id: I04ebe6ccd4a991fdd4b540ff0227973ea8896a9d
Reviewed-by: Eike Hein <hein@kde.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
---
src/gui/kernel/qsimpledrag.cpp | 32 +++++++++++++++++++++++++++-----
src/gui/kernel/qsimpledrag_p.h | 6 +++---
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index a1e25dc53c..87d3ba5915 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -58,6 +58,7 @@
#include <QtCore/QEventLoop>
#include <QtCore/QDebug>
+#include <QtCore/QLoggingCategory>
#include <private/qguiapplication_p.h>
#include <private/qdnd_p.h>
@@ -69,6 +70,8 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
+Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd")
+
static QWindow* topLevelAt(const QPoint &pos)
{
QWindowList list = QGuiApplication::topLevelWindows();
@@ -94,10 +97,10 @@ static QWindow* topLevelAt(const QPoint &pos)
*/
QBasicDrag::QBasicDrag() :
- m_restoreCursor(false), m_eventLoop(0),
+ m_current_window(nullptr), m_restoreCursor(false), m_eventLoop(nullptr),
m_executed_drop_action(Qt::IgnoreAction), m_can_drop(false),
- m_drag(0), m_drag_icon_window(0), m_useCompositing(true),
- m_screen(Q_NULLPTR)
+ m_drag(nullptr), m_drag_icon_window(nullptr), m_useCompositing(true),
+ m_screen(nullptr)
{
}
@@ -161,6 +164,7 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
return true; // Eat all mouse move events
}
case QEvent::MouseButtonRelease:
+ {
disableEventFilter();
if (canDrop()) {
QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window);
@@ -169,8 +173,25 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
cancel();
}
exitDndEventLoop();
- QCoreApplication::postEvent(o, new QMouseEvent(*static_cast<QMouseEvent *>(e)));
+
+ // If a QShapedPixmapWindow (drag feedback) is being dragged along, the
+ // mouse event's localPos() will be relative to that, which is useless.
+ // We want a position relative to the window where the drag ends, if possible (?).
+ // If there is no such window (belonging to this Qt application),
+ // make the event relative to the window where the drag started. (QTBUG-66103)
+ const QMouseEvent *release = static_cast<QMouseEvent *>(e);
+ const QWindow *releaseWindow = topLevelAt(release->globalPos());
+ qCDebug(lcDnd) << "mouse released over" << releaseWindow << "after drag from" << m_current_window << "globalPos" << release->globalPos();
+ if (!releaseWindow)
+ releaseWindow = m_current_window;
+ QPoint releaseWindowPos = (releaseWindow ? releaseWindow->mapFromGlobal(release->globalPos()) : release->globalPos());
+ QMouseEvent *newRelease = new QMouseEvent(release->type(),
+ releaseWindowPos, releaseWindowPos, release->screenPos(),
+ release->button(), release->buttons(),
+ release->modifiers(), release->source());
+ QCoreApplication::postEvent(o, newRelease);
return true; // defer mouse release events until drag event loop has returned
+ }
case QEvent::MouseButtonDblClick:
case QEvent::Wheel:
return true;
@@ -349,7 +370,7 @@ static inline QPoint fromNativeGlobalPixels(const QPoint &point)
into account.
*/
-QSimpleDrag::QSimpleDrag() : m_current_window(0)
+QSimpleDrag::QSimpleDrag()
{
}
@@ -373,6 +394,7 @@ void QSimpleDrag::startDrag()
updateCursor(Qt::IgnoreAction);
}
setExecutedDropAction(Qt::IgnoreAction);
+ qCDebug(lcDnd) << "drag began from" << m_current_window<< "cursor pos" << QCursor::pos() << "can drop?" << canDrop();
}
void QSimpleDrag::cancel()
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index 0b8a0bc703..bbd7f7f4bb 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -105,6 +105,9 @@ protected:
QDrag *drag() const { return m_drag; }
+protected:
+ QWindow *m_current_window;
+
private:
void enableEventFilter();
void disableEventFilter();
@@ -132,9 +135,6 @@ protected:
virtual void cancel() Q_DECL_OVERRIDE;
virtual void move(const QPoint &globalPos) Q_DECL_OVERRIDE;
virtual void drop(const QPoint &globalPos) Q_DECL_OVERRIDE;
-
-private:
- QWindow *m_current_window;
};
#endif // QT_NO_DRAGANDDROP
--
2.16.1

View File

@ -1,41 +0,0 @@
From 2ecfdf87b8362309f555e441f16e6c5b56f17e63 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 12:42:54 +0100
Subject: [PATCH 02/54] Remove QPrintDialogPrivate::applyPrinterProperties, no
one calls it
Change-Id: Ic140f62e5cb63c6a4b7f4fa10ca243d8bb055c4e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 8 --------
1 file changed, 8 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 183af7daa3..37a562125e 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -203,8 +203,6 @@ public:
~QPrintDialogPrivate();
void init();
- /// copy printer properties to the widget
- void applyPrinterProperties();
void selectPrinter(const QPrinter::OutputFormat outputFormat);
@@ -390,12 +388,6 @@ void QPrintDialogPrivate::selectPrinter(const QPrinter::OutputFormat outputForma
options.pageSetCombo->setEnabled(true);
}
-void QPrintDialogPrivate::applyPrinterProperties()
-{
- // apply printer options to property dialog
- top->d->applyPrinterProperties();
-}
-
void QPrintDialogPrivate::setupPrinter()
{
// First setup the requested OutputFormat, Printer and Page Size first
--
2.15.1

View File

@ -1,33 +0,0 @@
From cd12671fac459b71d2f5f65d3e221e4e8fca25f1 Mon Sep 17 00:00:00 2001
From: Andy Shaw <andy.shaw@qt.io>
Date: Thu, 7 Dec 2017 16:01:48 +0100
Subject: [PATCH 1/3] sqlite: Check that there are values to be set when
binding
If the values vector is empty then we know already that the paramCount
will still be invalid, so we should just accept that and not check the
reused named placeholders.
Task-number: QTBUG-64923
Change-Id: Ifaa755540c4574f1f76d3f9f129bf0f66b837b70
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
---
src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index e9f5ee9508..67dd1a6ee5 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -467,7 +467,7 @@ bool QSQLiteResult::exec()
#if (SQLITE_VERSION_NUMBER >= 3003011)
// In the case of the reuse of a named placeholder
- if (!paramCountIsValid) {
+ if (paramCount < values.count()) {
const auto countIndexes = [](int counter, const QList<int>& indexList) {
return counter + indexList.length();
};
--
2.16.2

View File

@ -1,73 +0,0 @@
From 79d78d814acad4e183e281aea9b131f396abe3fb Mon Sep 17 00:00:00 2001
From: Gatis Paeglis <gatis.paeglis@qt.io>
Date: Thu, 7 Dec 2017 11:49:49 +0100
Subject: [PATCH] xcb: verify if xrandr present before using xcb_randr* APIs
Not doing so might break the connection. We have had similar
issues before, e.g. QTBUG-45312.
Change-Id: I95f15d24773fc92b052578bd72d1ba264d0a5f63
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Uli Schlachter <psychon@znc.in>
---
src/plugins/platforms/xcb/qxcbscreen.cpp | 35 +++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index ec0f9ba561..67c96b2d80 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -446,17 +446,24 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
m_cursor = new QXcbCursor(connection, this);
- // Parse EDID
- if (m_edid.parse(getEdid()))
- qCDebug(lcQpaScreen, "EDID data for output \"%s\": identifier '%s', manufacturer '%s', model '%s', serial '%s', physical size: %.2fx%.2f",
- name().toLatin1().constData(),
- m_edid.identifier.toLatin1().constData(),
- m_edid.manufacturer.toLatin1().constData(),
- m_edid.model.toLatin1().constData(),
- m_edid.serialNumber.toLatin1().constData(),
- m_edid.physicalSize.width(), m_edid.physicalSize.height());
- else
- qCDebug(lcQpaScreen) << "Failed to parse EDID data for output" << name(); // keep this debug, not warning
+ if (connection->hasXRandr()) { // Parse EDID
+ QByteArray edid = getEdid();
+ if (m_edid.parse(edid)) {
+ qCDebug(lcQpaScreen, "EDID data for output \"%s\": identifier '%s', manufacturer '%s',"
+ "model '%s', serial '%s', physical size: %.2fx%.2f",
+ name().toLatin1().constData(),
+ m_edid.identifier.toLatin1().constData(),
+ m_edid.manufacturer.toLatin1().constData(),
+ m_edid.model.toLatin1().constData(),
+ m_edid.serialNumber.toLatin1().constData(),
+ m_edid.physicalSize.width(), m_edid.physicalSize.height());
+ } else {
+ // This property is defined by the xrandr spec. Parsing failure indicates a valid error,
+ // but keep this as debug, for details see 4f515815efc318ddc909a0399b71b8a684962f38.
+ qCDebug(lcQpaScreen) << "Failed to parse EDID data for output" << name() <<
+ "edid data: " << edid;
+ }
+ }
}
QXcbScreen::~QXcbScreen()
@@ -899,9 +906,13 @@ QByteArray QXcbScreen::getOutputProperty(xcb_atom_t atom) const
QByteArray QXcbScreen::getEdid() const
{
+ QByteArray result;
+ if (!connection()->hasXRandr())
+ return result;
+
// Try a bunch of atoms
xcb_atom_t atom = connection()->internAtom("EDID");
- QByteArray result = getOutputProperty(atom);
+ result = getOutputProperty(atom);
if (result.isEmpty()) {
atom = connection()->internAtom("EDID_DATA");
result = getOutputProperty(atom);
--
2.15.0

View File

@ -1,137 +0,0 @@
From ad77a2447e8cc828dadd268c72428556e3cc8a84 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 6 Dec 2017 10:19:13 +0100
Subject: [PATCH 1/1] CUPS: Use default cups job-priority instead of 50
This also reads the job-priority from lpoptions if set there for the particular printer
Change-Id: I75d983c377d2135a0b0d3e028829a7384a5e1897
Reviewed-by: Laurent Montel <laurent.montel@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 ++
src/printsupport/dialogs/qprintdialog_unix.cpp | 2 +-
src/printsupport/kernel/qcups_p.h | 5 +++--
src/printsupport/widgets/qcupsjobwidget.cpp | 20 +++++++++++++++++---
src/printsupport/widgets/qcupsjobwidget_p.h | 4 +++-
5 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 021d040..56976a6 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -427,6 +427,8 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
{
if (key == PDPK_PpdFile)
return QVariant::fromValue<ppd_file_t *>(m_ppd);
+ else if (key == PDPK_CupsJobPriority)
+ return printerOption(QStringLiteral("job-priority"));
return QVariant();
}
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 9ad9fa3..020894c 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -333,7 +333,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
widget.pageSetup->setPrinter(printer, outputFormat, printerName);
#if QT_CONFIG(cupsjobwidget)
- m_jobOptions = new QCupsJobWidget(printer);
+ m_jobOptions = new QCupsJobWidget(printer, currentPrintDevice);
widget.tabs->insertTab(1, m_jobOptions, tr("Job Options"));
#endif
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index b67390c..3abccf2 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -67,8 +67,9 @@ QT_BEGIN_NAMESPACE
// removed from the dialogs.
#define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00)
-#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
-#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
+#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
+#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
+#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index 8fb07c8..f21e229 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -52,6 +52,8 @@
#include <QPrinter>
#include <QPrintEngine>
+#include <kernel/qprintdevice_p.h>
+
QT_BEGIN_NAMESPACE
/*!
@@ -64,9 +66,10 @@ QT_BEGIN_NAMESPACE
\inmodule QtPrintSupport
*/
-QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QWidget *parent)
+QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWidget *parent)
: QWidget(parent),
- m_printer(printer)
+ m_printer(printer),
+ m_printDevice(printDevice)
{
m_ui.setupUi(this);
//set all the default values
@@ -151,7 +154,18 @@ QString QCupsJobWidget::jobBilling() const
void QCupsJobWidget::initJobPriority()
{
- setJobPriority(50);
+ int priority = -1;
+ if (m_printDevice) {
+ bool ok;
+ priority = m_printDevice->property(PDPK_CupsJobPriority).toInt(&ok);
+ if (!ok)
+ priority = -1;
+ }
+
+ if (priority < 0 || priority > 100)
+ priority = 50;
+
+ setJobPriority(priority);
}
void QCupsJobWidget::setJobPriority(int jobPriority)
diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h
index 2aca6bc..dcec27a 100644
--- a/src/printsupport/widgets/qcupsjobwidget_p.h
+++ b/src/printsupport/widgets/qcupsjobwidget_p.h
@@ -65,13 +65,14 @@ QT_BEGIN_NAMESPACE
class QString;
class QTime;
class QPrinter;
+class QPrintDevice;
class QCupsJobWidget : public QWidget
{
Q_OBJECT
public:
- explicit QCupsJobWidget(QPrinter *printer, QWidget *parent = nullptr);
+ explicit QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWidget *parent = nullptr);
~QCupsJobWidget();
void setupPrinter();
@@ -102,6 +103,7 @@ private:
void initBannerPages();
QPrinter *m_printer;
+ QPrintDevice *m_printDevice;
Ui::QCupsJobWidget m_ui;
Q_DISABLE_COPY(QCupsJobWidget)
--
2.7.4

View File

@ -1,123 +0,0 @@
From fb1836898f5f8f88accea92a5ad7adb625694700 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 12:49:12 +0100
Subject: [PATCH 03/54] Remove QUnixPrintWidgetPrivate::applyPrinterProperties
And move it's code to the only place it is called, the QUnixPrintWidget constructor,
that means we can remove the if that checks if propertiesDialog is not null since
at that stage we know it is null
Change-Id: I81cdaa0505fa6fe64a45c7d1f5c3e277400cbbf7
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 80 +++++++++++---------------
1 file changed, 35 insertions(+), 45 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 37a562125e..66d37dbec3 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -168,8 +168,6 @@ public:
QUnixPrintWidgetPrivate(QUnixPrintWidget *q, QPrinter *prn);
~QUnixPrintWidgetPrivate();
- /// copy printer properties to the widget
- void applyPrinterProperties();
bool checkFields();
void setupPrinter();
void setOptionsPane(QPrintDialogPrivate *pane);
@@ -790,48 +788,6 @@ void QUnixPrintWidgetPrivate::_q_btnBrowseClicked()
}
}
-void QUnixPrintWidgetPrivate::applyPrinterProperties()
-{
- if (printer == nullptr)
- return;
- if (printer->outputFileName().isEmpty()) {
- QString home = QDir::homePath();
- QString cur = QDir::currentPath();
- if (home.at(home.length()-1) != QLatin1Char('/'))
- home += QLatin1Char('/');
- if (!cur.isEmpty() && cur.at(cur.length()-1) != QLatin1Char('/'))
- cur += QLatin1Char('/');
- if (!cur.startsWith(home))
- cur = home;
- if (QGuiApplication::platformName() == QLatin1String("xcb")) {
- if (printer->docName().isEmpty()) {
- cur += QLatin1String("print.pdf");
- } else {
- QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));
- if (re.exactMatch(printer->docName()))
- cur += re.cap(1);
- else
- cur += printer->docName();
- cur += QLatin1String(".pdf");
- }
- } // xcb
-
- widget.filename->setText(cur);
- }
- else
- widget.filename->setText( printer->outputFileName() );
- QString printerName = printer->printerName();
- if (!printerName.isEmpty()) {
- const int i = widget.printers->findText(printerName);
- if (i >= 0)
- widget.printers->setCurrentIndex(i);
- }
- // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
-
- if (propertiesDialog)
- propertiesDialog->applyPrinterProperties(printer);
-}
-
#if QT_CONFIG(messagebox)
bool QUnixPrintWidgetPrivate::checkFields()
{
@@ -951,7 +907,41 @@ void QUnixPrintWidgetPrivate::setupPrinter()
QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
: QWidget(parent), d(new QUnixPrintWidgetPrivate(this, printer))
{
- d->applyPrinterProperties();
+ if (printer == nullptr)
+ return;
+ if (printer->outputFileName().isEmpty()) {
+ QString home = QDir::homePath();
+ QString cur = QDir::currentPath();
+ if (!home.endsWith(QLatin1Char('/')))
+ home += QLatin1Char('/');
+ if (!cur.startsWith(home))
+ cur = home;
+ else if (!cur.endsWith(QLatin1Char('/')))
+ cur += QLatin1Char('/');
+ if (QGuiApplication::platformName() == QStringLiteral("xcb")) {
+ if (printer->docName().isEmpty()) {
+ cur += QStringLiteral("print.pdf");
+ } else {
+ const QRegExp re(QStringLiteral("(.*)\\.\\S+"));
+ if (re.exactMatch(printer->docName()))
+ cur += re.cap(1);
+ else
+ cur += printer->docName();
+ cur += QStringLiteral(".pdf");
+ }
+ } // xcb
+
+ d->widget.filename->setText(cur);
+ }
+ else
+ d->widget.filename->setText(printer->outputFileName());
+ const QString printerName = printer->printerName();
+ if (!printerName.isEmpty()) {
+ const int i = d->widget.printers->findText(printerName);
+ if (i >= 0)
+ d->widget.printers->setCurrentIndex(i);
+ }
+ // PDF printer not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
}
/*! \internal
--
2.15.1

View File

@ -1,91 +0,0 @@
From 0c8aa32d9a1b1952c5d53529655c485f5b34a695 Mon Sep 17 00:00:00 2001
From: Andy Shaw <andy.shaw@qt.io>
Date: Tue, 2 Jan 2018 09:33:48 +0100
Subject: [PATCH 2/3] sqlite: Bind duplicated named placeholders correctly
sqlite will reuse the index for bound parameters when the named
placeholder is duplicated so we only need to call bind one time for each
placeholder. Therefore we need to have just one instance of each value
when doing the bind.
Task-number: QTBUG-65150
Change-Id: I75c4bcc4563e43c180a59a7a4cbb770dbe994642
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
---
src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 16 ++++++++++++++-
tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 25 +++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 67dd1a6ee5..444b18686a 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -446,7 +446,7 @@ static QString timespecToString(const QDateTime &dateTime)
bool QSQLiteResult::exec()
{
Q_D(QSQLiteResult);
- const QVector<QVariant> values = boundValues();
+ QVector<QVariant> values = boundValues();
d->skippedStatus = false;
d->skipRow = false;
@@ -478,6 +478,20 @@ bool QSQLiteResult::exec()
countIndexes);
paramCountIsValid = bindParamCount == values.count();
+ // When using named placeholders, it will reuse the index for duplicated
+ // placeholders. So we need to ensure the QVector has only one instance of
+ // each value as SQLite will do the rest for us.
+ QVector<QVariant> prunedValues;
+ QList<int> handledIndexes;
+ for (int i = 0, currentIndex = 0; i < values.size(); ++i) {
+ if (handledIndexes.contains(i))
+ continue;
+ const auto placeHolder = QString::fromUtf8(sqlite3_bind_parameter_name(d->stmt, currentIndex + 1));
+ handledIndexes << d->indexes[placeHolder];
+ prunedValues << values.at(d->indexes[placeHolder].first());
+ ++currentIndex;
+ }
+ values = prunedValues;
}
#endif
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 3ea13896d8..1a0340f153 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -2017,6 +2017,31 @@ void tst_QSqlQuery::prepare_bind_exec()
QCOMPARE( q.value(1).toString(), QString("name") );
QCOMPARE( q.value(2).toString(), QString("name") );
+ // Test that duplicated named placeholders before the next unique one works correctly - QTBUG-65150
+ QVERIFY(q.prepare("insert into " + qtest_prepare + " (id, name, name2) values (:id, :id, :name)"));
+ for (i = 104; i < 106; ++i) {
+ q.bindValue(":id", i);
+ q.bindValue(":name", "name");
+ QVERIFY(q.exec());
+ }
+ QVERIFY(q.exec("select * from " + qtest_prepare + " where id > 103 order by id"));
+ QVERIFY(q.next());
+ QCOMPARE(q.value(0).toInt(), 104);
+ QCOMPARE(q.value(1).toString(), QString("104"));
+ QCOMPARE(q.value(2).toString(), QString("name"));
+
+ // Test that duplicated named placeholders in any order
+ QVERIFY(q.prepare("insert into " + qtest_prepare + " (id, name, name2) values (:id, :name, :id)"));
+ for (i = 107; i < 109; ++i) {
+ q.bindValue(":id", i);
+ q.bindValue(":name", "name");
+ QVERIFY(q.exec());
+ }
+ QVERIFY(q.exec("select * from " + qtest_prepare + " where id > 106 order by id"));
+ QVERIFY(q.next());
+ QCOMPARE(q.value(0).toInt(), 107);
+ QCOMPARE(q.value(1).toString(), QString("name"));
+ QCOMPARE(q.value(2).toString(), QString("107"));
} // end of SQLite scope
}
--
2.16.2

View File

@ -1,86 +0,0 @@
From ff67dedaaff2dc68571ca9c8c6c6eeaaf084eae4 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 6 Dec 2017 15:27:05 +0100
Subject: [PATCH 1/1] QPageSetupWidget::setPrinter: Use printdevice default
paper size
This means that actually the paper size set on system settings (or lpoptions) is used instead of A4
Change-Id: I2dd86fd9ba210a335773430328b0ba2d3343395f
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 9 +++++++--
src/printsupport/dialogs/qpagesetupdialog_unix_p.h | 4 +++-
src/printsupport/dialogs/qprintdialog_unix.cpp | 2 +-
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index 49c0184..6f3bb0d 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -210,7 +210,7 @@ void QUnixPageSetupDialogPrivate::init()
Q_Q(QPageSetupDialog);
widget = new QPageSetupWidget(q);
- widget->setPrinter(printer, printer->outputFormat(), printer->printerName());
+ widget->setPrinter(printer, nullptr, printer->outputFormat(), printer->printerName());
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel,
@@ -371,12 +371,17 @@ void QPageSetupWidget::initPageSizes()
// Set the dialog to use the given QPrinter
// Usually only called on first creation
-void QPageSetupWidget::setPrinter(QPrinter *printer, QPrinter::OutputFormat outputFormat, const QString &printerName)
+void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice,
+ QPrinter::OutputFormat outputFormat, const QString &printerName)
{
m_printer = printer;
// Initialize the layout to the current QPrinter layout
m_pageLayout = m_printer->pageLayout();
+
+ if (printDevice)
+ m_pageLayout.setPageSize(printDevice->defaultPageSize());
+
// Assume if margins are Points then is by default, so set to locale default units
if (m_pageLayout.units() == QPageLayout::Point) {
if (QLocale().measurementSystem() == QLocale::MetricSystem)
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
index 44aca80..574569d 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
@@ -64,6 +64,7 @@ QT_REQUIRE_CONFIG(printdialog);
QT_BEGIN_NAMESPACE
class QPrinter;
+class QPrintDevice;
class QPagePreview;
class QPageSetupWidget : public QWidget {
@@ -71,7 +72,8 @@ class QPageSetupWidget : public QWidget {
explicit QPageSetupWidget(QWidget *parent = 0);
explicit QPageSetupWidget(QPrinter *printer, QWidget *parent = 0);
- void setPrinter(QPrinter *printer, QPrinter::OutputFormat outputFormat, const QString &printerName);
+ void setPrinter(QPrinter *printer, QPrintDevice *printDevice,
+ QPrinter::OutputFormat outputFormat, const QString &printerName);
void setupPrinter() const;
private slots:
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 020894c..22076bf 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -330,7 +330,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
- widget.pageSetup->setPrinter(printer, outputFormat, printerName);
+ widget.pageSetup->setPrinter(printer, currentPrintDevice, outputFormat, printerName);
#if QT_CONFIG(cupsjobwidget)
m_jobOptions = new QCupsJobWidget(printer, currentPrintDevice);
--
2.7.4

View File

@ -1,85 +0,0 @@
From f135d515e8d6aaf1c136aef68e08b4f759075310 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 12:53:04 +0100
Subject: [PATCH 04/54] Remove QPrintPropertiesDialog::applyPrinterProperties
It's only ever called after the constructor so merge its code to the constructor
Change-Id: Icca88764f725b9aeaa08ee7387da8885be247fba
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 66d37dbec3..6cccdd03cd 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -124,13 +124,11 @@ class QPrintPropertiesDialog : public QDialog
{
Q_OBJECT
public:
- QPrintPropertiesDialog(QAbstractPrintDialog *parent = nullptr);
+ QPrintPropertiesDialog(QPrinter *printer, QAbstractPrintDialog *parent = nullptr);
~QPrintPropertiesDialog();
void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName);
- /// copy printer properties to the widget
- void applyPrinterProperties(QPrinter *p);
void setupPrinter() const;
private:
@@ -236,7 +234,7 @@ public:
*/
-QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
+QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QAbstractPrintDialog *parent)
: QDialog(parent)
{
setWindowTitle(tr("Printer Properties"));
@@ -250,8 +248,11 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
+ widget.pageSetup->setPrinter(printer);
+
#if QT_CONFIG(cupsjobwidget)
m_jobOptions = new QCupsJobWidget();
+ m_jobOptions->setPrinter(printer);
widget.tabs->addTab(m_jobOptions, tr("Job Options"));
#endif
}
@@ -260,14 +261,6 @@ QPrintPropertiesDialog::~QPrintPropertiesDialog()
{
}
-void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p)
-{
- widget.pageSetup->setPrinter(p);
-#if QT_CONFIG(cupsjobwidget)
- m_jobOptions->setPrinter(p);
-#endif
-}
-
void QPrintPropertiesDialog::setupPrinter() const
{
widget.pageSetup->setupPrinter();
@@ -846,12 +839,10 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties()
if (propertiesDialog)
delete propertiesDialog;
- propertiesDialog = new QPrintPropertiesDialog(q);
+ propertiesDialog = new QPrintPropertiesDialog(q->printer(), q);
propertiesDialog->setResult(QDialog::Rejected);
propertiesDialogShown = false;
- propertiesDialog->applyPrinterProperties(q->printer());
-
if (q->isOptionEnabled(QPrintDialog::PrintToFile)
&& (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF
propertiesDialog->selectPrinter(QPrinter::PdfFormat, QString());
--
2.15.1

View File

@ -1,97 +0,0 @@
From f9b3ad5f5f6a36e7c45bdfbe61b364dcba70836d Mon Sep 17 00:00:00 2001
From: Andy Shaw <andy.shaw@qt.io>
Date: Wed, 7 Mar 2018 15:12:13 +0100
Subject: [PATCH 3/3] sqlite: Prevent a crash when sqlite does not detect any
parameters
When using a virtual table inside a SQLite database it is possible that
it does not report the right number of parameters. Therefore we need
to account for this case to prevent it from crashing when trying to
bind parameters it thinks does not exist.
Task-number: QTBUG-66816
Change-Id: I3ff70bb1fe73091f43c3df53616f75858e451cfd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
---
src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 5 ++-
tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 41 +++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 444b18686a..08875299b2 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -467,7 +467,10 @@ bool QSQLiteResult::exec()
#if (SQLITE_VERSION_NUMBER >= 3003011)
// In the case of the reuse of a named placeholder
- if (paramCount < values.count()) {
+ // We need to check explicitly that paramCount is greater than 1, as sqlite
+ // can end up in a case where for virtual tables it returns 0 even though it
+ // has parameters
+ if (paramCount > 1 && paramCount < values.count()) {
const auto countIndexes = [](int counter, const QList<int>& indexList) {
return counter + indexList.length();
};
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 1a0340f153..c57dbb8a01 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -172,6 +172,8 @@ private slots:
void emptyTableNavigate();
void timeStampParsing_data() { generic_data(); }
void timeStampParsing();
+ void sqliteVirtualTable_data() { generic_data("QSQLITE"); }
+ void sqliteVirtualTable();
#ifdef NOT_READY_YET
void task_229811();
@@ -4167,5 +4169,44 @@ void tst_QSqlQuery::QTBUG_57138()
QCOMPARE(q.value(2).toDateTime(), tzoffset);
}
+void tst_QSqlQuery::sqliteVirtualTable()
+{
+ // Virtual tables can behave differently when it comes to prepared
+ // queries, so we need to check these explicitly
+ QFETCH(QString, dbName);
+ QSqlDatabase db = QSqlDatabase::database(dbName);
+ CHECK_DATABASE(db);
+ const auto tableName = qTableName("sqliteVirtual", __FILE__, db);
+ QSqlQuery qry(db);
+ QVERIFY_SQL(qry, exec("create virtual table " + tableName + " using fts3(id, name)"));
+
+ // Delibrately malform the query to try and provoke a potential crash situation
+ QVERIFY_SQL(qry, prepare("select * from " + tableName + " where name match '?'"));
+ qry.addBindValue("Andy");
+ QVERIFY(!qry.exec());
+
+ QVERIFY_SQL(qry, prepare("insert into " + tableName + "(id, name) VALUES (?, ?)"));
+ qry.addBindValue(1);
+ qry.addBindValue("Andy");
+ QVERIFY_SQL(qry, exec());
+
+ QVERIFY_SQL(qry, exec("select * from " + tableName));
+ QVERIFY(qry.next());
+ QCOMPARE(qry.value(0).toInt(), 1);
+ QCOMPARE(qry.value(1).toString(), "Andy");
+
+ QVERIFY_SQL(qry, prepare("insert into " + tableName + "(id, name) values (:id, :name)"));
+ qry.bindValue(":id", 2);
+ qry.bindValue(":name", "Peter");
+ QVERIFY_SQL(qry, exec());
+
+ QVERIFY_SQL(qry, prepare("select * from " + tableName + " where name match ?"));
+ qry.addBindValue("Peter");
+ QVERIFY_SQL(qry, exec());
+ QVERIFY(qry.next());
+ QCOMPARE(qry.value(0).toInt(), 2);
+ QCOMPARE(qry.value(1).toString(), "Peter");
+}
+
QTEST_MAIN( tst_QSqlQuery )
#include "tst_qsqlquery.moc"
--
2.16.2

View File

@ -1,127 +0,0 @@
From 49c7939b6b3472af756412324442170d0af5d08f Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 20 Dec 2017 10:41:33 +0100
Subject: [PATCH] Fix custom page size handling in the Unix print dialog
There were several problems that i've fixed in a single commit since they are very interwinded
* The dialog used QPageSize::Custom for two things, the custom sizes coming from
the printer and the "user can write whatever size they want" size. Now only
the printer custom sizes use QPageSize::Custom and we use m_realCustomPageSizeIndex
for the "user can write whatever size they want" one.
* The dialog stored the QPageSize id as the combo userData, that doesn't work
when the printer has multiple custom sizes since they all share QPageSize::Custom
so now it stores the QPageSize itself
Task-number: QTBUG-58733
Change-Id: Ie640a07bb5e24b753db83c091c836e8af4ff126c
---
src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 30 ++++++++++++++--------
src/printsupport/dialogs/qpagesetupdialog_unix_p.h | 1 +
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index 6f3bb0dd55..55ac913df8 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -234,10 +234,14 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
m_printer(0),
m_outputFormat(QPrinter::PdfFormat),
m_units(QPageLayout::Point),
- m_blockSignals(false)
+ m_blockSignals(false),
+ m_realCustomPageSizeIndex(-1)
{
m_ui.setupUi(this);
+ if (!QMetaType::hasRegisteredComparators<QPageSize>())
+ QMetaType::registerEqualsComparator<QPageSize>();
+
QVBoxLayout *lay = new QVBoxLayout(m_ui.preview);
m_pagePreview = new QPagePreview(m_ui.preview);
m_pagePreview->setPagePreviewLayout(1, 1);
@@ -341,15 +345,18 @@ void QPageSetupWidget::initPageSizes()
m_ui.pageSizeCombo->clear();
+ m_realCustomPageSizeIndex = -1;
+
if (m_outputFormat == QPrinter::NativeFormat && !m_printerName.isEmpty()) {
QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get();
if (ps) {
QPrintDevice printDevice = ps->createPrintDevice(m_printerName);
const auto pageSizes = printDevice.supportedPageSizes();
for (const QPageSize &pageSize : pageSizes)
- m_ui.pageSizeCombo->addItem(pageSize.name(), QVariant::fromValue(pageSize.id()));
+ m_ui.pageSizeCombo->addItem(pageSize.name(), QVariant::fromValue(pageSize));
if (m_ui.pageSizeCombo->count() > 0 && printDevice.supportsCustomPageSizes()) {
- m_ui.pageSizeCombo->addItem(tr("Custom"), QVariant::fromValue(QPageSize::Custom));
+ m_ui.pageSizeCombo->addItem(tr("Custom"));
+ m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1;
m_blockSignals = false;
return;
}
@@ -359,10 +366,11 @@ void QPageSetupWidget::initPageSizes()
// If PdfFormat or no available printer page sizes, populate with all page sizes
for (int id = 0; id < QPageSize::LastPageSize; ++id) {
if (QPageSize::PageSizeId(id) == QPageSize::Custom) {
- m_ui.pageSizeCombo->addItem(tr("Custom"), QVariant::fromValue(QPageSize::Custom));
+ m_ui.pageSizeCombo->addItem(tr("Custom"));
+ m_realCustomPageSizeIndex = m_ui.pageSizeCombo->count() - 1;
} else {
QPageSize pageSize = QPageSize(QPageSize::PageSizeId(id));
- m_ui.pageSizeCombo->addItem(pageSize.name(), QVariant::fromValue(pageSize.id()));
+ m_ui.pageSizeCombo->addItem(pageSize.name(), QVariant::fromValue(pageSize));
}
}
@@ -434,7 +442,9 @@ void QPageSetupWidget::updateWidget()
m_ui.unitCombo->setCurrentIndex(m_ui.unitCombo->findData(QVariant::fromValue(m_units)));
- m_ui.pageSizeCombo->setCurrentIndex(m_ui.pageSizeCombo->findData(QVariant::fromValue(m_pageLayout.pageSize().id())));
+ const bool isCustom = m_ui.pageSizeCombo->currentIndex() == m_realCustomPageSizeIndex && m_realCustomPageSizeIndex != -1;
+ if (!isCustom)
+ m_ui.pageSizeCombo->setCurrentIndex(m_ui.pageSizeCombo->findData(QVariant::fromValue(m_pageLayout.pageSize())));
QMarginsF min;
QMarginsF max;
@@ -467,8 +477,6 @@ void QPageSetupWidget::updateWidget()
m_ui.bottomMargin->setMaximum(max.bottom());
m_ui.bottomMargin->setValue(m_pageLayout.margins().bottom());
- bool isCustom = m_ui.pageSizeCombo->currentData().value<QPageSize::PageSizeId>() == QPageSize::Custom;
-
m_ui.pageWidth->setSuffix(suffix);
m_ui.pageWidth->setValue(m_pageLayout.fullRect(m_units).width());
m_ui.pageWidth->setEnabled(isCustom);
@@ -513,10 +521,10 @@ void QPageSetupWidget::pageSizeChanged()
if (m_blockSignals)
return;
- QPageSize::PageSizeId id = m_ui.pageSizeCombo->currentData().value<QPageSize::PageSizeId>();
- if (id != QPageSize::Custom) {
+ if (m_ui.pageSizeCombo->currentIndex() != m_realCustomPageSizeIndex) {
+ const QPageSize pageSize = m_ui.pageSizeCombo->currentData().value<QPageSize>();
// TODO Set layout margin min/max to printer custom min/max
- m_pageLayout.setPageSize(QPageSize(id));
+ m_pageLayout.setPageSize(pageSize);
} else {
QSizeF customSize;
if (m_pageLayout.orientation() == QPageLayout::Landscape)
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
index 574569de29..292cccd7ea 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
@@ -102,6 +102,7 @@ private:
QPageLayout m_pageLayout;
QPageLayout::Unit m_units;
bool m_blockSignals;
+ int m_realCustomPageSizeIndex;
};
QT_END_NAMESPACE
--
2.15.1

View File

@ -1,75 +0,0 @@
From 881690969cc5a6a78df41e2d80ea1fa7bf07cb27 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 12:57:40 +0100
Subject: [PATCH 05/54] Remove QCupsJobWidget::setPrinter
It is only ever called after the constructor so merge the code
Change-Id: I381165ad90c85342e5db3c16327d729388b71fb2
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 3 +--
src/printsupport/widgets/qcupsjobwidget.cpp | 10 +++-------
src/printsupport/widgets/qcupsjobwidget_p.h | 3 +--
3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 6cccdd03cd..8c9997d572 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -251,8 +251,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QAbstractPrint
widget.pageSetup->setPrinter(printer);
#if QT_CONFIG(cupsjobwidget)
- m_jobOptions = new QCupsJobWidget();
- m_jobOptions->setPrinter(printer);
+ m_jobOptions = new QCupsJobWidget(printer);
widget.tabs->addTab(m_jobOptions, tr("Job Options"));
#endif
}
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index 00f2d64df2..8fb07c86b0 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -64,8 +64,9 @@ QT_BEGIN_NAMESPACE
\inmodule QtPrintSupport
*/
-QCupsJobWidget::QCupsJobWidget(QWidget *parent)
- : QWidget(parent)
+QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QWidget *parent)
+ : QWidget(parent),
+ m_printer(printer)
{
m_ui.setupUi(this);
//set all the default values
@@ -80,11 +81,6 @@ QCupsJobWidget::~QCupsJobWidget()
{
}
-void QCupsJobWidget::setPrinter(QPrinter *printer)
-{
- m_printer = printer;
-}
-
void QCupsJobWidget::setupPrinter()
{
QCUPSSupport::setJobHold(m_printer, jobHold(), jobHoldTime());
diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h
index 7d3c15938f..2aca6bc928 100644
--- a/src/printsupport/widgets/qcupsjobwidget_p.h
+++ b/src/printsupport/widgets/qcupsjobwidget_p.h
@@ -71,9 +71,8 @@ class QCupsJobWidget : public QWidget
Q_OBJECT
public:
- explicit QCupsJobWidget(QWidget *parent = 0);
+ explicit QCupsJobWidget(QPrinter *printer, QWidget *parent = nullptr);
~QCupsJobWidget();
- void setPrinter(QPrinter *printer);
void setupPrinter();
private Q_SLOTS:
--
2.15.1

View File

@ -1,136 +0,0 @@
From d7330140190686f805be9fcd1ac968e3768f0754 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Thu, 21 Dec 2017 16:27:02 +0100
Subject: [PATCH 1/1] CUPS: Refactor the code a bit
Move the selected and selDescription members to a subclass of QOptionTreeItem
since it's only ever used for Option type nodes of the tree
Change-Id: Ic99841c4e04a3afcff0950f72abf12977850f6d3
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 44 ++++++++++++++++----------
1 file changed, 28 insertions(+), 16 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 22076bf..6a7e679 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -247,8 +247,6 @@ public:
index(i),
ptr(p),
description(desc),
- selected(-1),
- selDescription(nullptr),
parentItem(pi) {}
~QOptionTreeItem() {
@@ -259,12 +257,22 @@ public:
int index;
const void *ptr;
const char *description;
- int selected;
- const char *selDescription;
QOptionTreeItem *parentItem;
QList<QOptionTreeItem*> childItems;
};
+class QOptionTreeItemOption : public QOptionTreeItem
+{
+public:
+ QOptionTreeItemOption (int i, const void *p, const char *desc, QOptionTreeItem *pi)
+ : QOptionTreeItem(Option, i, p, desc, pi)
+ {
+ }
+
+ int selected;
+ const char *selDescription;
+};
+
class QPPDOptionsModel : public QAbstractItemModel
{
Q_OBJECT
@@ -285,7 +293,7 @@ public:
QOptionTreeItem *rootItem;
void parseGroups(QOptionTreeItem *parent);
void parseOptions(QOptionTreeItem *parent);
- void parseChoices(QOptionTreeItem *parent);
+ void parseChoices(QOptionTreeItemOption *parent);
};
class QPPDOptionsEditor : public QStyledItemDelegate
@@ -387,10 +395,11 @@ void QPrintPropertiesDialog::setCupsOptionsFromItems(QOptionTreeItem *parent) co
{
for (QOptionTreeItem *itm : qAsConst(parent->childItems)) {
if (itm->type == QOptionTreeItem::Option) {
+ QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
- if (qstrcmp(opt->defchoice, opt->choices[itm->selected].choice) != 0) {
+ if (qstrcmp(opt->defchoice, opt->choices[itmOption->selected].choice) != 0) {
QStringList cupsOptions = QCUPSSupport::cupsOptionsList(m_printer);
- QCUPSSupport::setCupsOption(cupsOptions, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itm->selected].choice));
+ QCUPSSupport::setCupsOption(cupsOptions, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itmOption->selected].choice));
QCUPSSupport::setCupsOptions(m_printer, cupsOptions);
}
} else {
@@ -1153,12 +1162,15 @@ QVariant QPPDOptionsModel::data(const QModelIndex &index, int role) const
break;
case Qt::DisplayRole: {
- if (index.column() == 0)
+ if (index.column() == 0) {
return cupsCodec->toUnicode(itm->description);
- else if (itm->type == QOptionTreeItem::Option && itm->selected > -1)
- return cupsCodec->toUnicode(itm->selDescription);
- else
- return QVariant();
+ } else if (itm->type == QOptionTreeItem::Option) {
+ QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
+ if (itmOption->selected > -1)
+ return cupsCodec->toUnicode(itmOption->selDescription);
+ }
+
+ return QVariant();
}
break;
@@ -1240,14 +1252,14 @@ void QPPDOptionsModel::parseOptions(QOptionTreeItem *parent)
const ppd_group_t *group = static_cast<const ppd_group_t*>(parent->ptr);
for (int i = 0; i < group->num_options; ++i) {
if (!isBlacklistedOption(group->options[i].keyword)) {
- QOptionTreeItem *opt = new QOptionTreeItem(QOptionTreeItem::Option, i, &group->options[i], group->options[i].text, parent);
+ QOptionTreeItemOption *opt = new QOptionTreeItemOption(i, &group->options[i], group->options[i].text, parent);
parent->childItems.append(opt);
parseChoices(opt);
}
}
}
-void QPPDOptionsModel::parseChoices(QOptionTreeItem *parent)
+void QPPDOptionsModel::parseChoices(QOptionTreeItemOption *parent)
{
const ppd_option_t *option = static_cast<const ppd_option_t*>(parent->ptr);
bool marked = false;
@@ -1307,7 +1319,7 @@ void QPPDOptionsEditor::setEditorData(QWidget *editor, const QModelIndex &index)
return;
QComboBox *cb = static_cast<QComboBox*>(editor);
- QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
+ QOptionTreeItemOption *itm = static_cast<QOptionTreeItemOption*>(index.internalPointer());
if (itm->selected == -1)
cb->addItem(QString());
@@ -1323,7 +1335,7 @@ void QPPDOptionsEditor::setEditorData(QWidget *editor, const QModelIndex &index)
void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QComboBox *cb = static_cast<QComboBox*>(editor);
- QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
+ QOptionTreeItemOption *itm = static_cast<QOptionTreeItemOption*>(index.internalPointer());
if (itm->selected == cb->currentIndex())
return;
--
2.7.4

View File

@ -1,91 +0,0 @@
From 072dd59de771d0c942afd68260251be71bd59542 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 13:05:02 +0100
Subject: [PATCH 06/54] Remove QPrintPropertiesDialog::selectPrinter
It is only ever called after the constructor, so merge the code
Change-Id: I5c75a2cd367af401b41920f51754a64dc6c6eb40
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 30 +++++++++++++-------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 8c9997d572..c7f7488917 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -124,11 +124,10 @@ class QPrintPropertiesDialog : public QDialog
{
Q_OBJECT
public:
- QPrintPropertiesDialog(QPrinter *printer, QAbstractPrintDialog *parent = nullptr);
+ QPrintPropertiesDialog(QPrinter *printer, QPrinter::OutputFormat outputFormat,
+ const QString &printerName, QAbstractPrintDialog *parent = nullptr);
~QPrintPropertiesDialog();
- void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName);
-
void setupPrinter() const;
private:
@@ -234,7 +233,8 @@ public:
*/
-QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QAbstractPrintDialog *parent)
+QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrinter::OutputFormat outputFormat,
+ const QString &printerName, QAbstractPrintDialog *parent)
: QDialog(parent)
{
setWindowTitle(tr("Printer Properties"));
@@ -249,6 +249,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QAbstractPrint
connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
widget.pageSetup->setPrinter(printer);
+ widget.pageSetup->selectPrinter(outputFormat, printerName);
#if QT_CONFIG(cupsjobwidget)
m_jobOptions = new QCupsJobWidget(printer);
@@ -268,11 +269,6 @@ void QPrintPropertiesDialog::setupPrinter() const
#endif
}
-void QPrintPropertiesDialog::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName)
-{
- widget.pageSetup->selectPrinter(outputFormat, printerName);
-}
-
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -838,16 +834,20 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties()
if (propertiesDialog)
delete propertiesDialog;
- propertiesDialog = new QPrintPropertiesDialog(q->printer(), q);
- propertiesDialog->setResult(QDialog::Rejected);
- propertiesDialogShown = false;
+ QPrinter::OutputFormat outputFormat;
+ QString printerName;
if (q->isOptionEnabled(QPrintDialog::PrintToFile)
&& (widget.printers->currentIndex() == widget.printers->count() - 1)) {// PDF
- propertiesDialog->selectPrinter(QPrinter::PdfFormat, QString());
+ outputFormat = QPrinter::PdfFormat;
+ } else {
+ outputFormat = QPrinter::NativeFormat;
+ printerName = widget.printers->currentText();
}
- else
- propertiesDialog->selectPrinter(QPrinter::NativeFormat, widget.printers->currentText());
+
+ propertiesDialog = new QPrintPropertiesDialog(q->printer(), outputFormat, printerName, q);
+ propertiesDialog->setResult(QDialog::Rejected);
+ propertiesDialogShown = false;
}
void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
--
2.15.1

View File

@ -1,211 +0,0 @@
From 030d815eb8c5b6506178141da391594482c2e733 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Thu, 28 Dec 2017 14:46:32 +0100
Subject: [PATCH] Refactor QPPDOptionsModel a bit
Make the members private and add getters
Make some other functions also private
Move setCupsOptionsFromItems from QPrintPropertiesDialog to QPPDOptionsModel
Change-Id: Ibb555a6e6be53550f30c159c3ad611d55e2a767a
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 95 ++++++++++++++++----------
1 file changed, 59 insertions(+), 36 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 63d23cc..a9745d7 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -288,12 +288,21 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
- QPrintDevice *m_currentPrintDevice;
- QTextCodec *cupsCodec;
- QOptionTreeItem *rootItem;
+ void setCupsOptionsFromItems(QPrinter *printer) const;
+
+ QPrintDevice *currentPrintDevice() const;
+ QTextCodec *cupsCodec() const;
+
+private:
void parseGroups(QOptionTreeItem *parent);
void parseOptions(QOptionTreeItem *parent);
void parseChoices(QOptionTreeItemOption *parent);
+
+ void setCupsOptionsFromItems(QPrinter *printer, QOptionTreeItem *parent) const;
+
+ QPrintDevice *m_currentPrintDevice;
+ QTextCodec *m_cupsCodec;
+ QOptionTreeItem *m_rootItem;
};
class QPPDOptionsEditor : public QStyledItemDelegate
@@ -380,7 +389,7 @@ void QPrintPropertiesDialog::setupPrinter() const
#endif
#if QT_CONFIG(cups)
- setCupsOptionsFromItems(m_cupsOptionsModel->rootItem);
+ m_cupsOptionsModel->setCupsOptionsFromItems(m_printer);
#endif
}
@@ -390,25 +399,6 @@ void QPrintPropertiesDialog::showEvent(QShowEvent *event)
QDialog::showEvent(event);
}
-#if QT_CONFIG(cups)
-void QPrintPropertiesDialog::setCupsOptionsFromItems(QOptionTreeItem *parent) const
-{
- for (QOptionTreeItem *itm : qAsConst(parent->childItems)) {
- if (itm->type == QOptionTreeItem::Option) {
- QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
- const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
- if (qstrcmp(opt->defchoice, opt->choices[itmOption->selected].choice) != 0) {
- QStringList cupsOptions = QCUPSSupport::cupsOptionsList(m_printer);
- QCUPSSupport::setCupsOption(cupsOptions, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itmOption->selected].choice));
- QCUPSSupport::setCupsOptions(m_printer, cupsOptions);
- }
- } else {
- setCupsOptionsFromItems(itm);
- }
- }
-}
-#endif
-
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -1107,22 +1097,23 @@ void QUnixPrintWidget::updatePrinter()
QPPDOptionsModel::QPPDOptionsModel(QPrintDevice *currentPrintDevice, QObject *parent)
: QAbstractItemModel(parent)
, m_currentPrintDevice(currentPrintDevice)
+ , m_cupsCodec(nullptr)
{
ppd_file_t *ppd = m_currentPrintDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
- rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
+ m_rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
if (ppd) {
- cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
+ m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
for (int i = 0; i < ppd->num_groups; ++i) {
- QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], ppd->groups[i].text, rootItem);
- rootItem->childItems.append(group);
+ QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], ppd->groups[i].text, m_rootItem);
+ m_rootItem->childItems.append(group);
parseGroups(group); // parse possible subgroups
parseOptions(group); // parse options
}
}
- if (!cupsCodec)
- cupsCodec = QTextCodec::codecForLocale();
+ if (!m_cupsCodec)
+ m_cupsCodec = QTextCodec::codecForLocale();
}
int QPPDOptionsModel::columnCount(const QModelIndex &) const
@@ -1134,7 +1125,7 @@ int QPPDOptionsModel::rowCount(const QModelIndex &parent) const
{
QOptionTreeItem *itm;
if (!parent.isValid())
- itm = rootItem;
+ itm = m_rootItem;
else
itm = static_cast<QOptionTreeItem*>(parent.internalPointer());
@@ -1164,11 +1155,11 @@ QVariant QPPDOptionsModel::data(const QModelIndex &index, int role) const
case Qt::DisplayRole: {
if (index.column() == 0) {
- return cupsCodec->toUnicode(itm->description);
+ return m_cupsCodec->toUnicode(itm->description);
} else if (itm->type == QOptionTreeItem::Option) {
QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
if (itmOption->selected > -1)
- return cupsCodec->toUnicode(itmOption->selDescription);
+ return m_cupsCodec->toUnicode(itmOption->selDescription);
}
return QVariant();
@@ -1184,7 +1175,7 @@ QModelIndex QPPDOptionsModel::index(int row, int column, const QModelIndex &pare
{
QOptionTreeItem *itm;
if (!parent.isValid())
- itm = rootItem;
+ itm = m_rootItem;
else
itm = static_cast<QOptionTreeItem*>(parent.internalPointer());
@@ -1199,7 +1190,7 @@ QModelIndex QPPDOptionsModel::parent(const QModelIndex &index) const
QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
- if (itm->parentItem && itm->parentItem != rootItem)
+ if (itm->parentItem && itm->parentItem != m_rootItem)
return createIndex(itm->parentItem->index, 0, itm->parentItem);
return QModelIndex();
@@ -1216,6 +1207,38 @@ Qt::ItemFlags QPPDOptionsModel::flags(const QModelIndex &index) const
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
+QPrintDevice *QPPDOptionsModel::currentPrintDevice() const
+{
+ return m_currentPrintDevice;
+}
+
+QTextCodec *QPPDOptionsModel::cupsCodec() const
+{
+ return m_cupsCodec;
+}
+
+void QPPDOptionsModel::setCupsOptionsFromItems(QPrinter *printer) const
+{
+ setCupsOptionsFromItems(printer, m_rootItem);
+}
+
+void QPPDOptionsModel::setCupsOptionsFromItems(QPrinter *printer, QOptionTreeItem *parent) const
+{
+ for (QOptionTreeItem *itm : qAsConst(parent->childItems)) {
+ if (itm->type == QOptionTreeItem::Option) {
+ QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
+ const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
+ if (qstrcmp(opt->defchoice, opt->choices[itmOption->selected].choice) != 0) {
+ QStringList cupsOptions = QCUPSSupport::cupsOptionsList(printer);
+ QCUPSSupport::setCupsOption(cupsOptions, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itmOption->selected].choice));
+ QCUPSSupport::setCupsOptions(printer, cupsOptions);
+ }
+ } else {
+ setCupsOptionsFromItems(printer, itm);
+ }
+ }
+}
+
void QPPDOptionsModel::parseGroups(QOptionTreeItem *parent)
{
const ppd_group_t *group = static_cast<const ppd_group_t*>(parent->ptr);
@@ -1327,7 +1350,7 @@ void QPPDOptionsEditor::setEditorData(QWidget *editor, const QModelIndex &index)
const QPPDOptionsModel *m = static_cast<const QPPDOptionsModel*>(index.model());
for (auto *childItem : qAsConst(itm->childItems))
- cb->addItem(m->cupsCodec->toUnicode(childItem->description));
+ cb->addItem(m->cupsCodec()->toUnicode(childItem->description));
if (itm->selected > -1)
cb->setCurrentIndex(itm->selected);
@@ -1345,7 +1368,7 @@ void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model,
QPPDOptionsModel *m = static_cast<QPPDOptionsModel*>(model);
const auto values = QStringList{} << QString::fromLatin1(opt->keyword) << QString::fromLatin1(opt->choices[cb->currentIndex()].choice);
- if (m->m_currentPrintDevice->setProperty(PDPK_PpdOption, values)) {
+ if (m->currentPrintDevice()->setProperty(PDPK_PpdOption, values)) {
itm->selected = cb->currentIndex();
itm->selDescription = static_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
}
--
2.7.4

View File

@ -1,83 +0,0 @@
From ceccdff4e9fc93819d819b8ed15d95822f980505 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 13:10:17 +0100
Subject: [PATCH 07/54] Remove QPageSetupWidget::selectPrinter
t's only ever called after setPrinter so merge the code
Change-Id: I4b5d593edbe62b64354e81c19112fa87b0555fdc
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 12 ++----------
src/printsupport/dialogs/qpagesetupdialog_unix_p.h | 3 +--
src/printsupport/dialogs/qprintdialog_unix.cpp | 3 +--
3 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index c321552a19..49c0184289 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -210,7 +210,7 @@ void QUnixPageSetupDialogPrivate::init()
Q_Q(QPageSetupDialog);
widget = new QPageSetupWidget(q);
- widget->setPrinter(printer);
+ widget->setPrinter(printer, printer->outputFormat(), printer->printerName());
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel,
@@ -371,7 +371,7 @@ void QPageSetupWidget::initPageSizes()
// Set the dialog to use the given QPrinter
// Usually only called on first creation
-void QPageSetupWidget::setPrinter(QPrinter *printer)
+void QPageSetupWidget::setPrinter(QPrinter *printer, QPrinter::OutputFormat outputFormat, const QString &printerName)
{
m_printer = printer;
@@ -387,14 +387,6 @@ void QPageSetupWidget::setPrinter(QPrinter *printer)
m_units = m_pageLayout.units();
m_pagePreview->setPageLayout(m_pageLayout);
- // Then update the widget with the current printer details
- selectPrinter(m_printer->outputFormat(), m_printer->printerName());
-}
-
-// The printer selected in the QPrintDialog has been changed, update the widget to reflect this
-// Note the QPrinter is not updated at this time in case the user presses the Cancel button in QPrintDialog
-void QPageSetupWidget::selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName)
-{
m_outputFormat = outputFormat;
m_printerName = printerName;
initPageSizes();
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
index 658f103bea..c57b01c2d6 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
@@ -72,8 +72,7 @@ public:
explicit QPageSetupWidget(QWidget *parent = 0);
explicit QPageSetupWidget(QPrinter *printer, QWidget *parent = 0);
- void setPrinter(QPrinter *printer);
- void selectPrinter(QPrinter::OutputFormat outputFormat, const QString &printerName);
+ void setPrinter(QPrinter *printer, QPrinter::OutputFormat outputFormat, const QString &printerName);
void setupPrinter() const;
private slots:
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index c7f7488917..f87630f1a0 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -248,8 +248,7 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrinter::Outp
connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
- widget.pageSetup->setPrinter(printer);
- widget.pageSetup->selectPrinter(outputFormat, printerName);
+ widget.pageSetup->setPrinter(printer, outputFormat, printerName);
#if QT_CONFIG(cupsjobwidget)
m_jobOptions = new QCupsJobWidget(printer);
--
2.15.1

View File

@ -1,110 +0,0 @@
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

View File

@ -1,113 +0,0 @@
From 70f6a35c8f0b6a73f4d568532e1365cd3e8ff8dd Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 13:23:49 +0100
Subject: [PATCH 37/54] Introduce QPrintDevice::property/setProperty
So we can access QPlatformPrintDevice internals if needed
Change-Id: Ib37c5717713f37262ef12d7b61793d80f05baf4a
Reviewed-by: Liang Qi <liang.qi@qt.io>
---
src/printsupport/kernel/qplatformprintdevice.cpp | 15 +++++++++++++++
src/printsupport/kernel/qplatformprintdevice.h | 6 ++++++
src/printsupport/kernel/qprintdevice.cpp | 10 ++++++++++
src/printsupport/kernel/qprintdevice_p.h | 7 +++++++
4 files changed, 38 insertions(+)
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
index e2d4a08de3..ad3f923bec 100644
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
@@ -381,6 +381,21 @@ void QPlatformPrintDevice::loadMimeTypes() const
{
}
+QVariant QPlatformPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) const
+{
+ Q_UNUSED(key)
+
+ return QVariant();
+}
+
+bool QPlatformPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
+{
+ Q_UNUSED(key)
+ Q_UNUSED(value)
+
+ return false;
+}
+
QList<QMimeType> QPlatformPrintDevice::supportedMimeTypes() const
{
if (!m_haveMimeTypes)
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
index 44a3a966f4..654bb123fb 100644
--- a/src/printsupport/kernel/qplatformprintdevice.h
+++ b/src/printsupport/kernel/qplatformprintdevice.h
@@ -53,11 +53,14 @@
#include <QtPrintSupport/qtprintsupportglobal.h>
#include <private/qprint_p.h>
+#include <private/qprintdevice_p.h>
+#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
#include <QtCore/qmimetype.h>
#include <QtGui/qpagelayout.h>
+
QT_BEGIN_NAMESPACE
#ifndef QT_NO_PRINTER
@@ -118,6 +121,9 @@ public:
virtual QPrint::ColorMode defaultColorMode() const;
virtual QList<QPrint::ColorMode> supportedColorModes() const;
+ virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const;
+ virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value);
+
#ifndef QT_NO_MIMETYPE
virtual QList<QMimeType> supportedMimeTypes() const;
#endif
diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp
index 26799a6f13..7096f5a2f6 100644
--- a/src/printsupport/kernel/qprintdevice.cpp
+++ b/src/printsupport/kernel/qprintdevice.cpp
@@ -245,6 +245,16 @@ QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>();
}
+QVariant QPrintDevice::property(PrintDevicePropertyKey key) const
+{
+ return isValid() ? d->property(key) : QVariant();
+}
+
+bool QPrintDevice::setProperty(PrintDevicePropertyKey key, const QVariant &value)
+{
+ return isValid() ? d->setProperty(key, value) : false;
+}
+
#ifndef QT_NO_MIMETYPE
QList<QMimeType> QPrintDevice::supportedMimeTypes() const
{
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
index 1e0d3983e9..1a26d3afcf 100644
--- a/src/printsupport/kernel/qprintdevice_p.h
+++ b/src/printsupport/kernel/qprintdevice_p.h
@@ -131,6 +131,13 @@ public:
QPrint::ColorMode defaultColorMode() const;
QList<QPrint::ColorMode> supportedColorModes() const;
+ enum PrintDevicePropertyKey {
+ PDPK_CustomBase = 0xff00
+ };
+
+ QVariant property(PrintDevicePropertyKey key) const;
+ bool setProperty(PrintDevicePropertyKey key, const QVariant &value);
+
#ifndef QT_NO_MIMETYPE
QList<QMimeType> supportedMimeTypes() const;
#endif
--
2.15.1

View File

@ -1,97 +0,0 @@
From e79efe94e3e77ee035ff7d046158a577759f8c7c Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Mon, 4 Dec 2017 14:05:55 +0100
Subject: [PATCH 38/54] Allow access to ppd file and ppdMarkOption via
QPpdPrintDevice::property/setProperty
Change-Id: I47b49b52121950fa8e3ea7a056974d9f3033490f
Reviewed-by: Liang Qi <liang.qi@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 21 +++++++++++++++++++++
src/plugins/printsupport/cups/qppdprintdevice.h | 3 +++
src/printsupport/kernel/qcups_p.h | 3 +++
src/printsupport/kernel/qprint_p.h | 1 +
4 files changed, 28 insertions(+)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 9efa83d409..ad829df23d 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -42,6 +42,8 @@
#include <QtCore/QMimeDatabase>
#include <qdebug.h>
+#include "private/qcups_p.h" // Only needed for PDPK_*
+
#ifndef QT_LINUXBASE // LSB merges everything into cups.h
#include <cups/language.h>
#endif
@@ -421,6 +423,25 @@ QPrint::ColorMode QPpdPrintDevice::defaultColorMode() const
return QPrint::GrayScale;
}
+QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) const
+{
+ if (key == PDPK_PpdFile)
+ return QVariant::fromValue<ppd_file_t *>(m_ppd);
+
+ return QVariant();
+}
+
+bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
+{
+ if (key == PDPK_PpdOption) {
+ const QStringList values = value.toStringList();
+ if (values.count() == 2)
+ return ppdMarkOption(m_ppd, values[0].toLatin1(), values[1].toLatin1()) == 0;
+ }
+
+ return false;
+}
+
#ifndef QT_NO_MIMETYPE
void QPpdPrintDevice::loadMimeTypes() const
{
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 3cd7518b14..2e4dd3ab3b 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -89,6 +89,9 @@ public:
QPrint::ColorMode defaultColorMode() const Q_DECL_OVERRIDE;
+ QVariant property(QPrintDevice::PrintDevicePropertyKey key) const Q_DECL_OVERRIDE;
+ bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value) Q_DECL_OVERRIDE;
+
protected:
void loadPageSizes() const Q_DECL_OVERRIDE;
void loadResolutions() const Q_DECL_OVERRIDE;
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index 780115e350..b67390c4ed 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -67,6 +67,9 @@ QT_BEGIN_NAMESPACE
// removed from the dialogs.
#define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00)
+#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
+#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
+
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{
public:
diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h
index 280c2d7608..4956775461 100644
--- a/src/printsupport/kernel/qprint_p.h
+++ b/src/printsupport/kernel/qprint_p.h
@@ -59,6 +59,7 @@
#if (defined Q_OS_MACOS) || (defined Q_OS_UNIX && QT_CONFIG(cups))
#include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module
+Q_DECLARE_METATYPE(ppd_file_t *)
#endif
QT_BEGIN_NAMESPACE
--
2.15.1

View File

@ -1,290 +0,0 @@
From 5e2f583a67c75c1c03e213467bb56207e5084279 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Thu, 21 Dec 2017 16:55:42 +0100
Subject: [PATCH] CUPS: Fix conflict handling
The previous code assumed that ppdMarkOption returning non zero (i.e. it has conflicts)
also meant that the option wasn't applied at the ppd level, but it actually is.
What we need to do is after calling ppdMarkOption parse the tree again looking
to see if any option is conflicting and mark it as such in the UI.
Change-Id: I836f1902d14dc8c176bb06776471cbf4ed11786f
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 6 +-
src/printsupport/dialogs/qprintdialog_unix.cpp | 101 ++++++++++++++++++++-
src/printsupport/dialogs/qprintpropertieswidget.ui | 65 +++++++++++--
3 files changed, 160 insertions(+), 12 deletions(-)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 8aed8c5..9c4b699 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -443,8 +443,10 @@ bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, cons
{
if (key == PDPK_PpdOption) {
const QStringList values = value.toStringList();
- if (values.count() == 2)
- return ppdMarkOption(m_ppd, values[0].toLatin1(), values[1].toLatin1()) == 0;
+ if (values.count() == 2) {
+ ppdMarkOption(m_ppd, values[0].toLatin1(), values[1].toLatin1());
+ return true;
+ }
}
return false;
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 3b1c492..fcb53f4 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -141,6 +141,7 @@ public:
private slots:
void reject() override;
+ void accept() override;
private:
friend class QUnixPrintWidgetPrivate;
@@ -298,6 +299,12 @@ public:
QPrintDevice *currentPrintDevice() const;
QTextCodec *cupsCodec() const;
+ void emitConflictsChanged();
+ bool hasConflicts() const;
+
+signals:
+ void hasConflictsChanged(bool conflicts);
+
private:
void parseGroups(QOptionTreeItem *parent);
void parseOptions(QOptionTreeItem *parent);
@@ -305,6 +312,8 @@ private:
void setCupsOptionsFromItems(QPrinter *printer, QOptionTreeItem *parent) const;
void reject(QOptionTreeItem *item);
+ void emitDataChanged(QOptionTreeItem *item, const QModelIndex &itemIndex, bool *conflictsFound);
+ bool hasConflicts(QOptionTreeItem *item) const;
QPrintDevice *m_currentPrintDevice;
QTextCodec *m_cupsCodec;
@@ -377,6 +386,9 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *
widget.treeView->setModel(nullptr);
widget.tabs->setTabEnabled(advancedTabIndex, false);
}
+
+ widget.conflictsLabel->setVisible(m_cupsOptionsModel->hasConflicts());
+ connect(m_cupsOptionsModel, &QPPDOptionsModel::hasConflictsChanged, widget.conflictsLabel, &QLabel::setVisible);
#else
Q_UNUSED(currentPrintDevice)
widget.tabs->setTabEnabled(advancedTabIndex, false);
@@ -413,6 +425,21 @@ void QPrintPropertiesDialog::reject()
QDialog::reject();
}
+void QPrintPropertiesDialog::accept()
+{
+#if QT_CONFIG(cups)
+ if (m_cupsOptionsModel->hasConflicts()) {
+ widget.tabs->setCurrentWidget(widget.cupsPropertiesPage);
+ const QMessageBox::StandardButton answer = QMessageBox::warning(this, tr("Advanced option conflicts"),
+ tr("There are conflicts in some advanced options. Do you want to fix them?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ if (answer != QMessageBox::No)
+ return;
+ }
+#endif
+ QDialog::accept();
+}
+
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -1180,6 +1207,22 @@ QVariant QPPDOptionsModel::data(const QModelIndex &index, int role) const
}
break;
+ case Qt::DecorationRole: {
+ if (itm->type == QOptionTreeItem::Option && index.column() == 1) {
+ const ppd_option_t *option = static_cast<const ppd_option_t*>(itm->ptr);
+ if (option->conflicted) {
+ const QIcon warning = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, nullptr);
+ if (!warning.isNull())
+ return warning;
+
+ qWarning() << "Current application style returned a null icon for SP_MessageBoxWarning.";
+ return QColor(Qt::red);
+ }
+ }
+ return QVariant();
+ }
+ break;
+
}
return QVariant();
@@ -1316,6 +1359,55 @@ void QPPDOptionsModel::parseChoices(QOptionTreeItemOption *parent)
}
}
+bool QPPDOptionsModel::hasConflicts() const
+{
+ return hasConflicts(m_rootItem);
+}
+
+bool QPPDOptionsModel::hasConflicts(QOptionTreeItem *item) const
+{
+ if (item->type == QOptionTreeItem::Option) {
+ const ppd_option_t *option = static_cast<const ppd_option_t*>(item->ptr);
+ return option->conflicted;
+ }
+
+ for (QOptionTreeItem *child : qAsConst(item->childItems)) {
+ if (hasConflicts(child))
+ return true;
+ }
+
+ return false;
+}
+
+void QPPDOptionsModel::emitConflictsChanged()
+{
+ bool conflictsFound = false;
+ emitDataChanged(m_rootItem, QModelIndex(), &conflictsFound);
+
+ emit hasConflictsChanged(conflictsFound);
+}
+
+void QPPDOptionsModel::emitDataChanged(QOptionTreeItem *item, const QModelIndex &itemIndex, bool *conflictsFound)
+{
+ if (item->type == QOptionTreeItem::Option) {
+ // We just emit DecorationRole dataChanged for all the leaves
+ // and let the view requery the value
+ const QModelIndex secondColItem = index(itemIndex.row(), 1, itemIndex.parent());
+ emit dataChanged(secondColItem, secondColItem, QVector<int>() << Qt::DecorationRole);
+
+ if (conflictsFound && *conflictsFound == false) {
+ const ppd_option_t *option = static_cast<const ppd_option_t*>(item->ptr);
+ if (option->conflicted && conflictsFound)
+ *conflictsFound = true;
+ }
+ }
+
+ for (int i = 0; i < item->childItems.count(); ++i) {
+ QOptionTreeItem *child = item->childItems.at(i);
+ emitDataChanged(child, index(i, 0, itemIndex), conflictsFound);
+ }
+}
+
QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) const
{
if (role != Qt::DisplayRole)
@@ -1404,10 +1496,11 @@ void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model,
QPPDOptionsModel *m = static_cast<QPPDOptionsModel*>(model);
const auto values = QStringList{} << QString::fromLatin1(opt->keyword) << QString::fromLatin1(opt->choices[cb->currentIndex()].choice);
- if (m->currentPrintDevice()->setProperty(PDPK_PpdOption, values)) {
- itm->selected = cb->currentIndex();
- itm->selDescription = static_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
- }
+ m->currentPrintDevice()->setProperty(PDPK_PpdOption, values);
+ itm->selected = cb->currentIndex();
+ itm->selDescription = static_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
+
+ m->emitConflictsChanged();
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/src/printsupport/dialogs/qprintpropertieswidget.ui b/src/printsupport/dialogs/qprintpropertieswidget.ui
index 0e56fb3..d8e5261 100644
--- a/src/printsupport/dialogs/qprintpropertieswidget.ui
+++ b/src/printsupport/dialogs/qprintpropertieswidget.ui
@@ -14,7 +14,16 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -32,18 +41,62 @@
</item>
</layout>
</widget>
- <widget class="QWidget" name="cupsPropertiesPage" >
- <attribute name="title" >
+ <widget class="QWidget" name="cupsPropertiesPage">
+ <attribute name="title">
<string>Advanced</string>
</attribute>
- <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QTreeView" name="treeView" >
- <property name="alternatingRowColors" >
+ <widget class="QTreeView" name="treeView">
+ <property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="conflictsLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>165</red>
+ <green>167</green>
+ <blue>169</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="text">
+ <string>There are conflicts in some options. Please fix them.</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>
--
2.7.4

View File

@ -1,118 +0,0 @@
From 83538a360e246ac2242977015e4a374a9f0e21b8 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 6 Dec 2017 11:28:55 +0100
Subject: [PATCH] CUPS: Use printer job-sheets as default instead of none,none
This also reads the job-sheets from lpoptions if set there for the particular printer
Change-Id: I35aff103261ef58492779071d866e8a15ac78607
Reviewed-by: Laurent Montel <laurent.montel@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 ++
src/printsupport/kernel/qcups.cpp | 26 +++++++++++++++++++++++
src/printsupport/kernel/qcups_p.h | 8 +++++++
src/printsupport/widgets/qcupsjobwidget.cpp | 11 ++++++++--
4 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 56976a6..e11d301 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -429,6 +429,8 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
return QVariant::fromValue<ppd_file_t *>(m_ppd);
else if (key == PDPK_CupsJobPriority)
return printerOption(QStringLiteral("job-priority"));
+ else if (key == PDPK_CupsJobSheets)
+ return printerOption(QStringLiteral("job-sheets"));
return QVariant();
}
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index b9e162a..aa1cdff 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -150,6 +150,32 @@ static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPa
return QString();
}
+static inline QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage)
+{
+ if (bannerPage == QLatin1String("none")) return QCUPSSupport::NoBanner;
+ else if (bannerPage == QLatin1String("standard")) return QCUPSSupport::Standard;
+ else if (bannerPage == QLatin1String("unclassified")) return QCUPSSupport::Unclassified;
+ else if (bannerPage == QLatin1String("confidential")) return QCUPSSupport::Confidential;
+ else if (bannerPage == QLatin1String("classified")) return QCUPSSupport::Classified;
+ else if (bannerPage == QLatin1String("secret")) return QCUPSSupport::Secret;
+ else if (bannerPage == QLatin1String("topsecret")) return QCUPSSupport::TopSecret;
+
+ return QCUPSSupport::NoBanner;
+}
+
+QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets)
+{
+ JobSheets result;
+
+ const QStringList parts = jobSheets.split(QLatin1Char(','));
+ if (parts.count() == 2) {
+ result.startBannerPage = stringToBannerPage(parts[0]);
+ result.endBannerPage = stringToBannerPage(parts[1]);
+ }
+
+ return result;
+}
+
void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage)
{
QStringList cupsOptions = cupsOptionsList(printer);
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index 3abccf2..906a548 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE
#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
+#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3)
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{
@@ -139,6 +140,13 @@ public:
static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
const PagesPerSheetLayout pagesPerSheetLayout);
static void setPageRange(QPrinter *printer, int pageFrom, int pageTo);
+
+ struct JobSheets
+ {
+ BannerPage startBannerPage = QCUPSSupport::NoBanner;
+ BannerPage endBannerPage = QCUPSSupport::NoBanner;
+ };
+ static JobSheets parseJobSheets(const QString &jobSheets);
};
Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE);
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index f21e229..4535f75 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -196,8 +196,15 @@ void QCupsJobWidget::initBannerPages()
m_ui.endBannerPageCombo->addItem(tr("Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::Secret));
m_ui.endBannerPageCombo->addItem(tr("Top Secret", "CUPS Banner page"), QVariant::fromValue(QCUPSSupport::TopSecret));
- setStartBannerPage(QCUPSSupport::NoBanner);
- setEndBannerPage(QCUPSSupport::NoBanner);
+ QCUPSSupport::JobSheets jobSheets;
+
+ if (m_printDevice) {
+ const QString jobSheetsString = m_printDevice->property(PDPK_CupsJobSheets).toString();
+ jobSheets = QCUPSSupport::parseJobSheets(jobSheetsString);
+ }
+
+ setStartBannerPage(jobSheets.startBannerPage);
+ setEndBannerPage(jobSheets.endBannerPage);
}
void QCupsJobWidget::setStartBannerPage(const QCUPSSupport::BannerPage bannerPage)
--
2.7.4

View File

@ -1,240 +0,0 @@
From 5cb54cb5ebae99fab121061e25e26eec3056203a Mon Sep 17 00:00:00 2001
From: Marc Mutz <marc.mutz@kdab.com>
Date: Tue, 12 Dec 2017 12:44:02 +0100
Subject: [PATCH 44/54] QPlatformPrintDevice: use QVector, not QList in the API
QPlaformPrintDevice uses QVector to store, but QList in the getters to
retrieve these data. Port API from QList to QVector to avoid
conversion between the two containers on every access.
Saves almost 4KiB in text size (another 0.9% of QtPrintSupport).
Change-Id: If33df141b87753803c45d9f4dae501a68abe49af
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
---
src/printsupport/kernel/qplatformprintdevice.cpp | 16 ++++++++--------
src/printsupport/kernel/qplatformprintdevice.h | 8 ++++----
src/printsupport/kernel/qprintdevice.cpp | 16 ++++++++--------
src/printsupport/kernel/qprintdevice_p.h | 8 ++++----
src/printsupport/kernel/qprintengine_win.cpp | 8 ++++----
src/printsupport/kernel/qprinterinfo.cpp | 2 +-
6 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
index 82bddedb1b..2f76156a91 100644
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
@@ -313,11 +313,11 @@ QPrint::InputSlot QPlatformPrintDevice::defaultInputSlot() const
return input;
}
-QList<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const
+QVector<QPrint::InputSlot> QPlatformPrintDevice::supportedInputSlots() const
{
if (!m_haveInputSlots)
loadInputSlots();
- return m_inputSlots.toList();
+ return m_inputSlots;
}
void QPlatformPrintDevice::loadOutputBins() const
@@ -337,11 +337,11 @@ QPrint::OutputBin QPlatformPrintDevice::defaultOutputBin() const
return output;
}
-QList<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const
+QVector<QPrint::OutputBin> QPlatformPrintDevice::supportedOutputBins() const
{
if (!m_haveOutputBins)
loadOutputBins();
- return m_outputBins.toList();
+ return m_outputBins;
}
void QPlatformPrintDevice::loadDuplexModes() const
@@ -353,11 +353,11 @@ QPrint::DuplexMode QPlatformPrintDevice::defaultDuplexMode() const
return QPrint::DuplexNone;
}
-QList<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const
+QVector<QPrint::DuplexMode> QPlatformPrintDevice::supportedDuplexModes() const
{
if (!m_haveDuplexModes)
loadDuplexModes();
- return m_duplexModes.toList();
+ return m_duplexModes;
}
void QPlatformPrintDevice::loadColorModes() const
@@ -369,11 +369,11 @@ QPrint::ColorMode QPlatformPrintDevice::defaultColorMode() const
return QPrint::GrayScale;
}
-QList<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const
+QVector<QPrint::ColorMode> QPlatformPrintDevice::supportedColorModes() const
{
if (!m_haveColorModes)
loadColorModes();
- return m_colorModes.toList();
+ return m_colorModes;
}
#ifndef QT_NO_MIMETYPE
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
index 1cac009660..8af76464b5 100644
--- a/src/printsupport/kernel/qplatformprintdevice.h
+++ b/src/printsupport/kernel/qplatformprintdevice.h
@@ -110,16 +110,16 @@ public:
virtual QList<int> supportedResolutions() const;
virtual QPrint::InputSlot defaultInputSlot() const;
- virtual QList<QPrint::InputSlot> supportedInputSlots() const;
+ virtual QVector<QPrint::InputSlot> supportedInputSlots() const;
virtual QPrint::OutputBin defaultOutputBin() const;
- virtual QList<QPrint::OutputBin> supportedOutputBins() const;
+ virtual QVector<QPrint::OutputBin> supportedOutputBins() const;
virtual QPrint::DuplexMode defaultDuplexMode() const;
- virtual QList<QPrint::DuplexMode> supportedDuplexModes() const;
+ virtual QVector<QPrint::DuplexMode> supportedDuplexModes() const;
virtual QPrint::ColorMode defaultColorMode() const;
- virtual QList<QPrint::ColorMode> supportedColorModes() const;
+ virtual QVector<QPrint::ColorMode> supportedColorModes() const;
virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const;
virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value);
diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp
index 7096f5a2f6..2bc6906364 100644
--- a/src/printsupport/kernel/qprintdevice.cpp
+++ b/src/printsupport/kernel/qprintdevice.cpp
@@ -210,9 +210,9 @@ QPrint::InputSlot QPrintDevice::defaultInputSlot() const
return isValid() ? d->defaultInputSlot() : QPrint::InputSlot();
}
-QList<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
+QVector<QPrint::InputSlot> QPrintDevice::supportedInputSlots() const
{
- return isValid() ? d->supportedInputSlots() : QList<QPrint::InputSlot>();
+ return isValid() ? d->supportedInputSlots() : QVector<QPrint::InputSlot>{};
}
QPrint::OutputBin QPrintDevice::defaultOutputBin() const
@@ -220,9 +220,9 @@ QPrint::OutputBin QPrintDevice::defaultOutputBin() const
return isValid() ? d->defaultOutputBin() : QPrint::OutputBin();
}
-QList<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
+QVector<QPrint::OutputBin> QPrintDevice::supportedOutputBins() const
{
- return isValid() ? d->supportedOutputBins() : QList<QPrint::OutputBin>();
+ return isValid() ? d->supportedOutputBins() : QVector<QPrint::OutputBin>{};
}
QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const
@@ -230,9 +230,9 @@ QPrint::DuplexMode QPrintDevice::defaultDuplexMode() const
return isValid() ? d->defaultDuplexMode() : QPrint::DuplexNone;
}
-QList<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
+QVector<QPrint::DuplexMode> QPrintDevice::supportedDuplexModes() const
{
- return isValid() ? d->supportedDuplexModes() : QList<QPrint::DuplexMode>();
+ return isValid() ? d->supportedDuplexModes() : QVector<QPrint::DuplexMode>{};
}
QPrint::ColorMode QPrintDevice::defaultColorMode() const
@@ -240,9 +240,9 @@ QPrint::ColorMode QPrintDevice::defaultColorMode() const
return isValid() ? d->defaultColorMode() : QPrint::GrayScale;
}
-QList<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
+QVector<QPrint::ColorMode> QPrintDevice::supportedColorModes() const
{
- return isValid() ? d->supportedColorModes() : QList<QPrint::ColorMode>();
+ return isValid() ? d->supportedColorModes() : QVector<QPrint::ColorMode>{};
}
QVariant QPrintDevice::property(PrintDevicePropertyKey key) const
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
index 1a26d3afcf..3dff2e54fe 100644
--- a/src/printsupport/kernel/qprintdevice_p.h
+++ b/src/printsupport/kernel/qprintdevice_p.h
@@ -120,16 +120,16 @@ public:
QList<int> supportedResolutions() const;
QPrint::InputSlot defaultInputSlot() const;
- QList<QPrint::InputSlot> supportedInputSlots() const;
+ QVector<QPrint::InputSlot> supportedInputSlots() const;
QPrint::OutputBin defaultOutputBin() const;
- QList<QPrint::OutputBin> supportedOutputBins() const;
+ QVector<QPrint::OutputBin> supportedOutputBins() const;
QPrint::DuplexMode defaultDuplexMode() const;
- QList<QPrint::DuplexMode> supportedDuplexModes() const;
+ QVector<QPrint::DuplexMode> supportedDuplexModes() const;
QPrint::ColorMode defaultColorMode() const;
- QList<QPrint::ColorMode> supportedColorModes() const;
+ QVector<QPrint::ColorMode> supportedColorModes() const;
enum PrintDevicePropertyKey {
PDPK_CustomBase = 0xff00
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index e399118cc9..ba234b3aae 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1024,7 +1024,7 @@ bool QWin32PrintEnginePrivate::resetDC()
return hdc != 0;
}
-static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id)
+static int indexOfId(const QVector<QPrint::InputSlot> &inputSlots, QPrint::InputSlotId id)
{
for (int i = 0; i < inputSlots.size(); ++i) {
if (inputSlots.at(i).id == id)
@@ -1033,7 +1033,7 @@ static int indexOfId(const QList<QPrint::InputSlot> &inputSlots, QPrint::InputSl
return -1;
}
-static int indexOfWindowsId(const QList<QPrint::InputSlot> &inputSlots, int windowsId)
+static int indexOfWindowsId(const QVector<QPrint::InputSlot> &inputSlots, int windowsId)
{
for (int i = 0; i < inputSlots.size(); ++i) {
if (inputSlots.at(i).windowsId == windowsId)
@@ -1210,7 +1210,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
case PPK_PaperSource: {
if (!d->devMode)
break;
- const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots();
+ const auto inputSlots = d->m_printDevice.supportedInputSlots();
const int paperSource = value.toInt();
const int index = paperSource >= DMBIN_USER ?
indexOfWindowsId(inputSlots, paperSource) : indexOfId(inputSlots, QPrint::InputSlotId(paperSource));
@@ -1465,7 +1465,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
if (d->devMode->dmDefaultSource >= DMBIN_USER) {
value = int(d->devMode->dmDefaultSource);
} else {
- const QList<QPrint::InputSlot> inputSlots = d->m_printDevice.supportedInputSlots();
+ const auto inputSlots = d->m_printDevice.supportedInputSlots();
const int index = indexOfWindowsId(inputSlots, d->devMode->dmDefaultSource);
value = index >= 0 ? inputSlots.at(index).id : QPrint::Auto;
}
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index d271e069ad..49a0c9ece4 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -380,7 +380,7 @@ QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
{
Q_D(const QPrinterInfo);
QList<QPrinter::DuplexMode> list;
- const QList<QPrint::DuplexMode> supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
+ const auto supportedDuplexModes = d->m_printDevice.supportedDuplexModes();
list.reserve(supportedDuplexModes.size());
for (QPrint::DuplexMode mode : supportedDuplexModes)
list << QPrinter::DuplexMode(mode);
--
2.15.1

View File

@ -1,62 +0,0 @@
From 2831fa76655c614ed3df0816401514950e79b5e6 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 6 Dec 2017 12:00:00 +0100
Subject: [PATCH] CUPS: Use printer job-billing as default instead of the empty
string
This also reads the job-billing from lpoptions if set there for the particular printer
Change-Id: Ia4a6961de504005b8dcd9209da0624e9ae9ef7e4
Reviewed-by: Laurent Montel <laurent.montel@kdab.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 ++
src/printsupport/kernel/qcups_p.h | 1 +
src/printsupport/widgets/qcupsjobwidget.cpp | 6 +++++-
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index e11d301..0fd6f5f 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -431,6 +431,8 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
return printerOption(QStringLiteral("job-priority"));
else if (key == PDPK_CupsJobSheets)
return printerOption(QStringLiteral("job-sheets"));
+ else if (key == PDPK_CupsJobBilling)
+ return printerOption(QStringLiteral("job-billing"));
return QVariant();
}
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index 906a548..c6bbacc 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -71,6 +71,7 @@ QT_BEGIN_NAMESPACE
#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3)
+#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4)
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index 4535f75..adaaff8 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -139,7 +139,11 @@ QTime QCupsJobWidget::jobHoldTime() const
void QCupsJobWidget::initJobBilling()
{
- setJobBilling(QString());
+ QString jobBilling;
+ if (m_printDevice)
+ jobBilling = m_printDevice->property(PDPK_CupsJobBilling).toString();
+
+ setJobBilling(jobBilling);
}
void QCupsJobWidget::setJobBilling(const QString &jobBilling)
--
2.7.4

View File

@ -1,527 +0,0 @@
From b4330bc391bbb08898f192ea3469b73aed09134c Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Tue, 5 Dec 2017 09:40:59 +0100
Subject: [PATCH 50/54] Reintroduce the Advanced tab in the
QPrintPropertiesDialog
This is mostly a revert of 69de6177615de3c4c31dea529172389e92f490b0 adapted to the new code.
The commit that removed this code said:
a) there's duplicate settings in the advanced tabs and in the rest of the ui: this easily
solved with a blacklist
b) you can set these options in the system settings: probably true, but it is very cumbersome
to go to the printer settings every time i print to select from which tray the
paper should be used
Task Number: QTBUG-54464
Change-Id: I7b1cacf51006dadb10aa6e00fe6dd2ff748fe576
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 401 ++++++++++++++++++++-
src/printsupport/dialogs/qprintpropertieswidget.ui | 14 +
2 files changed, 409 insertions(+), 6 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index f87630f1a0..d5ad90e85e 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -108,6 +108,11 @@ Print dialog class declarations
allow editing of Page and Advanced tabs.
Layout in qprintpropertieswidget.ui
+
+ QPPDOptionsModel: Holds the PPD Options for the printer.
+
+ QPPDOptionsEditor: Edits the PPD Options for the printer.
+
*/
static void initResources()
@@ -124,19 +129,29 @@ class QPrintPropertiesDialog : public QDialog
{
Q_OBJECT
public:
- QPrintPropertiesDialog(QPrinter *printer, QPrinter::OutputFormat outputFormat,
- const QString &printerName, QAbstractPrintDialog *parent = nullptr);
+ QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *currentPrintDevice,
+ QPrinter::OutputFormat outputFormat, const QString &printerName,
+ QAbstractPrintDialog *parent);
~QPrintPropertiesDialog();
void setupPrinter() const;
+ void showEvent(QShowEvent *event) override;
+
private:
friend class QUnixPrintWidgetPrivate;
+ QPrinter *m_printer;
Ui::QPrintPropertiesWidget widget;
QDialogButtonBox *m_buttons;
#if QT_CONFIG(cupsjobwidget)
QCupsJobWidget *m_jobOptions;
#endif
+
+#if QT_CONFIG(cups)
+ void setCupsOptionsFromItems(QOptionTreeItem *parent) const;
+
+ QPPDOptionsModel *m_cupsOptionsModel;
+#endif
};
class QUnixPrintWidgetPrivate;
@@ -220,6 +235,70 @@ public:
QPrinter::OutputFormat printerOutputFormat;
};
+#if QT_CONFIG(cups)
+class QOptionTreeItem
+{
+public:
+ enum ItemType { Root, Group, Option, Choice };
+
+ QOptionTreeItem(ItemType t, int i, const void *p, const char *desc, QOptionTreeItem *pi)
+ : type(t),
+ index(i),
+ ptr(p),
+ description(desc),
+ selected(-1),
+ selDescription(nullptr),
+ parentItem(pi) {}
+
+ ~QOptionTreeItem() {
+ qDeleteAll(childItems);
+ }
+
+ ItemType type;
+ int index;
+ const void *ptr;
+ const char *description;
+ int selected;
+ const char *selDescription;
+ QOptionTreeItem *parentItem;
+ QList<QOptionTreeItem*> childItems;
+};
+
+class QPPDOptionsModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ explicit QPPDOptionsModel(QPrintDevice *currentPrintDevice, QObject *parent);
+
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &index) const override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
+
+ QPrintDevice *m_currentPrintDevice;
+ QTextCodec *cupsCodec;
+ QOptionTreeItem *rootItem;
+ void parseGroups(QOptionTreeItem *parent);
+ void parseOptions(QOptionTreeItem *parent);
+ void parseChoices(QOptionTreeItem *parent);
+};
+
+class QPPDOptionsEditor : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+ explicit QPPDOptionsEditor(QObject *parent) : QStyledItemDelegate(parent) {}
+
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+ void setEditorData(QWidget *editor, const QModelIndex &index) const override;
+ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
+};
+
+#endif
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -233,9 +312,11 @@ public:
*/
-QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrinter::OutputFormat outputFormat,
- const QString &printerName, QAbstractPrintDialog *parent)
+QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrintDevice *currentPrintDevice,
+ QPrinter::OutputFormat outputFormat, const QString &printerName,
+ QAbstractPrintDialog *parent)
: QDialog(parent)
+ , m_printer(printer)
{
setWindowTitle(tr("Printer Properties"));
QVBoxLayout *lay = new QVBoxLayout(this);
@@ -252,7 +333,29 @@ QPrintPropertiesDialog::QPrintPropertiesDialog(QPrinter *printer, QPrinter::Outp
#if QT_CONFIG(cupsjobwidget)
m_jobOptions = new QCupsJobWidget(printer);
- widget.tabs->addTab(m_jobOptions, tr("Job Options"));
+ widget.tabs->insertTab(1, m_jobOptions, tr("Job Options"));
+#endif
+
+ const int advancedTabIndex = widget.tabs->indexOf(widget.cupsPropertiesPage);
+#if QT_CONFIG(cups)
+ m_cupsOptionsModel = new QPPDOptionsModel(currentPrintDevice, this);
+
+ widget.treeView->setItemDelegate(new QPPDOptionsEditor(this));
+
+ if (m_cupsOptionsModel->rowCount() > 0) {
+ widget.treeView->setModel(m_cupsOptionsModel);
+
+ for (int i = 0; i < m_cupsOptionsModel->rowCount(); ++i)
+ widget.treeView->expand(m_cupsOptionsModel->index(i, 0));
+
+ widget.tabs->setTabEnabled(advancedTabIndex, true);
+ } else {
+ widget.treeView->setModel(nullptr);
+ widget.tabs->setTabEnabled(advancedTabIndex, false);
+ }
+#else
+ Q_UNUSED(currentPrintDevice)
+ widget.tabs->setTabEnabled(advancedTabIndex, false);
#endif
}
@@ -266,8 +369,36 @@ void QPrintPropertiesDialog::setupPrinter() const
#if QT_CONFIG(cupsjobwidget)
m_jobOptions->setupPrinter();
#endif
+
+#if QT_CONFIG(cups)
+ setCupsOptionsFromItems(m_cupsOptionsModel->rootItem);
+#endif
}
+void QPrintPropertiesDialog::showEvent(QShowEvent *event)
+{
+ widget.treeView->resizeColumnToContents(0);
+ QDialog::showEvent(event);
+}
+
+#if QT_CONFIG(cups)
+void QPrintPropertiesDialog::setCupsOptionsFromItems(QOptionTreeItem *parent) const
+{
+ for (QOptionTreeItem *itm : qAsConst(parent->childItems)) {
+ if (itm->type == QOptionTreeItem::Option) {
+ const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
+ if (qstrcmp(opt->defchoice, opt->choices[itm->selected].choice) != 0) {
+ QStringList cupsOptions = QCUPSSupport::cupsOptionsList(m_printer);
+ QCUPSSupport::setCupsOption(cupsOptions, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itm->selected].choice));
+ QCUPSSupport::setCupsOptions(m_printer, cupsOptions);
+ }
+ } else {
+ setCupsOptionsFromItems(itm);
+ }
+ }
+}
+#endif
+
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@@ -844,7 +975,7 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties()
printerName = widget.printers->currentText();
}
- propertiesDialog = new QPrintPropertiesDialog(q->printer(), outputFormat, printerName, q);
+ propertiesDialog = new QPrintPropertiesDialog(q->printer(), &m_currentPrintDevice, outputFormat, printerName, q);
propertiesDialog->setResult(QDialog::Rejected);
propertiesDialogShown = false;
}
@@ -952,6 +1083,264 @@ void QUnixPrintWidget::updatePrinter()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
+/*
+
+ QPPDOptionsModel
+
+ Holds the PPD Options for the printer.
+
+*/
+
+#if QT_CONFIG(cups)
+
+QPPDOptionsModel::QPPDOptionsModel(QPrintDevice *currentPrintDevice, QObject *parent)
+ : QAbstractItemModel(parent)
+ , m_currentPrintDevice(currentPrintDevice)
+{
+ ppd_file_t *ppd = m_currentPrintDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
+ rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
+
+ if (ppd) {
+ cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
+ for (int i = 0; i < ppd->num_groups; ++i) {
+ QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], ppd->groups[i].text, rootItem);
+ rootItem->childItems.append(group);
+ parseGroups(group); // parse possible subgroups
+ parseOptions(group); // parse options
+ }
+ }
+
+ if (!cupsCodec)
+ cupsCodec = QTextCodec::codecForLocale();
+}
+
+int QPPDOptionsModel::columnCount(const QModelIndex &) const
+{
+ return 2;
+}
+
+int QPPDOptionsModel::rowCount(const QModelIndex &parent) const
+{
+ QOptionTreeItem *itm;
+ if (!parent.isValid())
+ itm = rootItem;
+ else
+ itm = static_cast<QOptionTreeItem*>(parent.internalPointer());
+
+ if (itm->type == QOptionTreeItem::Option)
+ return 0;
+
+ return itm->childItems.count();
+}
+
+QVariant QPPDOptionsModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
+
+ switch (role) {
+ case Qt::FontRole: {
+ if (itm->type == QOptionTreeItem::Group){
+ QFont font;
+ font.setBold(true);
+ return QVariant(font);
+ }
+ return QVariant();
+ }
+ break;
+
+ case Qt::DisplayRole: {
+ if (index.column() == 0)
+ return cupsCodec->toUnicode(itm->description);
+ else if (itm->type == QOptionTreeItem::Option && itm->selected > -1)
+ return cupsCodec->toUnicode(itm->selDescription);
+ else
+ return QVariant();
+ }
+ break;
+
+ }
+
+ return QVariant();
+}
+
+QModelIndex QPPDOptionsModel::index(int row, int column, const QModelIndex &parent) const
+{
+ QOptionTreeItem *itm;
+ if (!parent.isValid())
+ itm = rootItem;
+ else
+ itm = static_cast<QOptionTreeItem*>(parent.internalPointer());
+
+ return createIndex(row, column, itm->childItems.at(row));
+}
+
+
+QModelIndex QPPDOptionsModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (itm->parentItem && itm->parentItem != rootItem)
+ return createIndex(itm->parentItem->index, 0, itm->parentItem);
+
+ return QModelIndex();
+}
+
+Qt::ItemFlags QPPDOptionsModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid() || static_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Group)
+ return Qt::ItemIsEnabled;
+
+ if (index.column() == 1)
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+void QPPDOptionsModel::parseGroups(QOptionTreeItem *parent)
+{
+ const ppd_group_t *group = static_cast<const ppd_group_t*>(parent->ptr);
+
+ if (group) {
+ for (int i = 0; i < group->num_subgroups; ++i) {
+ QOptionTreeItem *subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], group->subgroups[i].text, parent);
+ parent->childItems.append(subgroup);
+ parseGroups(subgroup); // parse possible subgroups
+ parseOptions(subgroup); // parse options
+ }
+ }
+}
+
+static bool isBlacklistedOption(const char *keyword) Q_DECL_NOTHROW
+{
+ // We already let the user set these options elsewhere
+ const char *cupsOptionBlacklist[] = {
+ "Collate",
+ "Copies",
+ "OutputOrder",
+ "PageRegion",
+ "PageSize"
+ };
+ auto equals = [](const char *keyword) {
+ return [keyword](const char *candidate) {
+ return qstrcmp(keyword, candidate) == 0;
+ };
+ };
+ return std::any_of(std::begin(cupsOptionBlacklist), std::end(cupsOptionBlacklist), equals(keyword));
+};
+
+void QPPDOptionsModel::parseOptions(QOptionTreeItem *parent)
+{
+ const ppd_group_t *group = static_cast<const ppd_group_t*>(parent->ptr);
+ for (int i = 0; i < group->num_options; ++i) {
+ if (!isBlacklistedOption(group->options[i].keyword)) {
+ QOptionTreeItem *opt = new QOptionTreeItem(QOptionTreeItem::Option, i, &group->options[i], group->options[i].text, parent);
+ parent->childItems.append(opt);
+ parseChoices(opt);
+ }
+ }
+}
+
+void QPPDOptionsModel::parseChoices(QOptionTreeItem *parent)
+{
+ const ppd_option_t *option = static_cast<const ppd_option_t*>(parent->ptr);
+ bool marked = false;
+ for (int i = 0; i < option->num_choices; ++i) {
+ QOptionTreeItem *choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], option->choices[i].text, parent);
+ if (static_cast<int>(option->choices[i].marked) == 1) {
+ parent->selected = i;
+ parent->selDescription = option->choices[i].text;
+ marked = true;
+ } else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
+ parent->selected = i;
+ parent->selDescription = option->choices[i].text;
+ }
+ parent->childItems.append(choice);
+ }
+}
+
+QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ switch (section) {
+ case 0:
+ return QVariant(tr("Name"));
+ case 1:
+ return QVariant(tr("Value"));
+ }
+
+ return QVariant();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+/*
+
+ QPPDOptionsEditor
+
+ Edits the PPD Options for the printer.
+
+*/
+
+QWidget *QPPDOptionsEditor::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ Q_UNUSED(option)
+
+ if (index.column() == 1 && static_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Option)
+ return new QComboBox(parent);
+
+ return nullptr;
+}
+
+void QPPDOptionsEditor::setEditorData(QWidget *editor, const QModelIndex &index) const
+{
+ if (index.column() != 1)
+ return;
+
+ QComboBox *cb = static_cast<QComboBox*>(editor);
+ QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (itm->selected == -1)
+ cb->addItem(QString());
+
+ const QPPDOptionsModel *m = static_cast<const QPPDOptionsModel*>(index.model());
+ for (auto *childItem : qAsConst(itm->childItems))
+ cb->addItem(m->cupsCodec->toUnicode(childItem->description));
+
+ if (itm->selected > -1)
+ cb->setCurrentIndex(itm->selected);
+}
+
+void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
+{
+ QComboBox *cb = static_cast<QComboBox*>(editor);
+ QOptionTreeItem *itm = static_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (itm->selected == cb->currentIndex())
+ return;
+
+ const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
+ QPPDOptionsModel *m = static_cast<QPPDOptionsModel*>(model);
+
+ const auto values = QStringList{} << QString::fromLatin1(opt->keyword) << QString::fromLatin1(opt->choices[cb->currentIndex()].choice);
+ if (m->m_currentPrintDevice->setProperty(PDPK_PpdOption, values)) {
+ itm->selected = cb->currentIndex();
+ itm->selDescription = static_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+
+#endif // QT_CONFIG(cups)
#endif // defined (Q_OS_UNIX)
QT_END_NAMESPACE
diff --git a/src/printsupport/dialogs/qprintpropertieswidget.ui b/src/printsupport/dialogs/qprintpropertieswidget.ui
index 66d7b80fcd..0e56fb33df 100644
--- a/src/printsupport/dialogs/qprintpropertieswidget.ui
+++ b/src/printsupport/dialogs/qprintpropertieswidget.ui
@@ -32,6 +32,20 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="cupsPropertiesPage" >
+ <attribute name="title" >
+ <string>Advanced</string>
+ </attribute>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QTreeView" name="treeView" >
+ <property name="alternatingRowColors" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
</layout>
--
2.15.1

View File

@ -1,139 +0,0 @@
From 414a703036db6d5b4b1f48b85d8c3b4702f869ec Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 6 Dec 2017 13:00:30 +0100
Subject: [PATCH] CUPS: Use printer job-hold-until as default instead of the
nohold
This also reads the job-hold-until from lpoptions if set there for the particular printer
Change-Id: Ic60fef675ab9f4760cd99ee9ac417b0478459681
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 2 ++
src/printsupport/kernel/qcups.cpp | 31 +++++++++++++++++++++++
src/printsupport/kernel/qcups_p.h | 18 +++++++++----
src/printsupport/widgets/qcupsjobwidget.cpp | 10 ++++++--
4 files changed, 54 insertions(+), 7 deletions(-)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 0fd6f5f..14c14fa 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -433,6 +433,8 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
return printerOption(QStringLiteral("job-sheets"));
else if (key == PDPK_CupsJobBilling)
return printerOption(QStringLiteral("job-billing"));
+ else if (key == PDPK_CupsJobHoldUntil)
+ return printerOption(QStringLiteral("job-hold-until"));
return QVariant();
}
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index aa1cdff..50c6953 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -107,6 +107,37 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold,
return QString();
}
+QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString &jobHoldUntil)
+{
+ if (jobHoldUntil == QLatin1String("indefinite")) {
+ return { QCUPSSupport::Indefinite, QTime() };
+ } else if (jobHoldUntil == QLatin1String("day-time")) {
+ return { QCUPSSupport::DayTime, QTime() };
+ } else if (jobHoldUntil == QLatin1String("night")) {
+ return { QCUPSSupport::Night, QTime() };
+ } else if (jobHoldUntil == QLatin1String("second-shift")) {
+ return { QCUPSSupport::SecondShift, QTime() };
+ } else if (jobHoldUntil == QLatin1String("third-shift")) {
+ return { QCUPSSupport::ThirdShift, QTime() };
+ } else if (jobHoldUntil == QLatin1String("weekend")) {
+ return { QCUPSSupport::Weekend, QTime() };
+ }
+
+
+ QTime parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m:s"));
+ if (!parsedTime.isValid())
+ parsedTime = QTime::fromString(jobHoldUntil, QStringLiteral("h:m"));
+ if (parsedTime.isValid()) {
+ // CUPS time is in UTC, user expects local time, so get the equivalent
+ QDateTime dateTimeUtc = QDateTime::currentDateTimeUtc();
+ dateTimeUtc.setTime(parsedTime);
+ return { QCUPSSupport::SpecificTime, dateTimeUtc.toLocalTime().time() };
+ }
+
+ return { QCUPSSupport::NoHold, QTime() };
+}
+
+
void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
{
QStringList cupsOptions = cupsOptionsList(printer);
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index c6bbacc..afddfdb 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -67,11 +67,12 @@ QT_BEGIN_NAMESPACE
// removed from the dialogs.
#define PPK_CupsOptions QPrintEngine::PrintEnginePropertyKey(0xfe00)
-#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
-#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
-#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
-#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3)
-#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4)
+#define PDPK_PpdFile QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase)
+#define PDPK_PpdOption QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 1)
+#define PDPK_CupsJobPriority QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 2)
+#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3)
+#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4)
+#define PDPK_CupsJobHoldUntil QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 5)
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{
@@ -148,6 +149,13 @@ public:
BannerPage endBannerPage = QCUPSSupport::NoBanner;
};
static JobSheets parseJobSheets(const QString &jobSheets);
+
+ struct JobHoldUntilWithTime
+ {
+ JobHoldUntil jobHold;
+ QTime time;
+ };
+ static JobHoldUntilWithTime parseJobHoldUntil(const QString &jobHoldUntil);
};
Q_DECLARE_TYPEINFO(QCUPSSupport::JobHoldUntil, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QCUPSSupport::BannerPage, Q_PRIMITIVE_TYPE);
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index adaaff8..5d026d4 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -73,7 +73,6 @@ QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWi
{
m_ui.setupUi(this);
//set all the default values
- //TODO restore last used values
initJobHold();
initJobBilling();
initJobPriority();
@@ -105,7 +104,14 @@ void QCupsJobWidget::initJobHold()
connect(m_ui.jobHoldComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleJobHoldTime()));
- setJobHold(QCUPSSupport::NoHold, QTime());
+ QCUPSSupport::JobHoldUntilWithTime jobHoldWithTime;
+
+ if (m_printDevice) {
+ const QString jobHoldUntilString = m_printDevice->property(PDPK_CupsJobHoldUntil).toString();
+ jobHoldWithTime = QCUPSSupport::parseJobHoldUntil(jobHoldUntilString);
+ }
+
+ setJobHold(jobHoldWithTime.jobHold, jobHoldWithTime.time);
toggleJobHoldTime();
}
--
2.7.4

View File

@ -1,32 +0,0 @@
From e31c79ece49f0893882f9062edc9664926b9b13f Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@qt.io>
Date: Mon, 18 Dec 2017 09:31:11 +0100
Subject: [PATCH 54/54] QtPrintSupport: Fix build
dialogs/qprintdialog_unix.cpp:1104:21: error: incomplete type 'QTextCodec' used in nested name specifier
Amends b4330bc391bbb08898f192ea3469b73aed09134c.
Task-number: QTBUG-54464
Change-Id: I555431d11a5c3f247d4f055d94255d2708c92374
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: David Faure <david.faure@kdab.com>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index d5ad90e85e..9ad9fa35a5 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -49,6 +49,7 @@
#include "qfiledialog.h"
#endif
#include <QtCore/qdir.h>
+#include <QtCore/qtextcodec.h>
#include <QtGui/qevent.h>
#if QT_CONFIG(filesystemmodel)
#include <QtWidgets/qfilesystemmodel.h>
--
2.15.1

View File

@ -1,512 +0,0 @@
From d94ccf310a9ca01593750a34f743ec652f6a344e Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 27 Dec 2017 11:12:19 +0100
Subject: [PATCH 1/1] Unix: Fix usability of the print properties dialog
Previous behavior:
* Open, change setting, cancel, open again, setting was as originally (i.e. unchanged)
* Open, change setting, accept, open, change setting, cancel, open again, the setting would be as before pressing cancel
* Open, change setting, accept, open, press cancel without changing anything, print, the initially changed setting is not applied
New behavior:
* Pressing cancel just cancels the changes since you opened the dialog, everything you accepted previously stays correctly selected
Change-Id: I483647504682f26d3d21c5229cc6530bf14fe519
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
---
src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 25 +++++
src/printsupport/dialogs/qpagesetupdialog_unix_p.h | 6 ++
src/printsupport/dialogs/qprintdialog_unix.cpp | 107 +++++++++++++--------
src/printsupport/kernel/qcups_p.h | 10 +-
src/printsupport/widgets/qcupsjobwidget.cpp | 25 ++++-
src/printsupport/widgets/qcupsjobwidget_p.h | 7 ++
6 files changed, 136 insertions(+), 44 deletions(-)
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
index 4086212..2063408 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp
@@ -234,6 +234,9 @@ QPageSetupWidget::QPageSetupWidget(QWidget *parent)
m_printer(0),
m_outputFormat(QPrinter::PdfFormat),
m_units(QPageLayout::Point),
+ m_savedUnits(QPageLayout::Point),
+ m_savedPagesPerSheet(-1),
+ m_savedPagesPerSheetLayout(-1),
m_blockSignals(false),
m_realCustomPageSizeIndex(-1)
{
@@ -404,6 +407,7 @@ void QPageSetupWidget::setPrinter(QPrinter *printer, QPrintDevice *printDevice,
m_printerName = printerName;
initPageSizes();
updateWidget();
+ updateSavedValues();
}
// Update the widget with the current settings
@@ -487,6 +491,7 @@ void QPageSetupWidget::updateWidget()
m_ui.pageHeight->setEnabled(isCustom);
m_ui.heightLabel->setEnabled(isCustom);
+ m_ui.portrait->setChecked(m_pageLayout.orientation() == QPageLayout::Portrait);
m_ui.landscape->setChecked(m_pageLayout.orientation() == QPageLayout::Landscape);
m_ui.pagesPerSheetButtonGroup->setEnabled(m_outputFormat == QPrinter::NativeFormat);
@@ -515,6 +520,26 @@ void QPageSetupWidget::setupPrinter() const
#endif
}
+void QPageSetupWidget::updateSavedValues()
+{
+ m_savedUnits = m_units;
+ m_savedPageLayout = m_pageLayout;
+ m_savedPagesPerSheet = m_ui.pagesPerSheetCombo->currentIndex();
+ m_savedPagesPerSheetLayout = m_ui.pagesPerSheetLayoutCombo->currentIndex();
+}
+
+void QPageSetupWidget::revertToSavedValues()
+{
+ m_units = m_savedUnits;
+ m_pageLayout = m_savedPageLayout;
+ m_pagePreview->setPageLayout(m_pageLayout);
+
+ updateWidget();
+
+ m_ui.pagesPerSheetCombo->setCurrentIndex(m_savedPagesPerSheet);
+ m_ui.pagesPerSheetLayoutCombo->setCurrentIndex(m_savedPagesPerSheetLayout);
+}
+
// Updates size/preview after the combobox has been changed.
void QPageSetupWidget::pageSizeChanged()
{
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
index 0b9723e..82c22c3 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
@@ -75,6 +75,8 @@ public:
void setPrinter(QPrinter *printer, QPrintDevice *printDevice,
QPrinter::OutputFormat outputFormat, const QString &printerName);
void setupPrinter() const;
+ void updateSavedValues();
+ void revertToSavedValues();
private slots:
void pageSizeChanged();
@@ -100,7 +102,11 @@ private:
QPrinter::OutputFormat m_outputFormat;
QString m_printerName;
QPageLayout m_pageLayout;
+ QPageLayout m_savedPageLayout;
QPageLayout::Unit m_units;
+ QPageLayout::Unit m_savedUnits;
+ int m_savedPagesPerSheet;
+ int m_savedPagesPerSheetLayout;
bool m_blockSignals;
int m_realCustomPageSizeIndex;
};
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index a3ba7be..29000bf 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -207,7 +207,6 @@ public:
private:
QPrintDialogPrivate *optionsPane;
bool filePrintersAdded;
- bool propertiesDialogShown;
};
class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
@@ -247,11 +246,10 @@ class QOptionTreeItem
public:
enum ItemType { Root, Group, Option, Choice };
- QOptionTreeItem(ItemType t, int i, const void *p, const char *desc, QOptionTreeItem *pi)
+ QOptionTreeItem(ItemType t, int i, const void *p, QOptionTreeItem *pi)
: type(t),
index(i),
ptr(p),
- description(desc),
parentItem(pi) {}
~QOptionTreeItem() {
@@ -261,7 +259,6 @@ public:
ItemType type;
int index;
const void *ptr;
- const char *description;
QOptionTreeItem *parentItem;
QList<QOptionTreeItem*> childItems;
};
@@ -269,14 +266,13 @@ public:
class QOptionTreeItemOption : public QOptionTreeItem
{
public:
- QOptionTreeItemOption (int i, const void *p, const char *desc, QOptionTreeItem *pi)
- : QOptionTreeItem(Option, i, p, desc, pi)
+ QOptionTreeItemOption (int i, const void *p, QOptionTreeItem *pi)
+ : QOptionTreeItem(Option, i, p, pi)
{
}
int selected;
int originallySelected;
- const char *selDescription;
};
class QPPDOptionsModel : public QAbstractItemModel
@@ -296,6 +292,8 @@ public:
void setCupsOptionsFromItems(QPrinter *printer) const;
void reject();
+ void updateSavedValues();
+ void revertToSavedValues();
QPrintDevice *currentPrintDevice() const;
QTextCodec *cupsCodec() const;
@@ -313,6 +311,8 @@ private:
void setCupsOptionsFromItems(QPrinter *printer, QOptionTreeItem *parent) const;
void reject(QOptionTreeItem *item);
+ void updateSavedValues(QOptionTreeItem *item);
+ void revertToSavedValues(QOptionTreeItem *item);
void emitDataChanged(QOptionTreeItem *item, const QModelIndex &itemIndex, bool *conflictsFound);
bool hasConflicts(QOptionTreeItem *item) const;
@@ -420,8 +420,14 @@ void QPrintPropertiesDialog::showEvent(QShowEvent *event)
void QPrintPropertiesDialog::reject()
{
+ widget.pageSetup->revertToSavedValues();
+
+#if QT_CONFIG(cupsjobwidget)
+ m_jobOptions->revertToSavedValues();
+#endif
+
#if QT_CONFIG(cups)
- m_cupsOptionsModel->reject();
+ m_cupsOptionsModel->revertToSavedValues();
#endif
QDialog::reject();
}
@@ -437,7 +443,15 @@ void QPrintPropertiesDialog::accept()
if (answer != QMessageBox::No)
return;
}
+ m_cupsOptionsModel->updateSavedValues();
+#endif
+
+#if QT_CONFIG(cupsjobwidget)
+ m_jobOptions->updateSavedValues();
#endif
+
+ widget.pageSetup->updateSavedValues();
+
QDialog::accept();
}
@@ -812,9 +826,9 @@ void QPrintDialog::accept()
*/
QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *prn)
: parent(p), propertiesDialog(0), printer(prn), optionsPane(0),
- filePrintersAdded(false), propertiesDialogShown(false)
+ filePrintersAdded(false)
{
- q = 0;
+ q = 0;
if (parent)
q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
@@ -900,7 +914,6 @@ void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
if (propertiesDialog){
delete propertiesDialog;
propertiesDialog = nullptr;
- propertiesDialogShown = false;
}
if (filePrintersAdded) {
@@ -993,7 +1006,7 @@ bool QUnixPrintWidgetPrivate::checkFields()
}
#if QT_CONFIG(cups)
- if (propertiesDialogShown) {
+ if (propertiesDialog) {
QCUPSSupport::PagesPerSheet pagesPerSheet = propertiesDialog->widget.pageSetup->m_ui.pagesPerSheetCombo
->currentData().value<QCUPSSupport::PagesPerSheet>();
@@ -1030,8 +1043,6 @@ void QUnixPrintWidgetPrivate::setupPrinterProperties()
}
propertiesDialog = new QPrintPropertiesDialog(q->printer(), &m_currentPrintDevice, outputFormat, printerName, q);
- propertiesDialog->setResult(QDialog::Rejected);
- propertiesDialogShown = false;
}
void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
@@ -1039,15 +1050,6 @@ void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
if (!propertiesDialog)
setupPrinterProperties();
propertiesDialog->exec();
- if (!propertiesDialogShown && propertiesDialog->result() == QDialog::Rejected) {
- // If properties dialog was rejected the dialog is deleted and
- // the properties are set to defaults when printer is setup
- delete propertiesDialog;
- propertiesDialog = nullptr;
- propertiesDialogShown = false;
- } else
- // properties dialog was shown and accepted
- propertiesDialogShown = true;
}
void QUnixPrintWidgetPrivate::setupPrinter()
@@ -1072,8 +1074,7 @@ void QUnixPrintWidgetPrivate::setupPrinter()
if (!propertiesDialog)
setupPrinterProperties();
- if (propertiesDialog->result() == QDialog::Accepted || !propertiesDialogShown)
- propertiesDialog->setupPrinter();
+ propertiesDialog->setupPrinter();
}
/*! \internal
@@ -1153,12 +1154,12 @@ QPPDOptionsModel::QPPDOptionsModel(QPrintDevice *currentPrintDevice, QObject *pa
, m_cupsCodec(nullptr)
{
ppd_file_t *ppd = m_currentPrintDevice->property(PDPK_PpdFile).value<ppd_file_t*>();
- m_rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
+ m_rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, nullptr);
if (ppd) {
m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
for (int i = 0; i < ppd->num_groups; ++i) {
- QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], ppd->groups[i].text, m_rootItem);
+ QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], m_rootItem);
m_rootItem->childItems.append(group);
parseGroups(group); // parse possible subgroups
parseOptions(group); // parse options
@@ -1208,11 +1209,18 @@ QVariant QPPDOptionsModel::data(const QModelIndex &index, int role) const
case Qt::DisplayRole: {
if (index.column() == 0) {
- return m_cupsCodec->toUnicode(itm->description);
+ if (itm->type == QOptionTreeItem::Option) {
+ const ppd_option_t *option = static_cast<const ppd_option_t*>(itm->ptr);
+ return m_cupsCodec->toUnicode(option->text);
+ } else if (itm->type == QOptionTreeItem::Group) {
+ const ppd_group_t *group = static_cast<const ppd_group_t*>(itm->ptr);
+ return m_cupsCodec->toUnicode(group->text);
+ }
} else if (itm->type == QOptionTreeItem::Option) {
QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
+ const ppd_option_t *option = static_cast<const ppd_option_t*>(itm->ptr);
if (itmOption->selected > -1)
- return m_cupsCodec->toUnicode(itmOption->selDescription);
+ return m_cupsCodec->toUnicode(option->choices[itmOption->selected].text);
}
return QVariant();
@@ -1314,7 +1322,7 @@ void QPPDOptionsModel::parseGroups(QOptionTreeItem *parent)
if (group) {
for (int i = 0; i < group->num_subgroups; ++i) {
- QOptionTreeItem *subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], group->subgroups[i].text, parent);
+ QOptionTreeItem *subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], parent);
parent->childItems.append(subgroup);
parseGroups(subgroup); // parse possible subgroups
parseOptions(subgroup); // parse options
@@ -1346,7 +1354,7 @@ void QPPDOptionsModel::parseOptions(QOptionTreeItem *parent)
const ppd_group_t *group = static_cast<const ppd_group_t*>(parent->ptr);
for (int i = 0; i < group->num_options; ++i) {
if (!isBlacklistedOption(group->options[i].keyword)) {
- QOptionTreeItemOption *opt = new QOptionTreeItemOption(i, &group->options[i], group->options[i].text, parent);
+ QOptionTreeItemOption *opt = new QOptionTreeItemOption(i, &group->options[i], parent);
parent->childItems.append(opt);
parseChoices(opt);
}
@@ -1358,14 +1366,12 @@ void QPPDOptionsModel::parseChoices(QOptionTreeItemOption *parent)
const ppd_option_t *option = static_cast<const ppd_option_t*>(parent->ptr);
bool marked = false;
for (int i = 0; i < option->num_choices; ++i) {
- QOptionTreeItem *choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], option->choices[i].text, parent);
+ QOptionTreeItem *choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], parent);
if (static_cast<int>(option->choices[i].marked) == 1) {
parent->selected = i;
- parent->selDescription = option->choices[i].text;
marked = true;
} else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
parent->selected = i;
- parent->selDescription = option->choices[i].text;
}
parent->originallySelected = parent->selected;
parent->childItems.append(choice);
@@ -1436,12 +1442,13 @@ QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) co
return QVariant();
}
-void QPPDOptionsModel::reject()
+void QPPDOptionsModel::revertToSavedValues()
{
- reject(m_rootItem);
+ revertToSavedValues(m_rootItem);
+ emitConflictsChanged();
}
-void QPPDOptionsModel::reject(QOptionTreeItem *item)
+void QPPDOptionsModel::revertToSavedValues(QOptionTreeItem *item)
{
if (item->type == QOptionTreeItem::Option) {
QOptionTreeItemOption *itemOption = static_cast<QOptionTreeItemOption *>(item);
@@ -1451,10 +1458,27 @@ void QPPDOptionsModel::reject(QOptionTreeItem *item)
: option->defchoice;
const auto values = QStringList{} << QString::fromLatin1(option->keyword) << QString::fromLatin1(choice);
m_currentPrintDevice->setProperty(PDPK_PpdOption, values);
+ itemOption->selected = itemOption->originallySelected;
}
for (QOptionTreeItem *child : qAsConst(item->childItems))
- reject(child);
+ revertToSavedValues(child);
+}
+
+void QPPDOptionsModel::updateSavedValues()
+{
+ updateSavedValues(m_rootItem);
+}
+
+void QPPDOptionsModel::updateSavedValues(QOptionTreeItem *item)
+{
+ if (item->type == QOptionTreeItem::Option) {
+ QOptionTreeItemOption *itemOption = static_cast<QOptionTreeItemOption *>(item);
+ itemOption->originallySelected = itemOption->selected;
+ }
+
+ for (QOptionTreeItem *child : qAsConst(item->childItems))
+ updateSavedValues(child);
}
////////////////////////////////////////////////////////////////////////////////
@@ -1490,8 +1514,10 @@ void QPPDOptionsEditor::setEditorData(QWidget *editor, const QModelIndex &index)
cb->addItem(QString());
const QPPDOptionsModel *m = static_cast<const QPPDOptionsModel*>(index.model());
- for (auto *childItem : qAsConst(itm->childItems))
- cb->addItem(m->cupsCodec()->toUnicode(childItem->description));
+ for (auto *childItem : qAsConst(itm->childItems)) {
+ const ppd_choice_t *choice = static_cast<const ppd_choice_t*>(childItem->ptr);
+ cb->addItem(m->cupsCodec()->toUnicode(choice->text));
+ }
if (itm->selected > -1)
cb->setCurrentIndex(itm->selected);
@@ -1511,7 +1537,6 @@ void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model,
const auto values = QStringList{} << QString::fromLatin1(opt->keyword) << QString::fromLatin1(opt->choices[cb->currentIndex()].choice);
m->currentPrintDevice()->setProperty(PDPK_PpdOption, values);
itm->selected = cb->currentIndex();
- itm->selDescription = static_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
m->emitConflictsChanged();
}
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index afddfdb..4b27632 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -145,13 +145,19 @@ public:
struct JobSheets
{
- BannerPage startBannerPage = QCUPSSupport::NoBanner;
- BannerPage endBannerPage = QCUPSSupport::NoBanner;
+ JobSheets(BannerPage s = NoBanner, BannerPage e = NoBanner)
+ : startBannerPage(s), endBannerPage(e) {}
+
+ BannerPage startBannerPage;
+ BannerPage endBannerPage;
};
static JobSheets parseJobSheets(const QString &jobSheets);
struct JobHoldUntilWithTime
{
+ JobHoldUntilWithTime(JobHoldUntil jh = NoHold, const QTime &t = QTime())
+ : jobHold(jh), time(t) {}
+
JobHoldUntil jobHold;
QTime time;
};
diff --git a/src/printsupport/widgets/qcupsjobwidget.cpp b/src/printsupport/widgets/qcupsjobwidget.cpp
index 7525d7f..dcdb933 100644
--- a/src/printsupport/widgets/qcupsjobwidget.cpp
+++ b/src/printsupport/widgets/qcupsjobwidget.cpp
@@ -77,6 +77,8 @@ QCupsJobWidget::QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWi
initJobBilling();
initJobPriority();
initBannerPages();
+
+ updateSavedValues();
}
QCupsJobWidget::~QCupsJobWidget()
@@ -91,6 +93,27 @@ void QCupsJobWidget::setupPrinter()
QCUPSSupport::setBannerPages(m_printer, startBannerPage(), endBannerPage());
}
+void QCupsJobWidget::updateSavedValues()
+{
+ m_savedJobHoldWithTime = { jobHold(), jobHoldTime() };
+ m_savedJobBilling = jobBilling();
+ m_savedPriority = jobPriority();
+ m_savedJobSheets = { startBannerPage(), endBannerPage() };
+}
+
+void QCupsJobWidget::revertToSavedValues()
+{
+ setJobHold(m_savedJobHoldWithTime.jobHold, m_savedJobHoldWithTime.time);
+ toggleJobHoldTime();
+
+ setJobBilling(m_savedJobBilling);
+
+ setJobPriority(m_savedPriority);
+
+ setStartBannerPage(m_savedJobSheets.startBannerPage);
+ setEndBannerPage(m_savedJobSheets.endBannerPage);
+}
+
void QCupsJobWidget::initJobHold()
{
m_ui.jobHoldComboBox->addItem(tr("Print Immediately"), QVariant::fromValue(QCUPSSupport::NoHold));
@@ -154,7 +177,7 @@ void QCupsJobWidget::initJobBilling()
void QCupsJobWidget::setJobBilling(const QString &jobBilling)
{
- m_ui.jobBillingLineEdit->insert(jobBilling);
+ m_ui.jobBillingLineEdit->setText(jobBilling);
}
QString QCupsJobWidget::jobBilling() const
diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h
index dcec27a..4b6b047 100644
--- a/src/printsupport/widgets/qcupsjobwidget_p.h
+++ b/src/printsupport/widgets/qcupsjobwidget_p.h
@@ -75,6 +75,8 @@ public:
explicit QCupsJobWidget(QPrinter *printer, QPrintDevice *printDevice, QWidget *parent = nullptr);
~QCupsJobWidget();
void setupPrinter();
+ void updateSavedValues();
+ void revertToSavedValues();
private Q_SLOTS:
void toggleJobHoldTime();
@@ -106,6 +108,11 @@ private:
QPrintDevice *m_printDevice;
Ui::QCupsJobWidget m_ui;
+ QCUPSSupport::JobHoldUntilWithTime m_savedJobHoldWithTime;
+ QString m_savedJobBilling;
+ int m_savedPriority;
+ QCUPSSupport::JobSheets m_savedJobSheets;
+
Q_DISABLE_COPY(QCupsJobWidget)
};
--
2.7.4

View File

@ -1,70 +0,0 @@
From bf59032d704f1163befc05e258a7f65887626add Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Wed, 27 Dec 2017 15:13:33 +0100
Subject: [PATCH 1/1] cups: Don't show InstallableOptions in the advanced
properties
According to CUPS maintainer it is recommended to not show them[1].
GTK and Libreoffice behave like that.
[1] https://lists.cups.org/pipermail/cups/2015-September/027124.html
Change-Id: I82614003490554d41e38a125d44e3a599c2e7342
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 29000bf..3a89c9e 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -1148,6 +1148,11 @@ void QUnixPrintWidget::updatePrinter()
#if QT_CONFIG(cups)
+static bool isBlacklistedGroup(ppd_group_t *group) Q_DECL_NOTHROW
+{
+ return qstrcmp(group->name, "InstallableOptions") == 0;
+};
+
QPPDOptionsModel::QPPDOptionsModel(QPrintDevice *currentPrintDevice, QObject *parent)
: QAbstractItemModel(parent)
, m_currentPrintDevice(currentPrintDevice)
@@ -1159,10 +1164,12 @@ QPPDOptionsModel::QPPDOptionsModel(QPrintDevice *currentPrintDevice, QObject *pa
if (ppd) {
m_cupsCodec = QTextCodec::codecForName(ppd->lang_encoding);
for (int i = 0; i < ppd->num_groups; ++i) {
- QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], m_rootItem);
- m_rootItem->childItems.append(group);
- parseGroups(group); // parse possible subgroups
- parseOptions(group); // parse options
+ if (!isBlacklistedGroup(&ppd->groups[i])) {
+ QOptionTreeItem *group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppd->groups[i], m_rootItem);
+ m_rootItem->childItems.append(group);
+ parseGroups(group); // parse possible subgroups
+ parseOptions(group); // parse options
+ }
}
}
@@ -1322,10 +1329,12 @@ void QPPDOptionsModel::parseGroups(QOptionTreeItem *parent)
if (group) {
for (int i = 0; i < group->num_subgroups; ++i) {
- QOptionTreeItem *subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], parent);
- parent->childItems.append(subgroup);
- parseGroups(subgroup); // parse possible subgroups
- parseOptions(subgroup); // parse options
+ if (!isBlacklistedGroup(&group->subgroups[i])) {
+ QOptionTreeItem *subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], parent);
+ parent->childItems.append(subgroup);
+ parseGroups(subgroup); // parse possible subgroups
+ parseOptions(subgroup); // parse options
+ }
}
}
}
--
2.7.4

View File

@ -1,328 +0,0 @@
From 608301d4c81ce65804a088aaebbd5433a56d69d7 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Thu, 28 Dec 2017 11:22:32 +0100
Subject: [PATCH] CUPS: Enable printing arbitrary pages and page ranges
Task-number: QTBUG-1311
Change-Id: I8e09def0e0d8c1404d3ee86845d98a30c23b6485
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 104 +++++++++++++++++++++++
src/printsupport/dialogs/qprintsettingsoutput.ui | 90 +++++++++++++++++---
src/printsupport/kernel/qcups.cpp | 7 +-
src/printsupport/kernel/qcups_p.h | 1 +
4 files changed, 188 insertions(+), 14 deletions(-)
Index: qtbase-opensource-src-5.9.4/src/printsupport/dialogs/qprintdialog_unix.cpp
===================================================================
--- qtbase-opensource-src-5.9.4.orig/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ qtbase-opensource-src-5.9.4/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -493,6 +493,9 @@ void QPrintDialogPrivate::init()
options.pageSetCombo->addItem(tr("All Pages"), QVariant::fromValue(QCUPSSupport::AllPages));
options.pageSetCombo->addItem(tr("Odd Pages"), QVariant::fromValue(QCUPSSupport::OddPages));
options.pageSetCombo->addItem(tr("Even Pages"), QVariant::fromValue(QCUPSSupport::EvenPages));
+#else
+ for (int i = options.pagesLayout->count() - 1; i >= 0; --i)
+ delete options.pagesLayout->itemAt(i)->widget();
#endif
top->d->setOptionsPane(this);
@@ -561,6 +564,87 @@ void QPrintDialogPrivate::selectPrinter(
options.pageSetCombo->setEnabled(true);
}
+#if QT_CONFIG(cups)
+static std::vector<std::pair<int, int>> pageRangesFromString(const QString &pagesString) Q_DECL_NOTHROW
+{
+ std::vector<std::pair<int, int>> result;
+ const QStringList items = pagesString.split(',');
+ for (const QString item : items) {
+ if (item.isEmpty())
+ return {};
+
+ if (item.contains(QLatin1Char('-'))) {
+ const QStringList rangeItems = item.split('-');
+ if (rangeItems.count() != 2)
+ return {};
+
+ bool ok;
+ const int number1 = rangeItems[0].toInt(&ok);
+ if (!ok)
+ return {};
+
+ const int number2 = rangeItems[1].toInt(&ok);
+ if (!ok)
+ return {};
+
+ if (number1 < 1 || number2 < 1 || number2 < number1)
+ return {};
+
+ result.push_back(std::make_pair(number1, number2));
+
+ } else {
+ bool ok;
+ const int number = item.toInt(&ok);
+ if (!ok)
+ return {};
+
+ if (number < 1)
+ return {};
+
+ result.push_back(std::make_pair(number, number));
+ }
+ }
+
+ // check no range intersects with the next
+ std::sort(result.begin(), result.end(), [](std::pair<int, int> it1, std::pair<int, int> it2) { return it1.first < it2.first; });
+ int previousSecond = -1;
+ for (auto pair : result) {
+ if (pair.first <= previousSecond)
+ return {};
+
+ previousSecond = pair.second;
+ }
+
+ return result;
+}
+
+static QString stringFromPageRanges(const std::vector<std::pair<int, int>> &pageRanges) Q_DECL_NOTHROW
+{
+ QString result;
+
+ for (auto pair : pageRanges) {
+ if (!result.isEmpty())
+ result += QLatin1Char(',');
+
+ if (pair.first == pair.second)
+ result += QString::number(pair.first);
+ else
+ result += QStringLiteral("%1-%2").arg(pair.first).arg(pair.second);
+ }
+
+ return result;
+}
+
+static bool isValidPagesString(const QString &pagesString) Q_DECL_NOTHROW
+{
+ if (pagesString.isEmpty())
+ return false;
+
+ auto pagesRanges = pageRangesFromString(pagesString);
+ return !pagesRanges.empty();
+}
+#endif
+
void QPrintDialogPrivate::setupPrinter()
{
// First setup the requested OutputFormat, Printer and Page Size first
@@ -605,6 +689,16 @@ void QPrintDialogPrivate::setupPrinter()
}
#if QT_CONFIG(cups)
+ if (options.pagesRadioButton->isChecked()) {
+ auto pageRanges = pageRangesFromString(options.pagesLineEdit->text());
+
+ p->setPrintRange(QPrinter::AllPages);
+ p->setFromTo(0, 0);
+
+ // server-side page filtering
+ QCUPSSupport::setPageRange(p, stringFromPageRanges(pageRanges));
+ }
+
// page set
if (p->printRange() == QPrinter::AllPages || p->printRange() == QPrinter::PageRange) {
//If the application is selecting pages and the first page number is even then need to adjust the odd-even accordingly
@@ -801,6 +895,16 @@ int QPrintDialog::exec()
void QPrintDialog::accept()
{
Q_D(QPrintDialog);
+#if QT_CONFIG(cups)
+ if (d->options.pagesRadioButton->isChecked() && !isValidPagesString(d->options.pagesLineEdit->text())) {
+ QMessageBox::critical(this, tr("Invalid pages definition"),
+ tr("%1 does not follow the correct syntax. Please use ',' to separate "
+ "ranges and pages, '-' to define ranges and make sure ranges do "
+ "not intersect with each other.").arg(d->options.pagesLineEdit->text()),
+ QMessageBox::Ok, QMessageBox::Ok);
+ return;
+ }
+#endif
d->setupPrinter();
QDialog::accept();
}
Index: qtbase-opensource-src-5.9.4/src/printsupport/dialogs/qprintsettingsoutput.ui
===================================================================
--- qtbase-opensource-src-5.9.4.orig/src/printsupport/dialogs/qprintsettingsoutput.ui
+++ qtbase-opensource-src-5.9.4/src/printsupport/dialogs/qprintsettingsoutput.ui
@@ -6,15 +6,24 @@
<rect>
<x>0</x>
<y>0</y>
- <width>426</width>
- <height>187</height>
+ <width>432</width>
+ <height>251</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -42,7 +51,16 @@
<property name="spacing">
<number>4</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <property name="bottomMargin">
<number>6</number>
</property>
<item>
@@ -60,7 +78,16 @@
<property name="spacing">
<number>6</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -119,6 +146,27 @@
</layout>
</item>
<item>
+ <layout class="QHBoxLayout" name="pagesLayout">
+ <item>
+ <widget class="QRadioButton" name="pagesRadioButton">
+ <property name="text">
+ <string>Pages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="pagesLineEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Specify pages or ranges separated by commas. Ranges are specified by two numbers separated by a hyphen. E.g: 3,5-7,9 prints pages 3, 5, 6, 7 and 9.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
<widget class="QRadioButton" name="printCurrentPage">
<property name="text">
<string>Current Page</string>
@@ -361,12 +409,12 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>76</x>
- <y>59</y>
+ <x>89</x>
+ <y>113</y>
</hint>
<hint type="destinationlabel">
- <x>122</x>
- <y>57</y>
+ <x>182</x>
+ <y>113</y>
</hint>
</hints>
</connection>
@@ -377,12 +425,28 @@
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
- <x>69</x>
- <y>67</y>
+ <x>82</x>
+ <y>113</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>267</x>
+ <y>113</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>pagesRadioButton</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>pagesLineEdit</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>58</x>
+ <y>132</y>
</hint>
<hint type="destinationlabel">
- <x>215</x>
- <y>67</y>
+ <x>163</x>
+ <y>128</y>
</hint>
</hints>
</connection>
Index: qtbase-opensource-src-5.9.4/src/printsupport/kernel/qcups.cpp
===================================================================
--- qtbase-opensource-src-5.9.4.orig/src/printsupport/kernel/qcups.cpp
+++ qtbase-opensource-src-5.9.4/src/printsupport/kernel/qcups.cpp
@@ -254,8 +254,13 @@ void QCUPSSupport::setPagesPerSheetLayou
void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo)
{
+ setPageRange(printer, QStringLiteral("%1-%2").arg(pageFrom).arg(pageTo));
+}
+
+void QCUPSSupport::setPageRange(QPrinter *printer, const QString &pageRange)
+{
QStringList cupsOptions = cupsOptionsList(printer);
- setCupsOption(cupsOptions, QStringLiteral("page-ranges"), QStringLiteral("%1-%2").arg(pageFrom).arg(pageTo));
+ setCupsOption(cupsOptions, QStringLiteral("page-ranges"), pageRange);
setCupsOptions(printer, cupsOptions);
}
Index: qtbase-opensource-src-5.9.4/src/printsupport/kernel/qcups_p.h
===================================================================
--- qtbase-opensource-src-5.9.4.orig/src/printsupport/kernel/qcups_p.h
+++ qtbase-opensource-src-5.9.4/src/printsupport/kernel/qcups_p.h
@@ -142,6 +142,7 @@ public:
static void setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
const PagesPerSheetLayout pagesPerSheetLayout);
static void setPageRange(QPrinter *printer, int pageFrom, int pageTo);
+ static void setPageRange(QPrinter *printer, const QString &pageRange);
struct JobSheets
{

View File

@ -1,237 +0,0 @@
From c45947aeefa1a83eda767edca4fd4c6f9404d3ff Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Fri, 29 Dec 2017 15:18:52 +0100
Subject: [PATCH] CUPS: Don't show choices that conflict with the printer
installed options
Some options only make sense if the printer has installed some extensions, e.g.
we should not shown "Staple" options if the Stapler addon is not installed,
so with this change we use ppdInstallableConflict to know whether an option
should be shown to the user or not.
Change-Id: I5733e1ac8b667c26b292aeafc90a10c155b751a4
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/plugins/printsupport/cups/qppdprintdevice.cpp | 15 +++++++-
src/plugins/printsupport/cups/qppdprintdevice.h | 1 +
src/printsupport/dialogs/qprintdialog_unix.cpp | 46 +++++++++++++++--------
src/printsupport/kernel/qcups_p.h | 1 +
src/printsupport/kernel/qplatformprintdevice.cpp | 8 ++++
src/printsupport/kernel/qplatformprintdevice.h | 1 +
src/printsupport/kernel/qprintdevice.cpp | 5 +++
src/printsupport/kernel/qprintdevice_p.h | 1 +
8 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 9c4b699..340b1a1 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -436,7 +436,7 @@ QVariant QPpdPrintDevice::property(QPrintDevice::PrintDevicePropertyKey key) con
else if (key == PDPK_CupsJobHoldUntil)
return printerOption(QStringLiteral("job-hold-until"));
- return QVariant();
+ return QPlatformPrintDevice::property(key);
}
bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value)
@@ -449,7 +449,18 @@ bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, cons
}
}
- return false;
+ return QPlatformPrintDevice::setProperty(key, value);
+}
+
+bool QPpdPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const
+{
+ if (key == PDPK_PpdChoiceIsInstallableConflict) {
+ const QStringList values = params.toStringList();
+ if (values.count() == 2)
+ return ppdInstallableConflict(m_ppd, values[0].toLatin1(), values[1].toLatin1());
+ }
+
+ return QPlatformPrintDevice::isFeatureAvailable(key, params);
}
#ifndef QT_NO_MIMETYPE
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.h b/src/plugins/printsupport/cups/qppdprintdevice.h
index 2e4dd3a..9867083 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.h
+++ b/src/plugins/printsupport/cups/qppdprintdevice.h
@@ -91,6 +91,7 @@ public:
QVariant property(QPrintDevice::PrintDevicePropertyKey key) const Q_DECL_OVERRIDE;
bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value) Q_DECL_OVERRIDE;
+ bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const Q_DECL_OVERRIDE;
protected:
void loadPageSizes() const Q_DECL_OVERRIDE;
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index ab38c24..22d7dd1 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -271,6 +271,7 @@ public:
{
}
+ // These indices are related to ppd_option_t::choices not to childItems
int selected;
int originallySelected;
};
@@ -1466,8 +1467,14 @@ void QPPDOptionsModel::parseOptions(QOptionTreeItem *parent)
for (int i = 0; i < group->num_options; ++i) {
if (!isBlacklistedOption(group->options[i].keyword)) {
QOptionTreeItemOption *opt = new QOptionTreeItemOption(i, &group->options[i], parent);
- parent->childItems.append(opt);
parseChoices(opt);
+
+ // Don't show options that are actually not options at all
+ // because they don't give the user any choice
+ if (opt->childItems.count() > 1)
+ parent->childItems.append(opt);
+ else
+ delete opt;
}
}
}
@@ -1477,15 +1484,18 @@ void QPPDOptionsModel::parseChoices(QOptionTreeItemOption *parent)
const ppd_option_t *option = static_cast<const ppd_option_t*>(parent->ptr);
bool marked = false;
for (int i = 0; i < option->num_choices; ++i) {
- QOptionTreeItem *choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], parent);
- if (static_cast<int>(option->choices[i].marked) == 1) {
- parent->selected = i;
- marked = true;
- } else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
- parent->selected = i;
+ const auto values = QStringList{} << QString::fromLatin1(option->keyword) << QString::fromLatin1(option->choices[i].choice);
+ if (!m_currentPrintDevice->isFeatureAvailable(PDPK_PpdChoiceIsInstallableConflict, values)) {
+ QOptionTreeItem *choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], parent);
+ if (static_cast<int>(option->choices[i].marked) == 1) {
+ parent->selected = i;
+ marked = true;
+ } else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
+ parent->selected = i;
+ }
+ parent->originallySelected = parent->selected;
+ parent->childItems.append(choice);
}
- parent->originallySelected = parent->selected;
- parent->childItems.append(choice);
}
}
@@ -1627,11 +1637,10 @@ void QPPDOptionsEditor::setEditorData(QWidget *editor, const QModelIndex &index)
const QPPDOptionsModel *m = static_cast<const QPPDOptionsModel*>(index.model());
for (auto *childItem : qAsConst(itm->childItems)) {
const ppd_choice_t *choice = static_cast<const ppd_choice_t*>(childItem->ptr);
- cb->addItem(m->cupsCodec()->toUnicode(choice->text));
+ cb->addItem(m->cupsCodec()->toUnicode(choice->text), childItem->index);
+ if (childItem->index == itm->selected)
+ cb->setCurrentIndex(cb->count() - 1);
}
-
- if (itm->selected > -1)
- cb->setCurrentIndex(itm->selected);
}
void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
@@ -1639,15 +1648,20 @@ void QPPDOptionsEditor::setModelData(QWidget *editor, QAbstractItemModel *model,
QComboBox *cb = static_cast<QComboBox*>(editor);
QOptionTreeItemOption *itm = static_cast<QOptionTreeItemOption*>(index.internalPointer());
- if (itm->selected == cb->currentIndex())
+ // We can't use cb->currentIndex() to know the index of the option in the choices[] array
+ // because some of them may not be present in the list because they conflict with the
+ // installable options so use the index passed on addItem
+ const int selectedChoiceIndex = cb->currentData().toInt();
+
+ if (itm->selected == selectedChoiceIndex || selectedChoiceIndex < 0)
return;
const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
QPPDOptionsModel *m = static_cast<QPPDOptionsModel*>(model);
- const auto values = QStringList{} << QString::fromLatin1(opt->keyword) << QString::fromLatin1(opt->choices[cb->currentIndex()].choice);
+ const auto values = QStringList{} << QString::fromLatin1(opt->keyword) << QString::fromLatin1(opt->choices[selectedChoiceIndex].choice);
m->currentPrintDevice()->setProperty(PDPK_PpdOption, values);
- itm->selected = cb->currentIndex();
+ itm->selected = selectedChoiceIndex;
m->emitConflictsChanged();
}
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index 0afa7fa..da2b087 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE
#define PDPK_CupsJobSheets QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 3)
#define PDPK_CupsJobBilling QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 4)
#define PDPK_CupsJobHoldUntil QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 5)
+#define PDPK_PpdChoiceIsInstallableConflict QPrintDevice::PrintDevicePropertyKey(QPrintDevice::PDPK_CustomBase + 6)
class Q_PRINTSUPPORT_EXPORT QCUPSSupport
{
diff --git a/src/printsupport/kernel/qplatformprintdevice.cpp b/src/printsupport/kernel/qplatformprintdevice.cpp
index 2f76156..8dba402 100644
--- a/src/printsupport/kernel/qplatformprintdevice.cpp
+++ b/src/printsupport/kernel/qplatformprintdevice.cpp
@@ -396,6 +396,14 @@ bool QPlatformPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key,
return false;
}
+bool QPlatformPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const
+{
+ Q_UNUSED(key)
+ Q_UNUSED(params)
+
+ return false;
+}
+
QList<QMimeType> QPlatformPrintDevice::supportedMimeTypes() const
{
if (!m_haveMimeTypes)
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
index 8af7646..a988518 100644
--- a/src/printsupport/kernel/qplatformprintdevice.h
+++ b/src/printsupport/kernel/qplatformprintdevice.h
@@ -123,6 +123,7 @@ public:
virtual QVariant property(QPrintDevice::PrintDevicePropertyKey key) const;
virtual bool setProperty(QPrintDevice::PrintDevicePropertyKey key, const QVariant &value);
+ virtual bool isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey key, const QVariant &params) const;
#ifndef QT_NO_MIMETYPE
virtual QList<QMimeType> supportedMimeTypes() const;
diff --git a/src/printsupport/kernel/qprintdevice.cpp b/src/printsupport/kernel/qprintdevice.cpp
index 2bc6906..50fc141 100644
--- a/src/printsupport/kernel/qprintdevice.cpp
+++ b/src/printsupport/kernel/qprintdevice.cpp
@@ -255,6 +255,11 @@ bool QPrintDevice::setProperty(PrintDevicePropertyKey key, const QVariant &value
return isValid() ? d->setProperty(key, value) : false;
}
+bool QPrintDevice::isFeatureAvailable(PrintDevicePropertyKey key, const QVariant &params) const
+{
+ return isValid() ? d->isFeatureAvailable(key, params) : false;
+}
+
#ifndef QT_NO_MIMETYPE
QList<QMimeType> QPrintDevice::supportedMimeTypes() const
{
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
index 3dff2e5..562ccd2 100644
--- a/src/printsupport/kernel/qprintdevice_p.h
+++ b/src/printsupport/kernel/qprintdevice_p.h
@@ -137,6 +137,7 @@ public:
QVariant property(PrintDevicePropertyKey key) const;
bool setProperty(PrintDevicePropertyKey key, const QVariant &value);
+ bool isFeatureAvailable(PrintDevicePropertyKey key, const QVariant &params) const;
#ifndef QT_NO_MIMETYPE
QList<QMimeType> supportedMimeTypes() const;
--
2.7.4

View File

@ -1,192 +0,0 @@
From e35878bf57f4107fa1a49a8a4d552ea5ce1b53a9 Mon Sep 17 00:00:00 2001
From: Albert Astals Cid <albert.astals.cid@kdab.com>
Date: Thu, 28 Dec 2017 17:51:43 +0100
Subject: [PATCH 1/1] CUPS: Rework set/clearCupsOption API
Previously it was a bit awkward to use, you had to do
QStringList cupsOptions = QCUPSSupport::cupsOptionsList(printer);
QCUPSSupport::setCupsOption(cupsOptions, option, value);
QCUPSSupport::setCupsOptions(printer, cupsOptions);
now you simply have to do
QCUPSSupport::setCupsOption(printer, option, value);
Change-Id: Id31583f1ec72644791d82776debbae5583a2be54
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 4 +--
src/printsupport/kernel/qcups.cpp | 44 ++++++++++----------------
src/printsupport/kernel/qcups_p.h | 6 ++--
3 files changed, 20 insertions(+), 34 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 47e2fa5..ab38c24 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -1417,9 +1417,7 @@ void QPPDOptionsModel::setCupsOptionsFromItems(QPrinter *printer, QOptionTreeIte
QOptionTreeItemOption *itmOption = static_cast<QOptionTreeItemOption *>(itm);
const ppd_option_t *opt = static_cast<const ppd_option_t*>(itm->ptr);
if (qstrcmp(opt->defchoice, opt->choices[itmOption->selected].choice) != 0) {
- QStringList cupsOptions = QCUPSSupport::cupsOptionsList(printer);
- QCUPSSupport::setCupsOption(cupsOptions, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itmOption->selected].choice));
- QCUPSSupport::setCupsOptions(printer, cupsOptions);
+ QCUPSSupport::setCupsOption(printer, QString::fromLatin1(opt->keyword), QString::fromLatin1(opt->choices[itmOption->selected].choice));
}
} else {
setCupsOptionsFromItems(printer, itm);
diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp
index 115ecb0..be170ed 100644
--- a/src/printsupport/kernel/qcups.cpp
+++ b/src/printsupport/kernel/qcups.cpp
@@ -43,33 +43,37 @@
QT_BEGIN_NAMESPACE
-QStringList QCUPSSupport::cupsOptionsList(QPrinter *printer)
+static QStringList cupsOptionsList(QPrinter *printer) Q_DECL_NOTHROW
{
return printer->printEngine()->property(PPK_CupsOptions).toStringList();
}
-void QCUPSSupport::setCupsOptions(QPrinter *printer, const QStringList &cupsOptions)
+void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions) Q_DECL_NOTHROW
{
printer->printEngine()->setProperty(PPK_CupsOptions, QVariant(cupsOptions));
}
-void QCUPSSupport::setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value)
+void QCUPSSupport::setCupsOption(QPrinter *printer, const QString &option, const QString &value)
{
+ QStringList cupsOptions = cupsOptionsList(printer);
if (cupsOptions.contains(option)) {
cupsOptions.replace(cupsOptions.indexOf(option) + 1, value);
} else {
cupsOptions.append(option);
cupsOptions.append(value);
}
+ setCupsOptions(printer, cupsOptions);
}
-void QCUPSSupport::clearCupsOption(QStringList &cupsOptions, const QString &option)
+void QCUPSSupport::clearCupsOption(QPrinter *printer, const QString &option)
{
+ QStringList cupsOptions = cupsOptionsList(printer);
// ### use const_iterator once QList::erase takes them
const QStringList::iterator it = std::find(cupsOptions.begin(), cupsOptions.end(), option);
if (it != cupsOptions.end()) {
Q_ASSERT(it + 1 < cupsOptions.end());
cupsOptions.erase(it, it+1);
+ setCupsOptions(printer, cupsOptions);
}
}
@@ -140,30 +144,24 @@ QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString
void QCUPSSupport::setJobHold(QPrinter *printer, const JobHoldUntil jobHold, const QTime &holdUntilTime)
{
- QStringList cupsOptions = cupsOptionsList(printer);
const QString jobHoldUntilArgument = jobHoldToString(jobHold, holdUntilTime);
if (!jobHoldUntilArgument.isEmpty()) {
- setCupsOption(cupsOptions,
+ setCupsOption(printer,
QStringLiteral("job-hold-until"),
jobHoldUntilArgument);
} else {
- clearCupsOption(cupsOptions, QStringLiteral("job-hold-until"));
+ clearCupsOption(printer, QStringLiteral("job-hold-until"));
}
- setCupsOptions(printer, cupsOptions);
}
void QCUPSSupport::setJobBilling(QPrinter *printer, const QString &jobBilling)
{
- QStringList cupsOptions = cupsOptionsList(printer);
- setCupsOption(cupsOptions, QStringLiteral("job-billing"), jobBilling);
- setCupsOptions(printer, cupsOptions);
+ setCupsOption(printer, QStringLiteral("job-billing"), jobBilling);
}
void QCUPSSupport::setJobPriority(QPrinter *printer, int priority)
{
- QStringList cupsOptions = cupsOptionsList(printer);
- setCupsOption(cupsOptions, QStringLiteral("job-priority"), QString::number(priority));
- setCupsOptions(printer, cupsOptions);
+ setCupsOption(printer, QStringLiteral("job-priority"), QString::number(priority));
}
static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPage)
@@ -209,17 +207,14 @@ QCUPSSupport::JobSheets QCUPSSupport::parseJobSheets(const QString &jobSheets)
void QCUPSSupport::setBannerPages(QPrinter *printer, const BannerPage startBannerPage, const BannerPage endBannerPage)
{
- QStringList cupsOptions = cupsOptionsList(printer);
const QString startBanner = bannerPageToString(startBannerPage);
const QString endBanner = bannerPageToString(endBannerPage);
- setCupsOption(cupsOptions, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner);
- setCupsOptions(printer, cupsOptions);
+ setCupsOption(printer, QStringLiteral("job-sheets"), startBanner + QLatin1Char(',') + endBanner);
}
void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet)
{
- QStringList cupsOptions = cupsOptionsList(printer);
QString pageSetString;
switch (pageSet) {
@@ -234,22 +229,19 @@ void QCUPSSupport::setPageSet(QPrinter *printer, const PageSet pageSet)
break;
}
- setCupsOption(cupsOptions, QStringLiteral("page-set"), pageSetString);
- setCupsOptions(printer, cupsOptions);
+ setCupsOption(printer, QStringLiteral("page-set"), pageSetString);
}
void QCUPSSupport::setPagesPerSheetLayout(QPrinter *printer, const PagesPerSheet pagesPerSheet,
const PagesPerSheetLayout pagesPerSheetLayout)
{
- QStringList cupsOptions = cupsOptionsList(printer);
// WARNING: the following trick (with a [2]-extent) only works as
// WARNING: long as there's only one two-digit number in the list
// WARNING: and it is the last one (before the "\0")!
static const char pagesPerSheetData[][2] = { "1", "2", "4", "6", "9", {'1', '6'}, "\0" };
static const char pageLayoutData[][5] = {"lrtb", "lrbt", "rlbt", "rltb", "btlr", "btrl", "tblr", "tbrl"};
- setCupsOption(cupsOptions, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet]));
- setCupsOption(cupsOptions, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout]));
- setCupsOptions(printer, cupsOptions);
+ setCupsOption(printer, QStringLiteral("number-up"), QLatin1String(pagesPerSheetData[pagesPerSheet]));
+ setCupsOption(printer, QStringLiteral("number-up-layout"), QLatin1String(pageLayoutData[pagesPerSheetLayout]));
}
void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo)
@@ -259,9 +251,7 @@ void QCUPSSupport::setPageRange(QPrinter *printer, int pageFrom, int pageTo)
void QCUPSSupport::setPageRange(QPrinter *printer, const QString &pageRange)
{
- QStringList cupsOptions = cupsOptionsList(printer);
- setCupsOption(cupsOptions, QStringLiteral("page-ranges"), pageRange);
- setCupsOptions(printer, cupsOptions);
+ setCupsOption(printer, QStringLiteral("page-ranges"), pageRange);
}
QT_END_NAMESPACE
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index a5af4bc..0afa7fa 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -129,10 +129,8 @@ public:
TopToBottomRightToLeft
};
- static QStringList cupsOptionsList(QPrinter *printer);
- static void setCupsOptions(QPrinter *printer, const QStringList &cupsOptions);
- static void setCupsOption(QStringList &cupsOptions, const QString &option, const QString &value);
- static void clearCupsOption(QStringList &cupsOptions, const QString &option);
+ static void setCupsOption(QPrinter *printer, const QString &option, const QString &value);
+ static void clearCupsOption(QPrinter *printer, const QString &option);
static void setJobHold(QPrinter *printer, const JobHoldUntil jobHold = NoHold, const QTime &holdUntilTime = QTime());
static void setJobBilling(QPrinter *printer, const QString &jobBilling = QString());
--
2.7.4

View File

@ -1,40 +0,0 @@
From 6e4a330d615e5d35931658023a30cc375bcfd0e5 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@qt.io>
Date: Wed, 17 Jan 2018 11:42:58 +0100
Subject: [PATCH] Cups Print Dialog: Change the message box titles to Caps
Amends 608301d4c81ce65804a088aaebbd5433a56d69d7.
Task-number: QTBUG-1311
Change-Id: I01cd60f0676f4e0501d411151492b4f867653053
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index cac3e9ebcb..2cc5bfbb8c 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -441,7 +441,7 @@ void QPrintPropertiesDialog::accept()
#if QT_CONFIG(cups)
if (m_cupsOptionsModel->hasConflicts()) {
widget.tabs->setCurrentWidget(widget.cupsPropertiesPage);
- const QMessageBox::StandardButton answer = QMessageBox::warning(this, tr("Advanced option conflicts"),
+ const QMessageBox::StandardButton answer = QMessageBox::warning(this, tr("Advanced Option Conflicts"),
tr("There are conflicts in some advanced options. Do you want to fix them?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer != QMessageBox::No)
@@ -916,7 +916,7 @@ void QPrintDialog::accept()
Q_D(QPrintDialog);
#if QT_CONFIG(cups)
if (d->options.pagesRadioButton->isChecked() && !isValidPagesString(d->options.pagesLineEdit->text())) {
- QMessageBox::critical(this, tr("Invalid pages definition"),
+ QMessageBox::critical(this, tr("Invalid Pages Definition"),
tr("%1 does not follow the correct syntax. Please use ',' to separate "
"ranges and pages, '-' to define ranges and make sure ranges do "
"not intersect with each other.").arg(d->options.pagesLineEdit->text()),
--
2.15.1

View File

@ -1,28 +0,0 @@
From a79d9da8e0bbc69053d00dd1ff1dd55c47258291 Mon Sep 17 00:00:00 2001
From: =?utf8?q?S=C3=A9rgio=20Martins?= <iamsergio@gmail.com>
Date: Mon, 8 Jan 2018 15:58:57 +0000
Subject: [PATCH] Fix build due to missing QDebug include
The build just passes on Qt CI by chance.
Change-Id: I3bfef12b48df22fa64d92af9cd345bfc984c9923
Reviewed-by: David Faure <david.faure@kdab.com>
---
src/printsupport/dialogs/qprintdialog_unix.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index fcb53f4..02d6903 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -48,6 +48,7 @@
#if QT_CONFIG(filedialog)
#include "qfiledialog.h"
#endif
+#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qtextcodec.h>
#include <QtGui/qevent.h>
--
2.7.4

View File

@ -4,10 +4,10 @@ References: QTBUG-37417
This is broken for shadow builds otherwise.
Index: qtbase-opensource-src-5.9.1/mkspecs/features/create_cmake.prf
Index: qtbase-everywhere-src-5.11.0-beta4/mkspecs/features/create_cmake.prf
===================================================================
--- qtbase-opensource-src-5.9.1.orig/mkspecs/features/create_cmake.prf
+++ qtbase-opensource-src-5.9.1/mkspecs/features/create_cmake.prf
--- qtbase-everywhere-src-5.11.0-beta4.orig/mkspecs/features/create_cmake.prf
+++ qtbase-everywhere-src-5.11.0-beta4/mkspecs/features/create_cmake.prf
@@ -30,7 +30,6 @@ CMAKE_MODULE_NAME = $$cmakeModuleName($$
split_incpath {
@ -16,11 +16,13 @@ Index: qtbase-opensource-src-5.9.1/mkspecs/features/create_cmake.prf
CMAKE_SOURCE_INCLUDES = \
$$cmakeTargetPaths($$QT_MODULE_INCLUDE_BASE $$QT_MODULE_INCLUDE_BASE/Qt$${CMAKE_MODULE_NAME})
CMAKE_SOURCE_PRIVATE_INCLUDES = \
@@ -53,8 +52,6 @@ contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*"
@@ -53,10 +52,6 @@ contains(CMAKE_INCLUDE_DIR, "^\\.\\./.*"
CMAKE_INCLUDE_DIR_IS_ABSOLUTE = True
}
-!exists($$first(QT.$${MODULE}_private.includes)): CMAKE_NO_PRIVATE_INCLUDES = true
-isEmpty(QT.$${MODULE}_private.includes)| \
- !exists($$first(QT.$${MODULE}_private.includes)): \
- CMAKE_NO_PRIVATE_INCLUDES = true
-
CMAKE_LIB_DIR = $$cmakeRelativePath($$[QT_INSTALL_LIBS], $$[QT_INSTALL_PREFIX])
contains(CMAKE_LIB_DIR,"^\\.\\./.*") {

View File

@ -1,39 +0,0 @@
Do not use SHM if display name doesn't look local.
Verifying availability of SHM only by using response of SHM Attach is not
reliable. There is always small chance that when we are a remote client of X
server, we'll get shmid that is already in use by some local X client. In that
case X server can not recognize that it is not accessing our shared memory but
the one of the other client and will report success.
This adds check for display name equivalent to one that was in Qt4. Determining
whether the connection is local/remote from display name is not 100% reliable,
but worked fine for years in Qt4.
Signed-off-by: Michal Srb <msrb@suse.com>
Index: qtbase-opensource-src-5.9.1/src/plugins/platforms/xcb/qxcbbackingstore.cpp
===================================================================
--- qtbase-opensource-src-5.9.1.orig/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ qtbase-opensource-src-5.9.1/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -178,7 +178,8 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *s
m_shm_info.shmseg = xcb_generate_id(xcb_connection());
const xcb_query_extension_reply_t *shm_reply = xcb_get_extension_data(xcb_connection(), &xcb_shm_id);
- bool shm_present = shm_reply != NULL && shm_reply->present;
+ bool is_local = (!displayName() || displayName()[0] == ':');
+ bool shm_present = is_local && shm_reply != NULL && shm_reply->present;
xcb_generic_error_t *error = NULL;
if (shm_present)
error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false));
Index: qtbase-opensource-src-5.9.1/src/plugins/platforms/xcb/qxcbobject.h
===================================================================
--- qtbase-opensource-src-5.9.1.orig/src/plugins/platforms/xcb/qxcbobject.h
+++ qtbase-opensource-src-5.9.1/src/plugins/platforms/xcb/qxcbobject.h
@@ -54,6 +54,7 @@ public:
xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_connection->atom(atom); }
xcb_connection_t *xcb_connection() const { return m_connection->xcb_connection(); }
+ const char *displayName() const { return m_connection->displayName(); }
private:
QXcbConnection *m_connection;

View File

@ -1,3 +1,23 @@
-------------------------------------------------------------------
Tue May 22 15:06:56 CEST 2018 - fabian@ritter-vogt.de
- Update to 5.11.0
* New bugfix release
* For more details please see:
* http://code.qt.io/cgit/qt/qtbase.git/plain/dist/changes-5.11.0/?h=v5.11.0
- Remove patches, now upstream:
* 0001-Do-a-static_cast-in-bit-blasts-that-are-UB.patch
* 0001-sqlite-Check-that-there-are-values-to-be-set-when-bi.patch
* 0002-sqlite-Bind-duplicated-named-placeholders-correctly.patch
* 0003-sqlite-Prevent-a-crash-when-sqlite-does-not-detect-a.patch
-------------------------------------------------------------------
Tue May 8 10:59:01 CEST 2018 - fabian@ritter-vogt.de
- Update to 5.11.0-rc
* New bugfix release
* No changelog available
-------------------------------------------------------------------
Fri Apr 27 16:25:43 UTC 2018 - fabian@ritter-vogt.de
@ -6,12 +26,42 @@ Fri Apr 27 16:25:43 UTC 2018 - fabian@ritter-vogt.de
* 0002-sqlite-Bind-duplicated-named-placeholders-correctly.patch
* 0003-sqlite-Prevent-a-crash-when-sqlite-does-not-detect-a.patch
-------------------------------------------------------------------
Mon Apr 23 08:55:13 CEST 2018 - fabian@ritter-vogt.de
- Update to 5.11.0-beta4
* New bugfix release
* No changelog available
- Refresh patches:
* force-cmake-private-headers.patch
- Remove patches, now upstream:
* 0001-Extend-the-MariaDB-define-check-to-cover-the-later-v.patch
-------------------------------------------------------------------
Wed Apr 11 09:13:30 CEST 2018 - fabian@ritter-vogt.de
- Update to 5.11.0-beta3
* New bugfix release
* No changelog available
-------------------------------------------------------------------
Wed Mar 28 09:17:05 CEST 2018 - fabian@ritter-vogt.de
- Update to 5.11.0-beta2
* New bugfix release
* No changelog available
-------------------------------------------------------------------
Tue Mar 27 18:22:40 UTC 2018 - fabian@ritter-vogt.de
- Add patch to fix build with GCC 8 (boo#1087073):
* 0001-Do-a-static_cast-in-bit-blasts-that-are-UB.patch
-------------------------------------------------------------------
Tue Mar 13 13:40:37 UTC 2018 - christophe@krop.fr
- Fix the license tag.
-------------------------------------------------------------------
Fri Mar 9 15:15:25 UTC 2018 - crrodriguez@opensuse.org
@ -37,11 +87,93 @@ Thu Mar 1 12:14:13 UTC 2018 - alarrosa@suse.com
the QT_ENABLE_PRINTER_DISCOVERY environment variable is set
(QT_DISABLE_PRINTER_DISCOVERY is no longer used).
-------------------------------------------------------------------
Thu Mar 1 09:54:43 CET 2018 - fabian@ritter-vogt.de
- Update to 5.11.0-beta1
* New feature release
* For more details please see:
* http://code.qt.io/cgit/qt/qtbase.git/plain/dist/changes-5.11.0-beta1/?h=v5.11.0-beta1
- Remove patches, now upstream:
* libqt5-do-not-use-shm-if-display-name-doesnt-look-local.patch
* opengl-Bail-if-cached-shader-fails-to-load.patch
* 0001-Revert-QHeaderView-properly-restore-section-data-aft.patch
* 0002-Revert-QHeaderView-Simplify-and-fix-layoutChange-han.patch
-------------------------------------------------------------------
Fri Feb 23 09:00:44 UTC 2018 - fabian@ritter-vogt.de
- Enable journald support (boo#1050461)
-------------------------------------------------------------------
Tue Feb 20 14:27:51 CET 2018 - fabian@ritter-vogt.de
- Update to 5.11.0-alpha
* New feature release
* For more details please see:
* https://wiki.qt.io/New_Features_in_Qt_5.11
- Refresh patches:
* 0001-Add-remote-print-queue-support.patch
* 0001-Revert-QHeaderView-properly-restore-section-data-aft.patch
- Remove patches, now upstream:
* 0001-QSimpleDrag-Fix-mouse-release-coords-for-delayed-eve.patch
* 0001-Remove-QPrintDialogPrivate-applyPrinterProperties-no.patch
* 0002-CUPS-Use-default-cups-job-priority-instead-of-50.patch
* 0002-Remove-QUnixPrintWidgetPrivate-applyPrinterPropertie.patch
* 0003-QPageSetupWidget-setPrinter-Use-printdevice-default-paper-size.patch
* 0003-Remove-QPrintPropertiesDialog-applyPrinterProperties.patch
* 0004-Fix-custom-page-size-handling-in-the-Unix-print-dial.patch
* 0004-Remove-QCupsJobWidget-setPrinter.patch
* 0005-CUPS-Refactor-the-code-a-bit.patch
* 0005-Remove-QPrintPropertiesDialog-selectPrinter.patch
* 0006-Refactor-QPPDOptionsModel-a-bit.patch
* 0006-Remove-QPageSetupWidget-selectPrinter.patch
* 0007-CUPS-Fix-advanced-options-cancel-of-the-print-properties-dialog.patch
* 0007-Introduce-QPrintDevice-property-setProperty.patch
* 0008-Allow-access-to-ppd-file-and-ppdMarkOption-via-QPpdP.patch
* 0008-CUPS-Fix-conflict-handling.patch
* 0009-CUPS-Use-printer-job-sheets-as-default-instead-of-none-none.patch
* 0009-QPlatformPrintDevice-use-QVector-not-QList-in-the-AP.patch
* 0010-CUPS-Use-printer-job-billing-as-default-instead-of-the-empty-string.patch
* 0010-Reintroduce-the-Advanced-tab-in-the-QPrintProperties.patch
* 0011-CUPS-Use-printer-job-hold-until-as-default-instead-of-the-nohold.patch
* 0011-QtPrintSupport-Fix-build.patch
* 0012-Unix-Fix-usability-of-the-print-properties-dialog.patch
* 0013-cups-Dont-show-InstallableOptions-in-the-advanced-properties-tab.patch
* 0014-CUPS-Enable-printing-arbitrary-pages-and-page-ranges.patch
* 0015-CUPS-Dont-show-choices-that-conflict-with-the-printer-installed-options.patch
* 0016-CUPS-Rework-set-clearCupsOption-API.patch
* 0017-Cups-Print-Dialog-Change-the-message-box-titles-to-C.patch
* 0018-Fix-build-due-to-missing-QDebug-include.patch
-------------------------------------------------------------------
Mon Feb 19 08:45:27 UTC 2018 - fabian@ritter-vogt.de
- Revert upstream commits to make saving of header sections work again:
* 0001-Revert-QHeaderView-properly-restore-section-data-aft.patch
* 0002-Revert-QHeaderView-Simplify-and-fix-layoutChange-han.patch
-------------------------------------------------------------------
Wed Feb 14 15:44:11 CET 2018 - fabian@ritter-vogt.de
- Update to 5.10.1
* New bugfix release
* For more details please see:
* http://code.qt.io/cgit/qt/qtbase.git/plain/dist/changes-5.10.1/?h=v5.10.1
- Drop patches, now upstream:
* 0001-xcb-verify-if-xrandr-present-before-using-xcb_randr-.patch
* 0001-Avoid-providing-bad-pixelDeltas-on-X11.patch
- Refresh patches:
* 0001-Extend-the-MariaDB-define-check-to-cover-the-later-v.patch
* 0003-Remove-QPrintPropertiesDialog-applyPrinterProperties.patch
* 0004-Remove-QCupsJobWidget-setPrinter.patch
* 0005-Remove-QPrintPropertiesDialog-selectPrinter.patch
* 0006-Remove-QPageSetupWidget-selectPrinter.patch
* 0003-QPageSetupWidget-setPrinter-Use-printdevice-default-paper-size.patch
* 0004-Fix-custom-page-size-handling-in-the-Unix-print-dial.patch
* 0011-CUPS-Use-printer-job-hold-until-as-default-instead-of-the-nohold.patch
* 0012-Unix-Fix-usability-of-the-print-properties-dialog.patch
-------------------------------------------------------------------
Mon Feb 12 14:21:22 UTC 2018 - mstaudt@suse.com

View File

@ -27,23 +27,26 @@
%if 0%{?suse_version} >= 1330
%global vulkan 1
%bcond_without harfbuzz
%else
# Harfbuzz too old
%bcond_with harfbuzz
# Vulkan headers too old
%global vulkan 0
%endif
Name: libqt5-qtbase
Version: 5.10.0
Version: 5.11.0
Release: 0
Summary: C++ Program Library, Core Components
License: LGPL-2.1-with-Qt-Company-Qt-exception-1.1 or LGPL-3.0-with-Qt-Company-Qt-exception-1.1
License: LGPL-2.1-with-Qt-Company-Qt-exception-1.1 or LGPL-3.0-only
Group: System/Libraries
Url: https://www.qt.io
%define base_name libqt5
%define real_version 5.10.0
%define so_version 5.10.0
%define tar_version qtbase-everywhere-src-5.10.0
Source: https://download.qt.io/official_releases/qt/5.10/%{real_version}/submodules/%{tar_version}.tar.xz
%define real_version 5.11.0
%define so_version 5.11.0
%define tar_version qtbase-everywhere-src-5.11.0
Source: https://download.qt.io/official_releases/qt/5.11/%{real_version}/submodules/%{tar_version}.tar.xz
# to get mtime of file:
Source1: libqt5-qtbase.changes
Source2: macros.qt5
@ -52,8 +55,6 @@ Source99: libqt5-qtbase-rpmlintrc
# patches 0-1000 are openSUSE and/or non-upstream(able) patches #
# PATCH-FIX-SUSE libqt5-Fix-Gujarati-font.patch bnc#878292 fix broken Gujarati font rendering
Patch3: libqt5-Fix-Gujarati-font.patch
# Patch-FIX-SUSE libqt5-do-not-use-shm-if-display-name-doesnt-look-local.patch -- bnc#888858
Patch5: libqt5-do-not-use-shm-if-display-name-doesnt-look-local.patch
# PATCH-FIX-OPENSUSE disable-rc4-ciphers-bnc865241.diff bnc#865241-- Exclude rc4 ciphers from being used by default
Patch6: disable-rc4-ciphers-bnc865241.diff
Patch8: tell-the-truth-about-private-api.patch
@ -65,46 +66,8 @@ Patch12: 0001-Add-remote-print-queue-support.patch
Patch15: force-cmake-private-headers.patch
# PATCH-FIX-UPSTREAM
Patch17: qapplication-emit-palettechanged.patch
# PATCH-FIX-UPSTREAM
Patch18: opengl-Bail-if-cached-shader-fails-to-load.patch
# patches 1000- 2000 and above from upstream 5.10 branch #
Patch1000: 0001-xcb-verify-if-xrandr-present-before-using-xcb_randr-.patch
Patch1001: 0001-Avoid-providing-bad-pixelDeltas-on-X11.patch
Patch1002: 0001-QSimpleDrag-Fix-mouse-release-coords-for-delayed-eve.patch
Patch1003: 0001-Extend-the-MariaDB-define-check-to-cover-the-later-v.patch
# patches 2000-3000 and above from upstream 5.11/dev branch #
Patch2000: 0001-Remove-QPrintDialogPrivate-applyPrinterProperties-no.patch
Patch2001: 0002-Remove-QUnixPrintWidgetPrivate-applyPrinterPropertie.patch
Patch2002: 0003-Remove-QPrintPropertiesDialog-applyPrinterProperties.patch
Patch2003: 0004-Remove-QCupsJobWidget-setPrinter.patch
Patch2004: 0005-Remove-QPrintPropertiesDialog-selectPrinter.patch
Patch2005: 0006-Remove-QPageSetupWidget-selectPrinter.patch
Patch2006: 0007-Introduce-QPrintDevice-property-setProperty.patch
Patch2007: 0008-Allow-access-to-ppd-file-and-ppdMarkOption-via-QPpdP.patch
Patch2008: 0009-QPlatformPrintDevice-use-QVector-not-QList-in-the-AP.patch
Patch2009: 0010-Reintroduce-the-Advanced-tab-in-the-QPrintProperties.patch
Patch2010: 0011-QtPrintSupport-Fix-build.patch
Patch2012: 0002-CUPS-Use-default-cups-job-priority-instead-of-50.patch
Patch2013: 0003-QPageSetupWidget-setPrinter-Use-printdevice-default-paper-size.patch
Patch2014: 0004-Fix-custom-page-size-handling-in-the-Unix-print-dial.patch
Patch2015: 0005-CUPS-Refactor-the-code-a-bit.patch
Patch2016: 0006-Refactor-QPPDOptionsModel-a-bit.patch
Patch2017: 0007-CUPS-Fix-advanced-options-cancel-of-the-print-properties-dialog.patch
Patch2018: 0008-CUPS-Fix-conflict-handling.patch
Patch2019: 0009-CUPS-Use-printer-job-sheets-as-default-instead-of-none-none.patch
Patch2020: 0010-CUPS-Use-printer-job-billing-as-default-instead-of-the-empty-string.patch
Patch2021: 0011-CUPS-Use-printer-job-hold-until-as-default-instead-of-the-nohold.patch
Patch2022: 0012-Unix-Fix-usability-of-the-print-properties-dialog.patch
Patch2023: 0013-cups-Dont-show-InstallableOptions-in-the-advanced-properties-tab.patch
Patch2024: 0014-CUPS-Enable-printing-arbitrary-pages-and-page-ranges.patch
Patch2025: 0015-CUPS-Dont-show-choices-that-conflict-with-the-printer-installed-options.patch
Patch2026: 0016-CUPS-Rework-set-clearCupsOption-API.patch
Patch2027: 0017-Cups-Print-Dialog-Change-the-message-box-titles-to-C.patch
Patch2028: 0018-Fix-build-due-to-missing-QDebug-include.patch
Patch2029: 0001-Do-a-static_cast-in-bit-blasts-that-are-UB.patch
Patch2030: 0001-sqlite-Check-that-there-are-values-to-be-set-when-bi.patch
Patch2031: 0002-sqlite-Bind-duplicated-named-placeholders-correctly.patch
Patch2032: 0003-sqlite-Prevent-a-crash-when-sqlite-does-not-detect-a.patch
# patches 1000- 2000 and above from upstream 5.11 branch #
# patches 2000-3000 and above from upstream 5.12/dev branch #
BuildRequires: alsa-devel
BuildRequires: cups-devel
BuildRequires: double-conversion-devel
@ -166,7 +129,9 @@ BuildRequires: pkgconfig(x11-xcb)
BuildRequires: xz
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gtk+-3.0)
%if %{with harfbuzz}
BuildRequires: pkgconfig(harfbuzz)
%endif
BuildRequires: pkgconfig(ice)
BuildRequires: pkgconfig(libinput)
BuildRequires: pkgconfig(libudev)
@ -632,6 +597,14 @@ Requires: libQt5Gui5 = %{version}
%description platformtheme-gtk3
Qt 5 plugin for better integration with gtk3-based desktop enviroments.
%package platformtheme-flatpak
Summary: Qt 5 Flatpak plugin
Group: Development/Libraries/C and C++
Requires: libQt5Gui5 = %{version}
%description platformtheme-flatpak
Qt 5 plugin for integration with flatpak.
%package -n libQt5Gui-devel
Summary: Development files for the Qt5 GUI library
Group: Development/Libraries/C and C++
@ -893,7 +866,9 @@ echo yes | ./configure \
-system-libjpeg \
-openssl-linked \
-system-libpng \
%if %{with harfbuzz}
-system-harfbuzz \
%endif
-fontconfig \
-system-freetype \
-cups \
@ -1224,6 +1199,12 @@ popd
%dir %{libqt5_plugindir}/platformthemes
%{libqt5_plugindir}/platformthemes/libqgtk3.so
%files platformtheme-flatpak
%defattr(-,root,root,755)
%doc *.txt LICENSE.*
%dir %{libqt5_plugindir}/platformthemes
%{libqt5_plugindir}/platformthemes/libqflatpak.so
%files -n libQt5Gui-devel
%defattr(-,root,root,755)
%doc *.txt LICENSE.*

View File

@ -1,79 +0,0 @@
From 3bb3ee936f27e9749bf1a2c4bd5ded2f5167663f Mon Sep 17 00:00:00 2001
From: Max Staudt <mstaudt@suse.de>
Date: Mon, 12 Feb 2018 15:07:29 +0100
Subject: [PATCH] opengl: Bail if cached shader fails to load
References: boo#1080578, boo#1079465
Signed-off-by: Max Staudt <mstaudt@suse.de>
QOpenGLProgramBinaryCache::setProgramBinary() should check
GL_LINK_STATUS after glProgramBinary(), but doesn't.
In practice, this means that SDDM is a white screen, and KDE is just
a gray task bar.
So far, Qt tries to check this using its internal ::link() function.
But in case the cached binary fails to load, Qt currently attempts to
link the inexistent program, resulting in a zero-length, fixed
pipeline shader.
Checking this already in ::setProgramBinary() makes the call to
::link() superfluous, so we remove that as well.
Many thanks to Michal Srb and Fabian Vogt for hunting this down.
This was truly a joint effort.
Cc: Michal Srb <msrb@suse.com>
Cc: Fabian Vogt <fvogt@suse.de>
Signed-off-by: Max Staudt <mstaudt@suse.de>
---
src/gui/opengl/qopenglprogrambinarycache.cpp | 11 ++++++++++-
src/gui/opengl/qopenglshaderprogram.cpp | 8 +-------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/gui/opengl/qopenglprogrambinarycache.cpp b/src/gui/opengl/qopenglprogrambinarycache.cpp
index 06373e1113..f50878ab5c 100644
--- a/src/gui/opengl/qopenglprogrambinarycache.cpp
+++ b/src/gui/opengl/qopenglprogrambinarycache.cpp
@@ -161,10 +161,19 @@ bool QOpenGLProgramBinaryCache::setProgramBinary(uint programId, uint blobFormat
QOpenGLExtraFunctions *funcs = QOpenGLContext::currentContext()->extraFunctions();
while (funcs->glGetError() != GL_NO_ERROR) { }
funcs->glProgramBinary(programId, blobFormat, p, blobSize);
+
int err = funcs->glGetError();
+ GLint link_status = 0;
+ funcs->glGetProgramiv(programId, GL_LINK_STATUS, &link_status);
+ if (link_status != GL_TRUE || err != GL_NO_ERROR) {
+ qCDebug(DBG_SHADER_CACHE, "Program binary failed to load for program %u, size %d, format 0x%x, link_status = 0x%x, err = 0x%x",
+ programId, blobSize, blobFormat, link_status, err);
+ return false;
+ }
+
qCDebug(DBG_SHADER_CACHE, "Program binary set for program %u, size %d, format 0x%x, err = 0x%x",
programId, blobSize, blobFormat, err);
- return err == 0;
+ return true;
}
#ifdef Q_OS_UNIX
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index cc8af16bfe..3b82baccb3 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -3824,13 +3824,7 @@ bool QOpenGLShaderProgramPrivate::linkBinary()
bool needsCompile = true;
if (binCache.load(cacheKey, q->programId())) {
qCDebug(DBG_SHADER_CACHE, "Program binary received from cache");
- linkBinaryRecursion = true;
- bool ok = q->link();
- linkBinaryRecursion = false;
- if (ok)
- needsCompile = false;
- else
- qCDebug(DBG_SHADER_CACHE, "Link failed after glProgramBinary");
+ needsCompile = false;
}
bool needsSave = false;
--
2.13.6

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fd5578cd320a13617c12cf2b19439386b203d6d45548e855f94e07be9829f762
size 45851596

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ed6e46db84f7d34923ab4eae165c63e05ab3cfa9d19a73d3f57b4e7bfd41de66
size 46803416