diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-26 08:27:02 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-26 08:27:02 +0100 |
commit | 8f1acd29e4d39383752899d6d05d484eb9d7935b (patch) | |
tree | e749c4bebdd49ff702dfaa062902cbb6016cfd82 /src | |
parent | 945198fd237a83348feb4537d811565a2c2cd8e0 (diff) | |
parent | 2fedce8ed8451fd9b14bc214dc26e79b0d5ab7bd (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I71cc71881fb638e207d83a8733bad8f267701c0f
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/configure.json | 16 | ||||
-rw-r--r-- | src/corelib/global/minimum-linux_p.h | 6 | ||||
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 14 | ||||
-rw-r--r-- | src/corelib/kernel/qsignalmapper.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qtimezoneprivate_p.h | 1 | ||||
-rw-r--r-- | src/corelib/tools/qtimezoneprivate_tz.cpp | 48 | ||||
-rw-r--r-- | src/gui/image/qpixmap.cpp | 15 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_p.h | 8 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qabstractnetworkcache.cpp | 4 | ||||
-rw-r--r-- | src/network/access/qnetworkaccesscachebackend.cpp | 17 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 14 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenu.mm | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoasystemsettings.mm | 3 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp | 7 | ||||
-rw-r--r-- | src/plugins/styles/mac/qmacstyle_mac.mm | 96 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 7 |
19 files changed, 189 insertions, 84 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json index 948aa0829b..ed31299603 100644 --- a/src/corelib/configure.json +++ b/src/corelib/configure.json @@ -374,6 +374,16 @@ ] } }, + "glibc": { + "label": "GNU libc", + "type": "compile", + "test": { + "include": "stdlib.h", + "main": [ + "return __GLIBC__;" + ] + } + }, "inotify": { "label": "inotify", "type": "compile", @@ -593,6 +603,12 @@ "condition": "libs.glib", "output": [ "privateFeature", "feature" ] }, + "glibc": { + "label": "GNU libc", + "autoDetect": "config.linux", + "condition": "tests.glibc", + "output": [ "privateFeature" ] + }, "iconv": { "label": "iconv", "purpose": "Provides internationalization on Unix.", diff --git a/src/corelib/global/minimum-linux_p.h b/src/corelib/global/minimum-linux_p.h index 9c074e13ba..5112015663 100644 --- a/src/corelib/global/minimum-linux_p.h +++ b/src/corelib/global/minimum-linux_p.h @@ -78,7 +78,11 @@ QT_BEGIN_NAMESPACE * - statx 4.11 QT_CONFIG(statx) */ -#if QT_CONFIG(statx) +#if QT_CONFIG(statx) && !QT_CONFIG(glibc) +// if using glibc, the statx() function in sysdeps/unix/sysv/linux/statx.c +// falls back to stat() for us. +// (Using QT_CONFIG(glibc) instead of __GLIBC__ because the macros aren't +// defined in assembler mode) # define MINLINUX_MAJOR 4 # define MINLINUX_MINOR 11 # define MINLINUX_PATCH 0 diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index abd86f2b49..18f0f6f55f 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -2355,6 +2355,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, bool wrap = flags & Qt::MatchWrap; bool allHits = (hits == -1); QString text; // only convert to a string if it is needed + const int column = start.column(); QModelIndex p = parent(start); int from = start.row(); int to = rowCount(p); @@ -2362,7 +2363,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, // iterates twice if wrapping for (int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) { for (int r = from; (r < to) && (allHits || result.count() < hits); ++r) { - QModelIndex idx = index(r, start.column(), p); + QModelIndex idx = index(r, column, p); if (!idx.isValid()) continue; QVariant v = data(idx, role); @@ -2401,10 +2402,13 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, result.append(idx); } } - if (recurse && hasChildren(idx)) { // search the hierarchy - result += match(index(0, idx.column(), idx), role, - (text.isEmpty() ? value : text), - (allHits ? -1 : hits - result.count()), flags); + if (recurse) { + const auto parent = column != 0 ? idx.sibling(idx.row(), 0) : idx; + if (hasChildren(parent)) { // search the hierarchy + result += match(index(0, column, parent), role, + (text.isEmpty() ? value : text), + (allHits ? -1 : hits - result.count()), flags); + } } } // prepare for the next iteration diff --git a/src/corelib/kernel/qsignalmapper.cpp b/src/corelib/kernel/qsignalmapper.cpp index d56965281e..02a1281f92 100644 --- a/src/corelib/kernel/qsignalmapper.cpp +++ b/src/corelib/kernel/qsignalmapper.cpp @@ -61,7 +61,7 @@ public: /*! \class QSignalMapper \inmodule QtCore - \obsolete + \obsolete The recommended solution is connecting the signal to a lambda. \brief The QSignalMapper class bundles signals from identifiable senders. \ingroup objectmodel diff --git a/src/corelib/tools/qtimezoneprivate_p.h b/src/corelib/tools/qtimezoneprivate_p.h index c9a5726216..24a9a00f11 100644 --- a/src/corelib/tools/qtimezoneprivate_p.h +++ b/src/corelib/tools/qtimezoneprivate_p.h @@ -331,6 +331,7 @@ public: private: void init(const QByteArray &ianaId); + QVector<QTimeZonePrivate::Data> getPosixTransitions(qint64 msNear) const; Data dataForTzTransition(QTzTransitionTime tran) const; QVector<QTzTransitionTime> m_tranTimes; diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index bed62a02bd..f75a61977d 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -943,19 +943,21 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::dataForTzTransition(QTzTransitionTime return data; } -QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const +QVector<QTimeZonePrivate::Data> QTzTimeZonePrivate::getPosixTransitions(qint64 msNear) const { - // If we have no rules (so probably an invalid tz), return invalid data: - if (!m_tranTimes.size()) - return invalidData(); + const int year = QDateTime::fromMSecsSinceEpoch(msNear, Qt::UTC).date().year(); + // The Data::atMSecsSinceEpoch of the single entry if zone is constant: + qint64 atTime = m_tranTimes.isEmpty() ? msNear : m_tranTimes.last().atMSecsSinceEpoch; + return calculatePosixTransitions(m_posixRule, year - 1, year + 1, atTime); +} - // If the required time is after the last transition and we have a POSIX rule then use it - if (m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch +QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const +{ + // If the required time is after the last transition (or there were none) + // and we have a POSIX rule then use it: + if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch) && !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) { - const int year = QDateTime::fromMSecsSinceEpoch(forMSecsSinceEpoch, Qt::UTC).date().year(); - QVector<QTimeZonePrivate::Data> posixTrans = - calculatePosixTransitions(m_posixRule, year - 1, year + 1, - m_tranTimes.last().atMSecsSinceEpoch); + QVector<QTimeZonePrivate::Data> posixTrans = getPosixTransitions(forMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [forMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch <= forMSecsSinceEpoch; @@ -986,13 +988,11 @@ bool QTzTimeZonePrivate::hasTransitions() const QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const { - // If the required time is after the last transition and we have a POSIX rule then use it - if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch + // If the required time is after the last transition (or there were none) + // and we have a POSIX rule then use it: + if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch) && !m_posixRule.isEmpty() && afterMSecsSinceEpoch >= 0) { - const int year = QDateTime::fromMSecsSinceEpoch(afterMSecsSinceEpoch, Qt::UTC).date().year(); - QVector<QTimeZonePrivate::Data> posixTrans = - calculatePosixTransitions(m_posixRule, year - 1, year + 1, - m_tranTimes.last().atMSecsSinceEpoch); + QVector<QTimeZonePrivate::Data> posixTrans = getPosixTransitions(afterMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [afterMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch <= afterMSecsSinceEpoch; @@ -1011,19 +1011,19 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const { - // If the required time is after the last transition and we have a POSIX rule then use it - if (m_tranTimes.size() > 0 && m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch + // If the required time is after the last transition (or there were none) + // and we have a POSIX rule then use it: + if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch) && !m_posixRule.isEmpty() && beforeMSecsSinceEpoch > 0) { - const int year = QDateTime::fromMSecsSinceEpoch(beforeMSecsSinceEpoch, Qt::UTC).date().year(); - QVector<QTimeZonePrivate::Data> posixTrans = - calculatePosixTransitions(m_posixRule, year - 1, year + 1, - m_tranTimes.last().atMSecsSinceEpoch); + QVector<QTimeZonePrivate::Data> posixTrans = getPosixTransitions(beforeMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch < beforeMSecsSinceEpoch; }); - Q_ASSERT(it > posixTrans.cbegin()); - return *--it; + if (it > posixTrans.cbegin()) + return *--it; + // It fell between the last transition (if any) and the first of the POSIX rule: + return m_tranTimes.isEmpty() ? invalidData() : dataForTzTransition(m_tranTimes.last()); } // Otherwise if we can find a valid tran then use its rule diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 2ef1d09422..5b4d218603 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1552,6 +1552,11 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) if (image.isNull()) return QPixmap(); + if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) { + qWarning("QPixmap::fromImage: QPixmap cannot be created without a QGuiApplication"); + return QPixmap(); + } + QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImage(image, flags); return QPixmap(data.take()); @@ -1574,6 +1579,11 @@ QPixmap QPixmap::fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags) if (image.isNull()) return QPixmap(); + if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) { + qWarning("QPixmap::fromImageInPlace: QPixmap cannot be created without a QGuiApplication"); + return QPixmap(); + } + QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImageInPlace(image, flags); return QPixmap(data.take()); @@ -1593,6 +1603,11 @@ QPixmap QPixmap::fromImageInPlace(QImage &image, Qt::ImageConversionFlags flags) */ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags) { + if (Q_UNLIKELY(!qobject_cast<QGuiApplication *>(QCoreApplication::instance()))) { + qWarning("QPixmap::fromImageReader: QPixmap cannot be created without a QGuiApplication"); + return QPixmap(); + } + QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::PixmapType)); data->fromImageReader(imageReader, flags); return QPixmap(data.take()); diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index d6f90c9254..562289a8c9 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -708,10 +708,11 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QScreen *screen = effectiveScreen(w); if (!screen) return initialGeometry; + const auto *wp = qt_window_private(const_cast<QWindow*>(w)); QRect rect(QHighDpi::fromNativePixels(initialGeometry, w)); - rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); - if (qt_window_private(const_cast<QWindow*>(w))->positionAutomatic - && w->type() != Qt::Popup) { + if (wp->resizeAutomatic) + rect.setSize(fixInitialSize(rect.size(), w, defaultWidth, defaultHeight)); + if (wp->positionAutomatic && w->type() != Qt::Popup) { const QRect availableGeometry = screen->availableGeometry(); // Center unless the geometry ( + unknown window frame) is too large for the screen). if (rect.height() < (availableGeometry.height() * 8) / 9 diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 25f9a8a9b2..b8fa77bef0 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -90,6 +90,7 @@ public: , receivedExpose(false) , positionPolicy(WindowFrameExclusive) , positionAutomatic(true) + , resizeAutomatic(true) , contentOrientation(Qt::PrimaryOrientation) , opacity(qreal(1.0)) , minimumSize(0, 0) @@ -156,6 +157,8 @@ public: virtual void processSafeAreaMarginsChanged() {}; bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; } + void setAutomaticPositionAndResizeEnabled(bool a) + { positionAutomatic = resizeAutomatic = a; } static QWindowPrivate *get(QWindow *window) { return window->d_func(); } @@ -179,6 +182,11 @@ public: bool receivedExpose; PositionPolicy positionPolicy; bool positionAutomatic; + // resizeAutomatic suppresses resizing by QPlatformWindow::initialGeometry(). + // It also indicates that width/height=0 is acceptable (for example, for + // the QRollEffect widget) and is thus not cleared in setGeometry(). + // An alternative approach might be using -1,-1 as a default size. + bool resizeAutomatic; Qt::ScreenOrientation contentOrientation; qreal opacity; QRegion mask; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a83ef95c79..22c93d7ec2 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1754,7 +1754,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, #ifdef Q_OS_DARWIN if (actualFontEngine->type() == QFontEngine::Mac) { - if (actualFontEngine->fontDef.stretch != 100) { + if (actualFontEngine->fontDef.stretch != 100 && actualFontEngine->fontDef.stretch != QFont::AnyStretch) { QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); for (uint i = 0; i < num_glyphs; ++i) g.advances[i] *= stretch; diff --git a/src/network/access/qabstractnetworkcache.cpp b/src/network/access/qabstractnetworkcache.cpp index 0b94dff61e..4e217294c4 100644 --- a/src/network/access/qabstractnetworkcache.cpp +++ b/src/network/access/qabstractnetworkcache.cpp @@ -191,8 +191,8 @@ bool QNetworkCacheMetaData::isValid() const Some cache implementations can keep these cache items in memory for performance reasons, but for security reasons they should not be written to disk. - Specifically with http, documents marked with Pragma: no-cache, or have a Cache-control set to - no-store or no-cache or any https document that doesn't have "Cache-control: public" set will + Specifically with http, documents with Cache-control set to no-store or any + https document that doesn't have "Cache-control: public" set will set the saveToDisk to false. \sa setSaveToDisk() diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp index 0c9a88596d..22fdc5bb0b 100644 --- a/src/network/access/qnetworkaccesscachebackend.cpp +++ b/src/network/access/qnetworkaccesscachebackend.cpp @@ -87,15 +87,16 @@ bool QNetworkAccessCacheBackend::sendCacheContents() setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, attributes.value(QNetworkRequest::HttpReasonPhraseAttribute)); // set the raw headers - QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); - QNetworkCacheMetaData::RawHeaderList::ConstIterator it = rawHeaders.constBegin(), - end = rawHeaders.constEnd(); - for ( ; it != end; ++it) { - if (it->first.toLower() == "cache-control" && - it->second.toLower().contains("must-revalidate")) { - return false; + const QNetworkCacheMetaData::RawHeaderList rawHeaders = item.rawHeaders(); + for (const auto &header : rawHeaders) { + if (header.first.toLower() == "cache-control") { + const QByteArray cacheControlValue = header.second.toLower(); + if (cacheControlValue.contains("must-revalidate") + || cacheControlValue.contains("no-cache")) { + return false; + } } - setRawHeader(it->first, it->second); + setRawHeader(header.first, header.second); } // handle a possible redirect diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 9ae94afc5a..f801ef0c88 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -524,6 +524,8 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h QHash<QByteArray, QByteArray> cacheControl = parseHttpOptionHeader(it->second); if (cacheControl.contains("must-revalidate")) return false; + if (cacheControl.contains("no-cache")) + return false; } QDateTime currentDateTime = QDateTime::currentDateTimeUtc(); @@ -1731,18 +1733,8 @@ QNetworkCacheMetaData QNetworkReplyHttpImplPrivate::fetchCacheMetaData(const QNe if (httpRequest.operation() == QHttpNetworkRequest::Get) { canDiskCache = true; - // 14.32 - // HTTP/1.1 caches SHOULD treat "Pragma: no-cache" as if the client - // had sent "Cache-Control: no-cache". - it = cacheHeaders.findRawHeader("pragma"); - if (it != cacheHeaders.rawHeaders.constEnd() - && it->second == "no-cache") - canDiskCache = false; - // HTTP/1.1. Check the Cache-Control header - if (cacheControl.contains("no-cache")) - canDiskCache = false; - else if (cacheControl.contains("no-store")) + if (cacheControl.contains("no-store")) canDiskCache = false; // responses to POST might be cacheable diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 7b96fca3f9..f34988721d 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -250,6 +250,9 @@ void QCocoaMenu::syncMenuItem_helper(QPlatformMenuItem *menuItem, bool menubarUp if (wasMerged) { oldItem.enabled = NO; oldItem.hidden = YES; + oldItem.keyEquivalent = @""; + oldItem.keyEquivalentModifierMask = NSEventModifierFlagCommand; + } else { [m_nativeMenu removeItem:oldItem]; } diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index aef2c6cf48..9b6dc94d33 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -158,10 +158,13 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes() pal.setColor(QPalette::Inactive, QPalette::WindowText, qc); pal.setColor(QPalette::Active, QPalette::HighlightedText, qc); pal.setColor(QPalette::Inactive, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Active, QPalette::ButtonText, qc); + pal.setColor(QPalette::Inactive, QPalette::ButtonText, qc); qc = qt_mac_toQColor(mac_widget_colors[i].inactive); pal.setColor(QPalette::Disabled, QPalette::Text, qc); pal.setColor(QPalette::Disabled, QPalette::WindowText, qc); pal.setColor(QPalette::Disabled, QPalette::HighlightedText, qc); + pal.setColor(QPalette::Disabled, QPalette::ButtonText, qc); } if (mac_widget_colors[i].paletteRole == QPlatformTheme::MenuPalette || mac_widget_colors[i].paletteRole == QPlatformTheme::MenuBarPalette) { diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 07fd2916c2..338e594c7b 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1132,7 +1132,8 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, // TODO: No concept of WA_wasMoved yet that would indicate a // CW_USEDEFAULT unless set. For now, assume that 0,0 means 'default' // for toplevels. - if (geometry.isValid()) { + if (geometry.isValid() + || !qt_window_private(const_cast<QWindow *>(w))->resizeAutomatic) { frameX = geometry.x(); frameY = geometry.y(); const QMargins effectiveMargins = margins + customMargins; diff --git a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp index 3377eeaae9..8d958aae94 100644 --- a/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp +++ b/src/plugins/platforms/xcb/nativepainting/qpaintengine_x11.cpp @@ -2645,6 +2645,13 @@ bool QXRenderGlyphCache::addGlyphs(const QTextItemInt &ti, if (glyph == 0 || glyph->format != glyphFormat()) return false; + if (glyph->format == QFontEngine::Format_Mono) { + // Must convert bitmap from msb to lsb bit order + QImage img(glyph->data, glyph->width, glyph->height, QImage::Format_Mono); + img = img.convertToFormat(QImage::Format_MonoLSB); + memcpy(glyph->data, img.constBits(), static_cast<size_t>(img.sizeInBytes())); + } + set->setGlyph(glyphs[i], spp, glyph); Q_ASSERT(glyph->data || glyph->width == 0 || glyph->height == 0); diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 9602340f9d..25ecc5bf48 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -356,15 +356,44 @@ static const qreal titleBarButtonSpacing = 8; // active: window is active // selected: tab is selected // hovered: tab is hovered -static const QColor tabBarTabBackgroundActive(190, 190, 190); -static const QColor tabBarTabBackgroundActiveHovered(178, 178, 178); -static const QColor tabBarTabBackgroundActiveSelected(211, 211, 211); -static const QColor tabBarTabBackground(227, 227, 227); -static const QColor tabBarTabBackgroundSelected(246, 246, 246); -static const QColor tabBarTabLineActive(160, 160, 160); -static const QColor tabBarTabLineActiveHovered(150, 150, 150); -static const QColor tabBarTabLine(210, 210, 210); -static const QColor tabBarTabLineSelected(189, 189, 189); +bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); } + +static const QColor lightTabBarTabBackgroundActive(190, 190, 190); +static const QColor darkTabBarTabBackgroundActive(38, 38, 38); +static const QColor tabBarTabBackgroundActive() { return isDarkMode() ? darkTabBarTabBackgroundActive : lightTabBarTabBackgroundActive; } + +static const QColor lightTabBarTabBackgroundActiveHovered(178, 178, 178); +static const QColor darkTabBarTabBackgroundActiveHovered(32, 32, 32); +static const QColor tabBarTabBackgroundActiveHovered() { return isDarkMode() ? darkTabBarTabBackgroundActiveHovered : lightTabBarTabBackgroundActiveHovered; } + +static const QColor lightTabBarTabBackgroundActiveSelected(211, 211, 211); +static const QColor darkTabBarTabBackgroundActiveSelected(52, 52, 52); +static const QColor tabBarTabBackgroundActiveSelected() { return isDarkMode() ? darkTabBarTabBackgroundActiveSelected : lightTabBarTabBackgroundActiveSelected; } + +static const QColor lightTabBarTabBackground(227, 227, 227); +static const QColor darkTabBarTabBackground(38, 38, 38); +static const QColor tabBarTabBackground() { return isDarkMode() ? darkTabBarTabBackground : lightTabBarTabBackground; } + +static const QColor lightTabBarTabBackgroundSelected(246, 246, 246); +static const QColor darkTabBarTabBackgroundSelected(52, 52, 52); +static const QColor tabBarTabBackgroundSelected() { return isDarkMode() ? darkTabBarTabBackgroundSelected : lightTabBarTabBackgroundSelected; } + +static const QColor lightTabBarTabLineActive(160, 160, 160); +static const QColor darkTabBarTabLineActive(90, 90, 90); +static const QColor tabBarTabLineActive() { return isDarkMode() ? darkTabBarTabLineActive : lightTabBarTabLineActive; } + +static const QColor lightTabBarTabLineActiveHovered(150, 150, 150); +static const QColor darkTabBarTabLineActiveHovered(90, 90, 90); +static const QColor tabBarTabLineActiveHovered() { return isDarkMode() ? darkTabBarTabLineActiveHovered : lightTabBarTabLineActiveHovered; } + +static const QColor lightTabBarTabLine(210, 210, 210); +static const QColor darkTabBarTabLine(90, 90, 90); +static const QColor tabBarTabLine() { return isDarkMode() ? darkTabBarTabLine : lightTabBarTabLine; } + +static const QColor lightTabBarTabLineSelected(189, 189, 189); +static const QColor darkTabBarTabLineSelected(90, 90, 90); +static const QColor tabBarTabLineSelected() { return isDarkMode() ? darkTabBarTabLineSelected : lightTabBarTabLineSelected; } + static const QColor tabBarCloseButtonBackgroundHovered(162, 162, 162); static const QColor tabBarCloseButtonBackgroundPressed(153, 153, 153); static const QColor tabBarCloseButtonBackgroundSelectedHovered(192, 192, 192); @@ -561,7 +590,7 @@ void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, in const bool active = (tabOpt->state & QStyle::State_Active); const bool selected = (tabOpt->state & QStyle::State_Selected); - const QRect bodyRect(1, 1, width - 2, height - 2); + const QRect bodyRect(1, 2, width - 2, height - 3); const QRect topLineRect(1, 0, width - 2, 1); const QRect bottomLineRect(1, height - 1, width - 2, 1); if (selected) { @@ -572,27 +601,27 @@ void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, in p->fillRect(tabRect, QColor(Qt::transparent)); p->restore(); } else if (active) { - p->fillRect(bodyRect, tabBarTabBackgroundActiveSelected); + p->fillRect(bodyRect, tabBarTabBackgroundActiveSelected()); // top line - p->fillRect(topLineRect, tabBarTabLineSelected); + p->fillRect(topLineRect, tabBarTabLineSelected()); } else { - p->fillRect(bodyRect, tabBarTabBackgroundSelected); + p->fillRect(bodyRect, tabBarTabBackgroundSelected()); } } else { // when the mouse is over non selected tabs they get a new color const bool hover = (tabOpt->state & QStyle::State_MouseOver); if (hover) { // fill body - p->fillRect(bodyRect, tabBarTabBackgroundActiveHovered); + p->fillRect(bodyRect, tabBarTabBackgroundActiveHovered()); // bottom line - p->fillRect(bottomLineRect, tabBarTabLineActiveHovered); + p->fillRect(bottomLineRect, isDarkMode() ? QColor(Qt::black) : tabBarTabLineActiveHovered()); } } // separator lines between tabs const QRect leftLineRect(0, 1, 1, height - 2); const QRect rightLineRect(width - 1, 1, 1, height - 2); - const QColor separatorLineColor = active ? tabBarTabLineActive : tabBarTabLine; + const QColor separatorLineColor = active ? tabBarTabLineActive() : tabBarTabLine(); p->fillRect(leftLineRect, separatorLineColor); p->fillRect(rightLineRect, separatorLineColor); } @@ -612,17 +641,20 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget * // fill body const QRect bodyRect(0, 1, width, height - 1); - const QColor bodyColor = active ? tabBarTabBackgroundActive : tabBarTabBackground; + const QColor bodyColor = active ? tabBarTabBackgroundActive() : tabBarTabBackground(); p->fillRect(bodyRect, bodyColor); // top line const QRect topLineRect(0, 0, width, 1); - const QColor topLineColor = active ? tabBarTabLineActive : tabBarTabLine; + const QColor topLineColor = active ? tabBarTabLineActive() : tabBarTabLine(); p->fillRect(topLineRect, topLineColor); // bottom line const QRect bottomLineRect(0, height - 1, width, 1); - const QColor bottomLineColor = active ? tabBarTabLineActive : tabBarTabLine; + bool isDocument = false; + if (const QTabBar *tabBar = qobject_cast<const QTabBar*>(w)) + isDocument = tabBar->documentMode(); + const QColor bottomLineColor = isDocument && isDarkMode() ? QColor(Qt::black) : active ? tabBarTabLineActive() : tabBarTabLine(); p->fillRect(bottomLineRect, bottomLineColor); } #endif @@ -1227,11 +1259,17 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int Q_UNREACHABLE(); } - const auto focusRingColor = qt_mac_toQColor(NSColor.keyboardFocusIndicatorColor.CGColor); + auto focusRingColor = qt_mac_toQColor(NSColor.keyboardFocusIndicatorColor.CGColor); + if (!qt_mac_applicationIsInDarkMode()) { + // This color already has alpha ~ 0.25, this value is too small - the ring is + // very pale and nothing like the native one. 0.39 makes it better (not ideal + // anyway). The color seems to be correct in dark more without any modification. + focusRingColor.setAlphaF(0.39); + } p->save(); p->setRenderHint(QPainter::Antialiasing); - p->setOpacity(0.5); + if (cw.type == SegmentedControl_First) { // TODO Flip left-right } @@ -3536,7 +3574,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (tbstyle == Qt::ToolButtonTextOnly || (tbstyle != Qt::ToolButtonTextOnly && !down)) { QPen pen = p->pen(); - QColor light = down ? Qt::black : Qt::white; + QColor light = down || isDarkMode() ? Qt::black : Qt::white; light.setAlphaF(0.375f); p->setPen(light); p->drawText(cr.adjusted(0, 1, 0, 1), alignment, tb->text); @@ -3958,6 +3996,11 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (!tabBar->tabTextColor(tabBar->currentIndex()).isValid()) myTab.palette.setColor(QPalette::WindowText, Qt::white); + if (myTab.documentMode && isDarkMode()) { + bool active = (myTab.state & State_Selected) && (myTab.state & State_Active); + myTab.palette.setColor(QPalette::WindowText, active ? Qt::white : Qt::gray); + } + int heightOffset = 0; if (verticalTabs) { heightOffset = -1; @@ -4444,16 +4487,17 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter p->fillRect(opt->rect, linearGrad); p->save(); + QRect toolbarRect = isDarkMode ? opt->rect.adjusted(0, 0, 0, 1) : opt->rect; if (opt->state & State_Horizontal) { p->setPen(isDarkMode ? darkModeSeparatorLine : mainWindowGradientBegin.lighter(114)); - p->drawLine(opt->rect.topLeft(), opt->rect.topRight()); + p->drawLine(toolbarRect.topLeft(), toolbarRect.topRight()); p->setPen(isDarkMode ? darkModeSeparatorLine :mainWindowGradientEnd.darker(114)); - p->drawLine(opt->rect.bottomLeft(), opt->rect.bottomRight()); + p->drawLine(toolbarRect.bottomLeft(), toolbarRect.bottomRight()); } else { p->setPen(isDarkMode ? darkModeSeparatorLine : mainWindowGradientBegin.lighter(114)); - p->drawLine(opt->rect.topLeft(), opt->rect.bottomLeft()); + p->drawLine(toolbarRect.topLeft(), toolbarRect.bottomLeft()); p->setPen(isDarkMode ? darkModeSeparatorLine : mainWindowGradientEnd.darker(114)); - p->drawLine(opt->rect.topRight(), opt->rect.bottomRight()); + p->drawLine(toolbarRect.topRight(), toolbarRect.bottomRight()); } p->restore(); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b71a0ed052..89a8a7be0f 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1543,14 +1543,19 @@ void QWidgetPrivate::createTLSysExtra() extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); if (extra->topextra->opacity != 255 && q->isWindow()) extra->topextra->window->setOpacity(qreal(extra->topextra->opacity) / qreal(255)); + + const bool isTipLabel = q->inherits("QTipLabel"); + const bool isAlphaWidget = !isTipLabel && q->inherits("QAlphaWidget"); #ifdef Q_OS_WIN // Pass on native parent handle for Widget embedded into Active X. const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty); if (activeXNativeParentHandle.isValid()) extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle); - if (q->inherits("QTipLabel") || q->inherits("QAlphaWidget")) + if (isTipLabel || isAlphaWidget) extra->topextra->window->setProperty("_q_windowsDropShadow", QVariant(true)); #endif + if (isTipLabel || isAlphaWidget || q->inherits("QRollEffect")) + qt_window_private(extra->topextra->window)->setAutomaticPositionAndResizeEnabled(false); } } |