summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-05-27 16:20:25 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-05-27 16:20:25 +0200
commita275f1eca3de6c497535e43d6452e89b5380fd8d (patch)
tree3dbb5be04cdd42a7350ce0035b973f3f68ce6bd7
parentb4f83596ca0091e81115b0f1ad1f9c8a1d5a5f9c (diff)
parentcc4c0b43a54d9606f491c193df381a424ae696bf (diff)
Merge 5.12 into 5.12.4
-rw-r--r--qmake/generators/makefile.cpp22
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h151
-rw-r--r--src/gui/kernel/qpalette.cpp5
-rw-r--r--src/gui/text/qtextodfwriter.cpp88
-rw-r--r--src/plugins/platforms/xcb/qxcbdrag.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp9
-rw-r--r--src/widgets/kernel/qwidget_p.h2
-rw-r--r--src/widgets/util/qcompleter.cpp40
-rw-r--r--src/widgets/widgets/qmenu.cpp7
-rw-r--r--src/xml/doc/src/qtxml-index.qdoc6
-rw-r--r--src/xml/doc/src/qtxml.qdoc6
-rw-r--r--tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp54
13 files changed, 218 insertions, 178 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
index e9dccf0c46..d53dbf9fa5 100644
--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -2002,14 +2002,11 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
- QString indeps;
- while(!feof(proc)) {
- int read_in = (int)fread(buff, 1, 255, proc);
- if(!read_in)
- break;
- indeps += QByteArray(buff, read_in);
- }
+ QByteArray depData;
+ while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc))
+ depData.append(buff, read_in);
QT_PCLOSE(proc);
+ const QString indeps = QString::fromLocal8Bit(depData);
if(!indeps.isEmpty()) {
QDir outDir(Option::output_dir);
QStringList dep_cmd_deps = splitDeps(indeps, dep_lines);
@@ -2090,14 +2087,11 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, out, LocalShell);
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
- QString indeps;
- while(!feof(proc)) {
- int read_in = (int)fread(buff, 1, 255, proc);
- if(!read_in)
- break;
- indeps += QByteArray(buff, read_in);
- }
+ QByteArray depData;
+ while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc))
+ depData.append(buff, read_in);
QT_PCLOSE(proc);
+ const QString indeps = QString::fromLocal8Bit(depData);
if(!indeps.isEmpty()) {
QDir outDir(Option::output_dir);
QStringList dep_cmd_deps = splitDeps(indeps, dep_lines);
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index ca35f60457..dfc6abf5ba 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -204,86 +204,42 @@ inline QPointF toNativeLocalPosition(const QPointF &pos, const QWindow *window)
return pos * scaleFactor;
}
-inline QRect fromNativePixels(const QRect &pixelRect, const QPlatformScreen *platformScreen)
+template <typename C>
+inline QRect fromNativePixels(const QRect &pixelRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(platformScreen);
- const QPoint origin = QHighDpiScaling::origin(platformScreen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin),
fromNative(pixelRect.size(), scaleFactor));
}
-inline QRect toNativePixels(const QRect &pointRect, const QPlatformScreen *platformScreen)
+template <typename C>
+inline QRect toNativePixels(const QRect &pointRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(platformScreen);
- const QPoint origin = QHighDpiScaling::origin(platformScreen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRect(toNative(pointRect.topLeft(), scaleFactor, origin),
toNative(pointRect.size(), scaleFactor));
}
-inline QRect fromNativePixels(const QRect &pixelRect, const QScreen *screen)
+template <typename C>
+inline QRectF toNativePixels(const QRectF &pointRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
- return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin),
- fromNative(pixelRect.size(), scaleFactor));
-}
-
-inline QRect toNativePixels(const QRect &pointRect, const QScreen *screen)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
- return QRect(toNative(pointRect.topLeft(), scaleFactor, origin),
- toNative(pointRect.size(), scaleFactor));
-}
-
-inline QRect fromNativePixels(const QRect &pixelRect, const QWindow *window)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- const QPoint origin = QHighDpiScaling::origin(window);
- return QRect(fromNative(pixelRect.topLeft(), scaleFactor, origin),
- fromNative(pixelRect.size(), scaleFactor));
-}
-
-inline QRectF toNativePixels(const QRectF &pointRect, const QScreen *screen)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRectF(toNative(pointRect.topLeft(), scaleFactor, origin),
- toNative(pointRect.size(), scaleFactor));
-}
-
-inline QRect toNativePixels(const QRect &pointRect, const QWindow *window)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- const QPoint origin = QHighDpiScaling::origin(window);
- return QRect(toNative(pointRect.topLeft(), scaleFactor, origin),
- toNative(pointRect.size(), scaleFactor));
+ toNative(pointRect.size(), scaleFactor));
}
-inline QRectF fromNativePixels(const QRectF &pixelRect, const QScreen *screen)
+template <typename C>
+inline QRectF fromNativePixels(const QRectF &pixelRect, const C *context)
{
- const qreal scaleFactor = QHighDpiScaling::factor(screen);
- const QPoint origin = QHighDpiScaling::origin(screen);
+ const qreal scaleFactor = QHighDpiScaling::factor(context);
+ const QPoint origin = QHighDpiScaling::origin(context);
return QRectF(fromNative(pixelRect.topLeft(), scaleFactor, origin),
fromNative(pixelRect.size(), scaleFactor));
}
-inline QRectF fromNativePixels(const QRectF &pixelRect, const QWindow *window)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- const QPoint origin = QHighDpiScaling::origin(window);
- return QRectF(fromNative(pixelRect.topLeft(), scaleFactor, origin),
- fromNative(pixelRect.size(), scaleFactor));
-}
-
-inline QRectF toNativePixels(const QRectF &pointRect, const QWindow *window)
-{
- const qreal scaleFactor = QHighDpiScaling::factor(window);
- const QPoint origin = QHighDpiScaling::origin(window);
- return QRectF(toNative(pointRect.topLeft(), scaleFactor, origin),
- toNative(pointRect.size(), scaleFactor));
-}
-
inline QSize fromNativePixels(const QSize &pixelSize, const QWindow *window)
{
return pixelSize / QHighDpiScaling::factor(window);
@@ -304,44 +260,28 @@ inline QSizeF toNativePixels(const QSizeF &pointSize, const QWindow *window)
return pointSize * QHighDpiScaling::factor(window);
}
-inline QPoint fromNativePixels(const QPoint &pixelPoint, const QScreen *screen)
-{
- return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
-}
-
-inline QPoint fromNativePixels(const QPoint &pixelPoint, const QWindow *window)
-{
- return fromNative(pixelPoint, QHighDpiScaling::factor(window), QHighDpiScaling::origin(window));
-}
-
-inline QPoint toNativePixels(const QPoint &pointPoint, const QScreen *screen)
+template <typename C>
+inline QPoint fromNativePixels(const QPoint &pixelPoint, const C *context)
{
- return toNative(pointPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
+ return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
-inline QPoint toNativePixels(const QPoint &pointPoint, const QWindow *window)
+template <typename C>
+inline QPoint toNativePixels(const QPoint &pointPoint, const C *context)
{
- return toNative(pointPoint, QHighDpiScaling::factor(window), QHighDpiScaling::origin(window));
+ return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
-inline QPointF fromNativePixels(const QPointF &pixelPoint, const QScreen *screen)
+template <typename C>
+inline QPointF fromNativePixels(const QPointF &pixelPoint, const C *context)
{
- return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
+ return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
-inline QPointF fromNativePixels(const QPointF &pixelPoint, const QWindow *window)
+template <typename C>
+inline QPointF toNativePixels(const QPointF &pointPoint, const C *context)
{
- return fromNative(pixelPoint, QHighDpiScaling::factor(window), QHighDpiScaling::origin(window));
-}
-
-inline QPointF toNativePixels(const QPointF &pointPoint, const QScreen *screen)
-{
- return toNative(pointPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
-}
-
-inline QPointF toNativePixels(const QPointF &pointPoint, const QWindow *window)
-{
- return toNative(pointPoint, QHighDpiScaling::factor(window), QHighDpiScaling::origin(window));
+ return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
}
inline QMargins fromNativePixels(const QMargins &pixelMargins, const QWindow *window)
@@ -406,47 +346,26 @@ inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *wi
}
// Any T that has operator/()
-template <typename T>
-T fromNativePixels(const T &pixelValue, const QWindow *window)
-{
- if (!QHighDpiScaling::isActive())
- return pixelValue;
-
- return pixelValue / QHighDpiScaling::factor(window);
-
-}
-
- //##### ?????
-template <typename T>
-T fromNativePixels(const T &pixelValue, const QScreen *screen)
+template <typename T, typename C>
+T fromNativePixels(const T &pixelValue, const C *context)
{
if (!QHighDpiScaling::isActive())
return pixelValue;
- return pixelValue / QHighDpiScaling::factor(screen);
+ return pixelValue / QHighDpiScaling::factor(context);
}
// Any T that has operator*()
-template <typename T>
-T toNativePixels(const T &pointValue, const QWindow *window)
+template <typename T, typename C>
+T toNativePixels(const T &pointValue, const C *context)
{
if (!QHighDpiScaling::isActive())
return pointValue;
- return pointValue * QHighDpiScaling::factor(window);
+ return pointValue * QHighDpiScaling::factor(context);
}
-template <typename T>
-T toNativePixels(const T &pointValue, const QScreen *screen)
-{
- if (!QHighDpiScaling::isActive())
- return pointValue;
-
- return pointValue * QHighDpiScaling::factor(screen);
-}
-
-
// Any QVector<T> where T has operator/()
template <typename T>
QVector<T> fromNativePixels(const QVector<T> &pixelValues, const QWindow *window)
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index 9ccfb9b819..c6805dd4e6 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -1006,6 +1006,8 @@ QDataStream &operator<<(QDataStream &s, const QPalette &p)
max = QPalette::HighlightedText + 1;
else if (s.version() <= QDataStream::Qt_4_3)
max = QPalette::AlternateBase + 1;
+ else if (s.version() <= QDataStream::Qt_5_11)
+ max = QPalette::ToolTipText + 1;
for (int r = 0; r < max; r++)
s << p.d->br[grp][r];
}
@@ -1046,6 +1048,9 @@ QDataStream &operator>>(QDataStream &s, QPalette &p)
} else if (s.version() <= QDataStream::Qt_4_3) {
p = QPalette();
max = QPalette::AlternateBase + 1;
+ } else if (s.version() <= QDataStream::Qt_5_11) {
+ p = QPalette();
+ max = QPalette::ToolTipText + 1;
}
QBrush tmp;
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index 103e0a8222..1906502c10 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -43,6 +43,7 @@
#include "qtextodfwriter_p.h"
+#include <QImageReader>
#include <QImageWriter>
#include <QTextListFormat>
#include <QTextList>
@@ -410,6 +411,29 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
writer.writeEndElement(); // list-item
}
+static bool probeImageData(QIODevice *device, QImage *image, QString *mimeType, qreal *width, qreal *height)
+{
+ QImageReader reader(device);
+ const QByteArray format = reader.format().toLower();
+ if (format == "png") {
+ *mimeType = QStringLiteral("image/png");
+ } else if (format == "jpg") {
+ *mimeType = QStringLiteral("image/jpg");
+ } else if (format == "svg") {
+ *mimeType = QStringLiteral("image/svg+xml");
+ } else {
+ *image = reader.read();
+ return false;
+ }
+
+ const QSize size = reader.size();
+
+ *width = size.width();
+ *height = size.height();
+
+ return true;
+}
+
void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextFragment &fragment) const
{
writer.writeStartElement(drawNS, QString::fromLatin1("frame"));
@@ -420,47 +444,73 @@ void QTextOdfWriter::writeInlineCharacter(QXmlStreamWriter &writer, const QTextF
QTextImageFormat imageFormat = fragment.charFormat().toImageFormat();
writer.writeAttribute(drawNS, QString::fromLatin1("name"), imageFormat.name());
+ QByteArray data;
+ QString mimeType;
+ qreal width = 0;
+ qreal height = 0;
+
QImage image;
QString name = imageFormat.name();
if (name.startsWith(QLatin1String(":/"))) // auto-detect resources
name.prepend(QLatin1String("qrc"));
QUrl url = QUrl(name);
- const QVariant data = m_document->resource(QTextDocument::ImageResource, url);
- if (data.type() == QVariant::Image) {
- image = qvariant_cast<QImage>(data);
- } else if (data.type() == QVariant::ByteArray) {
- image.loadFromData(data.toByteArray());
- }
-
- if (image.isNull()) {
- if (image.isNull()) { // try direct loading
- name = imageFormat.name(); // remove qrc:/ prefix again
- image.load(name);
+ const QVariant variant = m_document->resource(QTextDocument::ImageResource, url);
+ if (variant.type() == QVariant::Image) {
+ image = qvariant_cast<QImage>(variant);
+ } else if (variant.type() == QVariant::ByteArray) {
+ data = variant.toByteArray();
+
+ QBuffer buffer(&data);
+ buffer.open(QIODevice::ReadOnly);
+ probeImageData(&buffer, &image, &mimeType, &width, &height);
+ } else {
+ // try direct loading
+ QFile file(imageFormat.name());
+ if (file.open(QIODevice::ReadOnly) && !probeImageData(&file, &image, &mimeType, &width, &height)) {
+ file.seek(0);
+ data = file.readAll();
}
}
if (! image.isNull()) {
QBuffer imageBytes;
- QString filename = m_strategy->createUniqueImageName();
+
int imgQuality = imageFormat.quality();
if (imgQuality >= 100 || imgQuality < 0 || image.hasAlphaChannel()) {
QImageWriter imageWriter(&imageBytes, "png");
imageWriter.write(image);
- m_strategy->addFile(filename, QString::fromLatin1("image/png"), imageBytes.data());
+
+ data = imageBytes.data();
+ mimeType = QStringLiteral("image/png");
} else {
// Write images without alpha channel as jpg with quality set by QTextImageFormat
QImageWriter imageWriter(&imageBytes, "jpg");
imageWriter.setQuality(imgQuality);
imageWriter.write(image);
- m_strategy->addFile(filename, QString::fromLatin1("image/jpg"), imageBytes.data());
+
+ data = imageBytes.data();
+ mimeType = QStringLiteral("image/jpg");
}
- // get the width/height from the format.
- qreal width = imageFormat.hasProperty(QTextFormat::ImageWidth)
- ? imageFormat.width() : image.width();
+
+ width = image.width();
+ height = image.height();
+ }
+
+ if (!data.isEmpty()) {
+ if (imageFormat.hasProperty(QTextFormat::ImageWidth)) {
+ width = imageFormat.width();
+ }
+ if (imageFormat.hasProperty(QTextFormat::ImageHeight)) {
+ height = imageFormat.height();
+ }
+
+ QString filename = m_strategy->createUniqueImageName();
+
+ m_strategy->addFile(filename, mimeType, data);
+
writer.writeAttribute(svgNS, QString::fromLatin1("width"), pixelToPoint(width));
- qreal height = imageFormat.hasProperty(QTextFormat::ImageHeight)
- ? imageFormat.height() : image.height();
writer.writeAttribute(svgNS, QString::fromLatin1("height"), pixelToPoint(height));
+ writer.writeAttribute(textNS, QStringLiteral("anchor-type"), QStringLiteral("as-char"));
writer.writeStartElement(drawNS, QString::fromLatin1("image"));
writer.writeAttribute(xlinkNS, QString::fromLatin1("href"), filename);
writer.writeEndElement(); // image
diff --git a/src/plugins/platforms/xcb/qxcbdrag.cpp b/src/plugins/platforms/xcb/qxcbdrag.cpp
index aa329d8cb7..1ce947165d 100644
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -202,7 +202,7 @@ void QXcbDrag::startDrag()
if (connection()->mouseGrabber() == nullptr)
shapedPixmapWindow()->setMouseGrabEnabled(true);
- auto nativePixelPos = QHighDpi::toNativePixels(QCursor::pos(), initiatorWindow);
+ auto nativePixelPos = QHighDpi::toNativePixels(QCursor::pos(), initiatorWindow.data());
move(nativePixelPos, QGuiApplication::mouseButtons(), QGuiApplication::keyboardModifiers());
}
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 30b35ad92f..dbce80b125 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -9786,9 +9786,9 @@ QRectF QGraphicsPixmapItem::boundingRect() const
return QRectF();
if (d->flags & ItemIsSelectable) {
qreal pw = 1.0;
- return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
+ return QRectF(d->offset, QSizeF(d->pixmap.size()) / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
} else {
- return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio());
+ return QRectF(d->offset, QSizeF(d->pixmap.size()) / d->pixmap.devicePixelRatio());
}
}
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 53d87c6113..59053f3539 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2580,14 +2580,15 @@ void QWidgetPrivate::createWinId()
/*!
\internal
Ensures that the widget is set on the screen point is on. This is handy getting a correct
-size hint before a resize in e.g QMenu and QToolTip
+size hint before a resize in e.g QMenu and QToolTip.
+Returns if the screen was changed.
*/
-void QWidgetPrivate::setScreenForPoint(const QPoint &pos)
+bool QWidgetPrivate::setScreenForPoint(const QPoint &pos)
{
Q_Q(QWidget);
if (!q->isWindow())
- return;
+ return false;
// Find the screen for pos and make the widget undertand it is on that screen.
const QScreen *currentScreen = windowHandle() ? windowHandle()->screen() : nullptr;
QScreen *actualScreen = QGuiApplication::screenAt(pos);
@@ -2596,7 +2597,9 @@ void QWidgetPrivate::setScreenForPoint(const QPoint &pos)
createWinId();
if (windowHandle())
windowHandle()->setScreen(actualScreen);
+ return true;
}
+ return false;
}
/*!
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 7e4ea2cc0c..ae50624c04 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -355,7 +355,7 @@ public:
void createRecursively();
void createWinId();
- void setScreenForPoint(const QPoint &pos);
+ bool setScreenForPoint(const QPoint &pos);
void createTLExtra();
void createExtra();
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 0daa4a4b41..e41f7e7573 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -976,18 +976,48 @@ void QCompleterPrivate::showPopup(const QRect& rect)
popup->show();
}
+#if QT_CONFIG(filesystemmodel)
+static bool isRoot(const QFileSystemModel *model, const QString &path)
+{
+ const auto index = model->index(path);
+ return index.isValid() && model->fileInfo(index).isRoot();
+}
+
+static bool completeOnLoaded(const QFileSystemModel *model,
+ const QString &nativePrefix,
+ const QString &path,
+ Qt::CaseSensitivity caseSensitivity)
+{
+ const auto pathSize = path.size();
+ const auto prefixSize = nativePrefix.size();
+ if (prefixSize < pathSize)
+ return false;
+ const QString prefix = QDir::fromNativeSeparators(nativePrefix);
+ if (prefixSize == pathSize)
+ return path.compare(prefix, caseSensitivity) == 0 && isRoot(model, path);
+ // The user is typing something within that directory and is not in a subdirectory yet.
+ const auto separator = QLatin1Char('/');
+ return prefix.startsWith(path, caseSensitivity) && prefix.at(pathSize) == separator
+ && !prefix.rightRef(prefixSize - pathSize - 1).contains(separator);
+}
+
void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
{
Q_Q(QCompleter);
// Slot called when QFileSystemModel has finished loading.
// If we hide the popup because there was no match because the model was not loaded yet,
- // we re-start the completion when we get the results
- if (hiddenBecauseNoMatch
- && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
- && widget) {
- q->complete();
+ // we re-start the completion when we get the results (unless triggered by
+ // something else, see QTBUG-14292).
+ if (hiddenBecauseNoMatch && widget) {
+ if (auto model = qobject_cast<const QFileSystemModel *>(proxy->sourceModel())) {
+ if (completeOnLoaded(model, prefix, path, cs))
+ q->complete();
+ }
}
}
+#else // QT_CONFIG(filesystemmodel)
+void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &) {}
+#endif
/*!
Constructs a completer object with the given \a parent.
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index a8cca2ae3a..5b1f609b7e 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -73,6 +73,7 @@
#endif
#include "qpushbutton.h"
#include "qtooltip.h"
+#include <qwindow.h>
#include <private/qpushbutton_p.h>
#include <private/qaction_p.h>
#include <private/qguiapplication_p.h>
@@ -2356,8 +2357,10 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
d->motions = 0;
d->doChildEffects = true;
d->updateLayoutDirection();
- // Ensure that we get correct sizeHints by placing this window on the right screen.
- d->setScreenForPoint(p);
+
+ // Ensure that we get correct sizeHints by placing this window on the correct screen.
+ if (d->setScreenForPoint(p))
+ d->itemsDirty = true;
const bool contextMenu = d->isContextMenu();
if (d->lastContextMenu != contextMenu) {
diff --git a/src/xml/doc/src/qtxml-index.qdoc b/src/xml/doc/src/qtxml-index.qdoc
index dfb9b45fa7..65c6673db0 100644
--- a/src/xml/doc/src/qtxml-index.qdoc
+++ b/src/xml/doc/src/qtxml-index.qdoc
@@ -30,8 +30,10 @@
\title Qt XML
\brief The Qt XML module provides C++ implementations of the SAX and DOM standards for XML.
- The module is not actively maintained anymore. Please use
- the QXmlStreamReader and QXmlStreamWriter classes in Qt Core instead.
+ Note that the module will not receive additional features anymore. For reading or writing XML
+ documents iteratively (SAX), we recommend using Qt Core's QXmlStreamReader and
+ QXmlStreamWriter classes. The classes are both easier to use and more compliant with the
+ XML standard.
To include the definitions of the module's classes, use the
following directive:
diff --git a/src/xml/doc/src/qtxml.qdoc b/src/xml/doc/src/qtxml.qdoc
index ad9b08b623..452e39d745 100644
--- a/src/xml/doc/src/qtxml.qdoc
+++ b/src/xml/doc/src/qtxml.qdoc
@@ -33,8 +33,10 @@
\brief The Qt XML module provides C++ implementations of the SAX and DOM standards for XML.
- The module is not actively maintained anymore. Please use
- the \l{QXmlStreamReader} and \l{QXmlStreamWriter} classes in \l{Qt Core} instead.
+ Note that the module will not receive additional features anymore. For reading or writing XML
+ documents iteratively (SAX), we recommend using Qt Core's QXmlStreamReader and
+ QXmlStreamWriter classes. The classes are both easier to use and more compliant with the
+ XML standard.
To include the definitions of the module's classes, use the
following directive:
diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
index 011a0e1a85..041d9d7a09 100644
--- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp
@@ -174,6 +174,7 @@ private slots:
void floatingPointPrecision();
+ void compatibility_Qt5();
void compatibility_Qt3();
void compatibility_Qt2();
@@ -260,17 +261,17 @@ static int NColorRoles[] = {
QPalette::HighlightedText + 1, // Qt_4_0, Qt_4_1
QPalette::HighlightedText + 1, // Qt_4_2
QPalette::AlternateBase + 1, // Qt_4_3
- QPalette::PlaceholderText + 1, // Qt_4_4
- QPalette::PlaceholderText + 1, // Qt_4_5
- QPalette::PlaceholderText + 1, // Qt_4_6
- QPalette::PlaceholderText + 1, // Qt_5_0
- QPalette::PlaceholderText + 1, // Qt_5_1
- QPalette::PlaceholderText + 1, // Qt_5_2
- QPalette::PlaceholderText + 1, // Qt_5_3
- QPalette::PlaceholderText + 1, // Qt_5_4
- QPalette::PlaceholderText + 1, // Qt_5_5
- QPalette::PlaceholderText + 1, // Qt_5_6
- 0 // add the correct value for Qt_5_7 here later
+ QPalette::ToolTipText + 1, // Qt_4_4
+ QPalette::ToolTipText + 1, // Qt_4_5
+ QPalette::ToolTipText + 1, // Qt_4_6, Qt_4_7, Qt_4_8, Qt_4_9
+ QPalette::ToolTipText + 1, // Qt_5_0
+ QPalette::ToolTipText + 1, // Qt_5_1
+ QPalette::ToolTipText + 1, // Qt_5_2, Qt_5_3
+ QPalette::ToolTipText + 1, // Qt_5_4, Qt_5_5
+ QPalette::ToolTipText + 1, // Qt_5_6, Qt_5_7, Qt_5_8, Qt_5_9, Qt_5_10, Qt_5_11
+ QPalette::PlaceholderText + 1, // Qt_5_12
+ QPalette::PlaceholderText + 1, // Qt_5_13
+ 0 // add the correct value for Qt_5_14 here later
};
// Testing get/set functions
@@ -3102,6 +3103,37 @@ void tst_QDataStream::streamRealDataTypes()
}
}
+void tst_QDataStream::compatibility_Qt5()
+{
+ QLinearGradient gradient(QPointF(0,0), QPointF(1,1));
+ gradient.setColorAt(0, Qt::red);
+ gradient.setColorAt(1, Qt::blue);
+
+ QBrush brush(gradient);
+ QPalette palette;
+ palette.setBrush(QPalette::Button, brush);
+ palette.setColor(QPalette::Light, Qt::green);
+
+ QByteArray stream;
+ {
+ QDataStream out(&stream, QIODevice::WriteOnly);
+ out.setVersion(QDataStream::Qt_5_7);
+ out << palette;
+ out << brush;
+ }
+ QBrush in_brush;
+ QPalette in_palette;
+ {
+ QDataStream in(stream);
+ in.setVersion(QDataStream::Qt_5_7);
+ in >> in_palette;
+ in >> in_brush;
+ }
+ QCOMPARE(in_brush.style(), Qt::LinearGradientPattern);
+ QCOMPARE(in_palette.brush(QPalette::Button).style(), Qt::LinearGradientPattern);
+ QCOMPARE(in_palette.color(QPalette::Light), QColor(Qt::green));
+}
+
void tst_QDataStream::compatibility_Qt3()
{
QByteArray ba("hello");