diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/corelib/kernel/qassociativeiterable.h | 15 | ||||
| -rw-r--r-- | src/corelib/kernel/qsequentialiterable.h | 15 | ||||
| -rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 7 | ||||
| -rw-r--r-- | src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 10 | ||||
| -rw-r--r-- | src/testlib/qtest.h | 8 | ||||
| -rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 11 | ||||
| -rw-r--r-- | src/widgets/kernel/qstandardgestures.cpp | 10 | ||||
| -rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 46 |
8 files changed, 64 insertions, 58 deletions
diff --git a/src/corelib/kernel/qassociativeiterable.h b/src/corelib/kernel/qassociativeiterable.h index 4f9bbf67bfb..c042fe4a0ec 100644 --- a/src/corelib/kernel/qassociativeiterable.h +++ b/src/corelib/kernel/qassociativeiterable.h @@ -21,9 +21,8 @@ QT_WARNING_DISABLE_DEPRECATED Q_CORE_EXPORT QT_DEPRECATED_VERSION_X_6_15(text) #endif -class -QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaAssociation::Iterable::Iterator instead.") -QAssociativeIterator : public QIterator<QMetaAssociation> +// Keep this a single long line, otherwise syncqt doesn't create a class forwarding header +class QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaAssociation's iterables and iterators instead.") QAssociativeIterator : public QIterator<QMetaAssociation> { public: using key_type = QVariant; @@ -42,9 +41,8 @@ public: QVariantPointer<QAssociativeIterator> operator->() const; }; -class -QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaAssociation::Iterable::ConstIterator instead.") -QAssociativeConstIterator : public QConstIterator<QMetaAssociation> +// Keep this a single long line, otherwise syncqt doesn't create a class forwarding header +class QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaAssociation's iterables and iterators instead.") QAssociativeConstIterator : public QConstIterator<QMetaAssociation> { public: using key_type = QVariant; @@ -63,9 +61,8 @@ public: QVariantConstPointer operator->() const; }; -class -QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaAssociation::Iterable instead.") -QAssociativeIterable : public QIterable<QMetaAssociation> +// Keep this a single long line, otherwise syncqt doesn't create a class forwarding header +class QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaAssociation's iterables and iterators instead.") QAssociativeIterable : public QIterable<QMetaAssociation> { public: using iterator = QTaggedIterator<QAssociativeIterator, void>; diff --git a/src/corelib/kernel/qsequentialiterable.h b/src/corelib/kernel/qsequentialiterable.h index 76908bdae4b..b2e690ea9cf 100644 --- a/src/corelib/kernel/qsequentialiterable.h +++ b/src/corelib/kernel/qsequentialiterable.h @@ -21,9 +21,8 @@ QT_WARNING_DISABLE_DEPRECATED Q_CORE_EXPORT QT_DEPRECATED_VERSION_X_6_15(text) #endif -class -QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaSequence::Iterable::Iterator instead.") -QSequentialIterator : public QIterator<QMetaSequence> +// Keep this a single long line, otherwise syncqt doesn't create a class forwarding header +class QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaSequence's iterables and iterators instead.") QSequentialIterator : public QIterator<QMetaSequence> { public: using value_type = QVariant; @@ -38,9 +37,8 @@ public: QVariantPointer<QSequentialIterator> operator->() const; }; -class -QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaSequence::Iterable::ConstIterator instead.") -QSequentialConstIterator : public QConstIterator<QMetaSequence> +// Keep this a single long line, otherwise syncqt doesn't create a class forwarding header +class QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaSequence's iterables and iterators instead.") QSequentialConstIterator : public QConstIterator<QMetaSequence> { public: using value_type = QVariant; @@ -55,9 +53,8 @@ public: QVariantConstPointer operator->() const; }; -class -QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaSequence::Iterable instead.") -QSequentialIterable : public QIterable<QMetaSequence> +// Keep this a single long line, otherwise syncqt doesn't create a class forwarding header +class QT_CORE_DEPRECATED_EXPORT_VERSION_X_6_15("Use QMetaSequence's iterables and iterators instead.") QSequentialIterable : public QIterable<QMetaSequence> { public: using iterator = QTaggedIterator<QSequentialIterator, void>; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9459e8bdfd3..f96f154f5b1 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -4035,10 +4035,13 @@ void QWindowsWindow::requestUpdate() // the Posted event on the GUI thread. if (m_vsyncUpdatePending.testAndSetAcquire(UpdateState::Requested, UpdateState::Posted)) { QWindowsWindow *oldSelf = this; - QMetaObject::invokeMethod(w, [w, oldSelf] { + qsizetype oldCallbackId = m_vsyncServiceCallbackId; + QMetaObject::invokeMethod(w, [w, oldSelf, oldCallbackId] { // 'oldSelf' is only used for comparison, don't access it directly! auto *self = static_cast<QWindowsWindow *>(w->handle()); - if (self && self == oldSelf) { + // NOTE: In the off chance that the window got destroyed and recreated with the + // same address, we also check that the callback id is the same. + if (self && self == oldSelf && self->m_vsyncServiceCallbackId == oldCallbackId) { // The platform window is still alive self->m_vsyncUpdatePending.storeRelease(UpdateState::Ready); self->deliverUpdateRequest(); diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index e2f181aa628..2ea3fe38e1c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -596,6 +596,16 @@ HRESULT QWindowsUiaMainProvider::GetPropertyValue(PROPERTYID idProp, VARIANT *pR *pRetVal = QComVariant{ accessible->text(QAccessible::Help) }.release(); break; case UIA_HasKeyboardFocusPropertyId: + // If the top-level window has no focused child, report the top-level + // widget (window). If it already has a focused widget, it will be + // reported automatically. + if (topLevelWindow) { + QAccessibleInterface *focusacc = accessible->focusChild(); + if (!focusacc) { + *pRetVal = QComVariant{ accessible->state().active ? true : false }.release(); + break; + } + } *pRetVal = QComVariant{ accessible->state().focused ? true : false }.release(); break; case UIA_IsKeyboardFocusablePropertyId: diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 431f91d5474..10bb63040c8 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -181,16 +181,16 @@ inline bool qCompare(quint32 const &t1, quint64 const &t2, const char *actual, } namespace Internal { -template <typename T, typename = void> -struct HasInitMain : std::false_type{}; +template <typename T> +using InitMainTest = decltype(&T::initMain); template <typename T> -struct HasInitMain<T, std::void_t<decltype(&T::initMain)>> : std::true_type {}; +constexpr inline bool hasInitMain = qxp::is_detected_v<InitMainTest, T>; template<typename T> void callInitMain() { - if constexpr (HasInitMain<T>::value) + if constexpr (hasInitMain<T>) T::initMain(); } diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 570566793dc..0f0496ad04d 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1622,12 +1622,6 @@ void QTreeViewPrivate::calcLogicalIndices( const auto indicesCount = logicalIndices->size(); itemPositions->resize(indicesCount); for (qsizetype currentLogicalSection = 0; currentLogicalSection < indicesCount; ++currentLogicalSection) { - // shortcut, no need to calc anything more - if (indicesCount == 1 || spanning) { - (*itemPositions)[currentLogicalSection] = QStyleOptionViewItem::OnlyOne; - continue; - } - const int headerSection = logicalIndices->at(currentLogicalSection); // determine the viewItemPosition depending on the position of column 0 int nextLogicalSection = currentLogicalSection + 1 >= indicesCount ? logicalIndexAfterRight @@ -1635,8 +1629,11 @@ void QTreeViewPrivate::calcLogicalIndices( int prevLogicalSection = currentLogicalSection - 1 < 0 ? logicalIndexBeforeLeft : logicalIndices->at(currentLogicalSection - 1); + const int headerSection = logicalIndices->at(currentLogicalSection); QStyleOptionViewItem::ViewItemPosition pos; - if ((nextLogicalSection != 0 && prevLogicalSection == -1) || isTreePosition(headerSection)) + if ((nextLogicalSection == -1 && prevLogicalSection == -1) || spanning) { + pos = QStyleOptionViewItem::OnlyOne; + } else if ((nextLogicalSection != 0 && prevLogicalSection == -1) || isTreePosition(headerSection)) pos = QStyleOptionViewItem::Beginning; else if (nextLogicalSection == 0 || nextLogicalSection == -1) pos = QStyleOptionViewItem::End; diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index e9de82d2357..314d82fd64f 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -348,8 +348,14 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state, result = QGestureRecognizer::Ignore; break; case QSwipeGesturePrivate::ThreePointsReached: - result = (ev->touchPointStates() & QEventPoint::State::Pressed) - ? QGestureRecognizer::CancelGesture : QGestureRecognizer::Ignore; + if (ev->touchPointStates() & QEventPoint::State::Pressed) { + result = QGestureRecognizer::CancelGesture; + } else if (d->verticalDirection != QSwipeGesture::NoDirection || + d->horizontalDirection != QSwipeGesture::NoDirection) { + result = QGestureRecognizer::TriggerGesture; + } else { + result = QGestureRecognizer::Ignore; + } break; } } diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 592b70ef8ba..1f026775435 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1200,7 +1200,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w int vpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2; if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth) verticalShift = -verticalShift; - tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding); + tr.adjust(hpadding, verticalShift + vpadding, horizontalShift - hpadding, -vpadding); bool selected = opt->state & QStyle::State_Selected; if (selected) { tr.setTop(tr.top() - verticalShift); @@ -1625,23 +1625,18 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { QRect rect = header->rect; if (!header->icon.isNull()) { - int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); - QPixmap pixmap - = header->icon.pixmap(QSize(iconExtent, iconExtent), QStyleHelper::getDpr(p), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); - int pixw = pixmap.width() / pixmap.devicePixelRatio(); - - QRect aligned = alignedRect(header->direction, header->iconAlignment, pixmap.size() / pixmap.devicePixelRatio(), rect); - QRect inter = aligned.intersected(rect); - p->drawPixmap(inter.x(), inter.y(), pixmap, - inter.x() - aligned.x(), inter.y() - aligned.y(), - aligned.width() * pixmap.devicePixelRatio(), - pixmap.height() * pixmap.devicePixelRatio()); + const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); + const QRect aligned = alignedRect(header->direction, header->iconAlignment, + QSize(iconExtent, iconExtent), rect); + header->icon.paint(p, aligned, Qt::AlignCenter, + header->state.testFlag(State_Enabled) ? QIcon::Normal + : QIcon::Disabled); const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); if (header->direction == Qt::LeftToRight) - rect.setLeft(rect.left() + pixw + margin); + rect.setLeft(rect.left() + iconExtent + margin); else - rect.setRight(rect.right() - pixw - margin); + rect.setRight(rect.right() - iconExtent - margin); } QFontMetrics fm(header->fontMetrics); if (header->state & QStyle::State_On) { @@ -2838,7 +2833,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; - hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt bool verticalTabs = tab->shape == QTabBar::RoundedEast || tab->shape == QTabBar::RoundedWest @@ -2866,8 +2860,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize; int w = size.width(); int h = size.height(); - int midHeight = static_cast<int>(qCeil(float(tr.height() - h) / 2)); - int midWidth = ((tr.width() - w) / 2); bool atTheTop = true; switch (tab->shape) { @@ -2879,14 +2871,19 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case QTabBar::TriangularEast: atTheTop = (sr == SE_TabBarTabRightButton); break; - default: + default: { + const int midHeight = + tr.y() + static_cast<int>(qCeil(float(tr.height() - h) / 2)); if (sr == SE_TabBarTabLeftButton) r = QRect(tab->rect.x() + hpadding, midHeight, w, h); else r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h); r = visualRect(tab->direction, tab->rect, r); + break; + } } if (verticalTabs) { + const int midWidth = tr.x() + ((tr.width() - w) / 2); if (atTheTop) r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h); else @@ -4209,20 +4206,19 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex #if QT_CONFIG(toolbutton) case CC_ToolButton: if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { - int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget); ret = tb->rect; switch (sc) { case SC_ToolButton: - if ((tb->features - & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) - == QStyleOptionToolButton::MenuButtonPopup) + if (tb->features.testFlag(QStyleOptionToolButton::MenuButtonPopup)) { + const int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget); ret.adjust(0, 0, -mbi, 0); + } break; case SC_ToolButtonMenu: - if ((tb->features - & (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay)) - == QStyleOptionToolButton::MenuButtonPopup) + if (tb->features.testFlag(QStyleOptionToolButton::MenuButtonPopup)) { + const int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget); ret.adjust(ret.width() - mbi, 0, 0, 0); + } break; default: break; |
