Merge 5.12 into 5.12.4
Change-Id: I0b00afdda019c5ede5ea6b552cfc9ebbcd854037
This commit is contained in:
commit
a275f1eca3
@ -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);
|
||||
|
@ -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));
|
||||
toNative(pointRect.size(), scaleFactor));
|
||||
}
|
||||
|
||||
inline QRect toNativePixels(const QRect &pointRect, const QWindow *window)
|
||||
template <typename C>
|
||||
inline QRectF fromNativePixels(const QRectF &pixelRect, const C *context)
|
||||
{
|
||||
const qreal scaleFactor = QHighDpiScaling::factor(window);
|
||||
const QPoint origin = QHighDpiScaling::origin(window);
|
||||
return QRect(toNative(pointRect.topLeft(), scaleFactor, origin),
|
||||
toNative(pointRect.size(), scaleFactor));
|
||||
}
|
||||
|
||||
inline QRectF fromNativePixels(const QRectF &pixelRect, 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(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)
|
||||
template <typename C>
|
||||
inline QPoint fromNativePixels(const QPoint &pixelPoint, const C *context)
|
||||
{
|
||||
return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
|
||||
return fromNative(pixelPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
|
||||
}
|
||||
|
||||
inline QPoint fromNativePixels(const QPoint &pixelPoint, const QWindow *window)
|
||||
template <typename C>
|
||||
inline QPoint toNativePixels(const QPoint &pointPoint, const C *context)
|
||||
{
|
||||
return fromNative(pixelPoint, QHighDpiScaling::factor(window), QHighDpiScaling::origin(window));
|
||||
return toNative(pointPoint, QHighDpiScaling::factor(context), QHighDpiScaling::origin(context));
|
||||
}
|
||||
|
||||
inline QPoint toNativePixels(const QPoint &pointPoint, const QScreen *screen)
|
||||
template <typename C>
|
||||
inline QPointF fromNativePixels(const QPointF &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 QPointF toNativePixels(const QPointF &pointPoint, const C *context)
|
||||
{
|
||||
return toNative(pointPoint, QHighDpiScaling::factor(window), QHighDpiScaling::origin(window));
|
||||
}
|
||||
|
||||
inline QPointF fromNativePixels(const QPointF &pixelPoint, const QScreen *screen)
|
||||
{
|
||||
return fromNative(pixelPoint, QHighDpiScaling::factor(screen), QHighDpiScaling::origin(screen));
|
||||
}
|
||||
|
||||
inline QPointF fromNativePixels(const QPointF &pixelPoint, const QWindow *window)
|
||||
{
|
||||
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)
|
||||
template <typename T, typename C>
|
||||
T fromNativePixels(const T &pixelValue, const C *context)
|
||||
{
|
||||
if (!QHighDpiScaling::isActive())
|
||||
return pixelValue;
|
||||
|
||||
return pixelValue / QHighDpiScaling::factor(window);
|
||||
|
||||
}
|
||||
|
||||
//##### ?????
|
||||
template <typename T>
|
||||
T fromNativePixels(const T &pixelValue, const QScreen *screen)
|
||||
{
|
||||
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)
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
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();
|
||||
|
||||
if (image.isNull()) {
|
||||
if (image.isNull()) { // try direct loading
|
||||
name = imageFormat.name(); // remove qrc:/ prefix again
|
||||
image.load(name);
|
||||
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
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -355,7 +355,7 @@ public:
|
||||
void createRecursively();
|
||||
void createWinId();
|
||||
|
||||
void setScreenForPoint(const QPoint &pos);
|
||||
bool setScreenForPoint(const QPoint &pos);
|
||||
|
||||
void createTLExtra();
|
||||
void createExtra();
|
||||
|
@ -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.
|
||||
|
@ -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) {
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user