summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/global/macros.qdocconf8
-rw-r--r--src/gui/painting/qcolor.cpp30
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp9
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style_p.h1
-rw-r--r--src/testlib/qtestlog.cpp6
-rw-r--r--src/widgets/widgets/qtabbar.cpp66
-rw-r--r--src/widgets/widgets/qtabbar_p.h3
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST5
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp33
9 files changed, 96 insertions, 65 deletions
diff --git a/doc/global/macros.qdocconf b/doc/global/macros.qdocconf
index ae08c76ad93..f414b3fed18 100644
--- a/doc/global/macros.qdocconf
+++ b/doc/global/macros.qdocconf
@@ -91,11 +91,11 @@ macro.NdkFullVer = "27.2.12479018"
macro.NdkCompilerVer = "Clang 17.0.2"
macro.JdkVer = "17"
macro.AndroidMinApiVer = "28"
-macro.AndroidMaxApiVer = "35"
+macro.AndroidMaxApiVer = "36"
macro.AndroidMinVer = "9"
-macro.AndroidMaxVer = "15"
-macro.AndroidPlatformVer = "35"
-macro.AndroidBuildToolsVer = "35.0.1"
+macro.AndroidMaxVer = "16"
+macro.AndroidPlatformVer = "36"
+macro.AndroidBuildToolsVer = "36.0.0"
macro.GradleVer = "8.14.3"
macro.AGPVer = "8.10.1"
macro.AAOSVer = "10 to 13"
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index fe79490f54b..d63da38b747 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2196,29 +2196,27 @@ QColor QColor::toHsv() const noexcept
color.ct.ahsv.alpha = ct.argb.alpha;
color.ct.ahsv.pad = 0;
- const float r = ct.argb.red / float(USHRT_MAX);
- const float g = ct.argb.green / float(USHRT_MAX);
- const float b = ct.argb.blue / float(USHRT_MAX);
- const float max = Q_MAX_3(r, g, b);
- const float min = Q_MIN_3(r, g, b);
- const float delta = max - min;
- color.ct.ahsv.value = qRound(max * USHRT_MAX);
- if (qFuzzyIsNull(delta)) {
+ const ushort r = ct.argb.red;
+ const ushort g = ct.argb.green;
+ const ushort b = ct.argb.blue;
+ const auto [min, max] = std::minmax({r, g, b});
+ color.ct.ahsv.value = max;
+ if (max == min) {
// achromatic case, hue is undefined
color.ct.ahsv.hue = USHRT_MAX;
color.ct.ahsv.saturation = 0;
} else {
// chromatic case
- float hue = 0;
+ const float delta = max - min; // cannot overflow
+ float hue;
color.ct.ahsv.saturation = qRound((delta / max) * USHRT_MAX);
- if (qFuzzyCompare(r, max)) {
- hue = ((g - b) /delta);
- } else if (qFuzzyCompare(g, max)) {
- hue = (2.0f + (b - r) / delta);
- } else if (qFuzzyCompare(b, max)) {
- hue = (4.0f + (r - g) / delta);
+ if (max == r) {
+ hue = 0 + (g - b) / delta;
+ } else if (max == g) {
+ hue = 2 + (b - r) / delta;
} else {
- Q_ASSERT_X(false, "QColor::toHsv", "internal error");
+ Q_ASSERT(max == b); // max({r,g,b}) must be one of r, g, and b!
+ hue = 4 + (r - g) / delta;
}
hue *= 60.0f;
if (hue < 0.0f)
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index e9b90d787bc..98e51397c17 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -2622,6 +2622,7 @@ void QWindows11Style::polish(QPalette& result)
d->m_titleBarNormalIcon = QIcon();
d->m_toolbarExtensionButton = QIcon();
d->m_lineEditClearButton = QIcon();
+ d->m_tabCloseButton = QIcon();
}
QPixmap QWindows11Style::standardPixmap(StandardPixmap standardPixmap,
@@ -2662,6 +2663,14 @@ QIcon QWindows11Style::standardIcon(StandardPixmap standardIcon,
}
return d->m_toolbarExtensionButton;
}
+ case SP_TabCloseButton: {
+ if (d->m_tabCloseButton.isNull()) {
+ auto e = new WinFontIconEngine(fluentIcon(Icon::ChromeClose), d->assetFont);
+ e->setScale(0.6);
+ d->m_tabCloseButton = QIcon(e);
+ }
+ return d->m_tabCloseButton;
+ }
default:
break;
}
diff --git a/src/plugins/styles/modernwindows/qwindows11style_p.h b/src/plugins/styles/modernwindows/qwindows11style_p.h
index 9d0cdda3e33..43a344a6ac9 100644
--- a/src/plugins/styles/modernwindows/qwindows11style_p.h
+++ b/src/plugins/styles/modernwindows/qwindows11style_p.h
@@ -125,6 +125,7 @@ class QWindows11StylePrivate : public QWindowsVistaStylePrivate {
protected:
QIcon m_toolbarExtensionButton;
QIcon m_lineEditClearButton;
+ QIcon m_tabCloseButton;
};
QT_END_NAMESPACE
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 29cafe9aea4..f3db4ece49e 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -305,9 +305,7 @@ namespace QTest {
{
static QBasicAtomicInt counter = Q_BASIC_ATOMIC_INITIALIZER(QTest::maxWarnings);
- auto loggerCapture = loggers->allLoggers();
-
- if (loggerCapture.isEmpty()) {
+ if (loggers.isDestroyed() || loggers->allLoggers().isEmpty()) {
// the message handler may be called from a worker thread, after the main thread stopped
// logging. Forwarding to original message handler to avoid swallowing the message
Q_ASSERT(oldMessageHandler);
@@ -326,6 +324,8 @@ namespace QTest {
return;
}
+ auto loggerCapture = loggers->allLoggers();
+
if (type != QtFatalMsg) {
if (counter.loadRelaxed() <= 0)
return;
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 0f0abb6e1d5..44218d41ded 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -52,6 +52,14 @@ public:
void enterEvent(QEnterEvent *event) override;
void leaveEvent(QEvent *event) override;
void paintEvent(QPaintEvent *event) override;
+
+ void setParentClipRect(const QRect &clipRect)
+ {
+ m_parentClipRect = clipRect;
+ }
+
+protected:
+ QRect m_parentClipRect;
};
}
@@ -598,10 +606,11 @@ QRect QTabBarPrivate::normalizedScrollRect(int index)
q->initStyleOption(&opt, currentIndex);
opt.rect = q->rect();
- QRect scrollButtonLeftRect = q->style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);
- QRect scrollButtonRightRect = q->style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);
- QRect tearLeftRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &opt, q);
- QRect tearRightRect = q->style()->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &opt, q);
+ const auto style = q->style();
+ QRect scrollButtonLeftRect = style->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, q);
+ QRect scrollButtonRightRect = style->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, q);
+ QRect tearLeftRect = style->subElementRect(QStyle::SE_TabBarTearIndicatorLeft, &opt, q);
+ QRect tearRightRect = style->subElementRect(QStyle::SE_TabBarTearIndicatorRight, &opt, q);
if (verticalTabs(shape)) {
int topEdge, bottomEdge;
@@ -739,7 +748,7 @@ void QTabBarPrivate::layoutTab(int index)
if (tab->leftWidget) {
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
QPoint p = rect.topLeft();
- if ((index == pressedIndex) || paintWithOffsets) {
+ if (index == pressedIndex) {
if (vertical)
p.setY(p.y() + tab->dragOffset);
else
@@ -750,7 +759,7 @@ void QTabBarPrivate::layoutTab(int index)
if (tab->rightWidget) {
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabRightButton, &opt, q);
QPoint p = rect.topLeft();
- if ((index == pressedIndex) || paintWithOffsets) {
+ if (index == pressedIndex) {
if (vertical)
p.setY(p.y() + tab->dragOffset);
else
@@ -1004,8 +1013,13 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
}
if (isVisible() && tabAt(d->mousePosition) == index) {
- d->hoverIndex = index;
- d->hoverRect = tabRect(index);
+ if (d->normalizedScrollRect(index).contains(d->mousePosition)) {
+ d->hoverIndex = index;
+ d->hoverRect = tabRect(index);
+ } else {
+ d->hoverIndex = -1;
+ d->hoverRect = QRect();
+ }
}
tabInserted(index);
@@ -1096,11 +1110,13 @@ void QTabBar::removeTab(int index)
if (d->hoverRect.isValid()) {
update(d->hoverRect);
d->hoverIndex = tabAt(d->mousePosition);
- if (d->validIndex(d->hoverIndex)) {
+ if (d->validIndex(d->hoverIndex)
+ && d->normalizedScrollRect(d->hoverIndex).contains(d->mousePosition)) {
d->hoverRect = tabRect(d->hoverIndex);
update(d->hoverRect);
} else {
d->hoverRect = QRect();
+ d->hoverIndex = -1;
}
}
tabRemoved(index);
@@ -1692,15 +1708,18 @@ bool QTabBar::event(QEvent *event)
case QEvent::HoverEnter: {
QHoverEvent *he = static_cast<QHoverEvent *>(event);
d->mousePosition = he->position().toPoint();
- if (!d->hoverRect.contains(d->mousePosition)) {
+ const auto sr = d->normalizedScrollRect();
+ const auto oldHoverRect = d->hoverRect & sr;
+ if (!oldHoverRect.contains(d->mousePosition)) {
if (d->hoverRect.isValid())
update(d->hoverRect);
d->hoverIndex = tabAt(d->mousePosition);
- if (d->validIndex(d->hoverIndex)) {
+ if (d->validIndex(d->hoverIndex) && sr.contains(d->mousePosition)) {
d->hoverRect = tabRect(d->hoverIndex);
update(d->hoverRect);
} else {
d->hoverRect = QRect();
+ d->hoverIndex = -1;
}
}
return true;
@@ -1845,10 +1864,14 @@ void QTabBar::paintEvent(QPaintEvent *)
QStyleOption opt;
opt.initFrom(this);
QRegion buttonRegion;
- if (d->leftB->isVisible())
- buttonRegion |= style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, this);
- if (d->rightB->isVisible())
- buttonRegion |= style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, this);
+ if (d->leftB->isVisible()) {
+ const auto r = style()->subElementRect(QStyle::SE_TabBarScrollLeftButton, &opt, this);
+ buttonRegion |= r;
+ }
+ if (d->rightB->isVisible()) {
+ const auto r = style()->subElementRect(QStyle::SE_TabBarScrollRightButton, &opt, this);
+ buttonRegion |= r;
+ }
if (!buttonRegion.isEmpty())
p.setClipRegion(QRegion(rect()) - buttonRegion);
}
@@ -1857,9 +1880,13 @@ void QTabBar::paintEvent(QPaintEvent *)
const auto tab = d->tabList.at(i);
if (!tab->visible)
continue;
+ for (const auto side : { QTabBar::LeftSide, QTabBar::RightSide }) {
+ if (auto closeButton = qobject_cast<CloseButton *>(tabButton(i, side)))
+ closeButton->setParentClipRect(scrollRect);
+ }
QStyleOptionTab tabOption;
initStyleOption(&tabOption, i);
- if (d->paintWithOffsets && tab->dragOffset != 0) {
+ if (tab->dragOffset != 0) {
if (vertical) {
tabOption.rect.moveTop(tabOption.rect.y() + tab->dragOffset);
} else {
@@ -1901,7 +1928,7 @@ void QTabBar::paintEvent(QPaintEvent *)
const auto tab = d->tabList.at(selected);
initStyleOption(&tabOption, selected);
- if (d->paintWithOffsets && tab->dragOffset != 0) {
+ if (tab->dragOffset != 0) {
// if the drag offset is != 0, a move is in progress (drag or animation)
// => set the tab position to Moving to preserve the rect
tabOption.position = QStyleOptionTab::TabPosition::Moving;
@@ -2934,6 +2961,11 @@ void CloseButton::paintEvent(QPaintEvent *)
opt.state |= QStyle::State_Selected;
}
+ if (m_parentClipRect.isValid()) {
+ auto tl = mapFromParent(m_parentClipRect.topLeft());
+ auto br = mapFromParent(m_parentClipRect.bottomRight());
+ p.setClipRect(QRect(tl, br));
+ }
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
}
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 38fbde76470..5b31926253f 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -56,7 +56,7 @@ public:
QTabBarPrivate()
: layoutDirty(false), drawBase(true), elideModeSetByUser(false), useScrollButtons(false),
useScrollButtonsSetByUser(false), expanding(true), closeButtonOnTabs(false),
- paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false),
+ movable(false), dragInProgress(false), documentMode(false),
autoHide(false), changeCurrentOnDrag(false)
{}
~QTabBarPrivate()
@@ -95,7 +95,6 @@ public:
bool useScrollButtonsSetByUser : 1;
bool expanding : 1;
bool closeButtonOnTabs : 1;
- bool paintWithOffsets : 1;
bool movable : 1;
bool dragInProgress : 1;
bool documentMode : 1;
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 9651c1480c8..12da5b423ab 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -4,11 +4,6 @@ osx
macos arm
[render_systemClip]
osx
-[multipleToplevelFocusCheck]
-centos
-opensuse-leap
-ubuntu
-sles-15
# QTBUG-87668
[showMinimizedKeepsFocus]
android
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index e3d172c60c0..359a0946474 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -6931,9 +6931,13 @@ class TopLevelFocusCheck: public QWidget
Q_OBJECT
public:
QLineEdit* edit;
- explicit TopLevelFocusCheck(QWidget *parent = nullptr)
+ explicit TopLevelFocusCheck(const QString &name, QWidget *parent = nullptr)
: QWidget(parent), edit(new QLineEdit(this))
{
+ const QString title = QLatin1String(QTest::currentTestFunction()) + "_"_L1 + name;
+ setWindowTitle(title);
+ setObjectName(title);
+ edit->setObjectName(QString("%1_edit"_L1).arg(title));
edit->hide();
edit->installEventFilter(this);
}
@@ -6943,7 +6947,7 @@ public slots:
{
edit->show();
edit->setFocus(Qt::OtherFocusReason);
- QCoreApplication::processEvents();
+ QVERIFY(QTest::qWaitForWindowFocused(edit));
}
bool eventFilter(QObject *obj, QEvent *event) override
{
@@ -6963,49 +6967,42 @@ void tst_QWidget::multipleToplevelFocusCheck()
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("Window activation is not supported");
- TopLevelFocusCheck w1;
- TopLevelFocusCheck w2;
+ TopLevelFocusCheck w1("Widget-1"_L1);
+ TopLevelFocusCheck w2("Widget-2"_L1);
- const QString title = QLatin1String(QTest::currentTestFunction());
- w1.setWindowTitle(title + QLatin1String("_W1"));
w1.move(m_availableTopLeft + QPoint(20, 20));
w1.resize(200, 200);
w1.show();
QVERIFY(QTest::qWaitForWindowExposed(&w1));
- w2.setWindowTitle(title + QLatin1String("_W2"));
w2.move(w1.frameGeometry().topRight() + QPoint(20, 0));
w2.resize(200,200);
w2.show();
QVERIFY(QTest::qWaitForWindowExposed(&w2));
w1.activateWindow();
- QApplicationPrivate::setActiveWindow(&w1);
QVERIFY(QTest::qWaitForWindowActive(&w1));
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
+ QTRY_COMPARE(QApplication::activeWindow(), &w1);
QTest::mouseDClick(&w1, Qt::LeftButton);
- QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit));
+ QTRY_COMPARE(QApplication::focusWidget(), w1.edit);
w2.activateWindow();
- QApplicationPrivate::setActiveWindow(&w2);
QVERIFY(QTest::qWaitForWindowActive(&w2));
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
+ QTRY_COMPARE(QApplication::activeWindow(), &w2);
QTest::mouseClick(&w2, Qt::LeftButton);
QTRY_COMPARE(QApplication::focusWidget(), nullptr);
QTest::mouseDClick(&w2, Qt::LeftButton);
- QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w2.edit));
+ QTRY_COMPARE(QApplication::focusWidget(), w2.edit);
w1.activateWindow();
- QApplicationPrivate::setActiveWindow(&w1);
QVERIFY(QTest::qWaitForWindowActive(&w1));
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w1));
+ QTRY_COMPARE(QApplication::activeWindow(), &w1);
QTest::mouseDClick(&w1, Qt::LeftButton);
- QTRY_COMPARE(QApplication::focusWidget(), static_cast<QWidget *>(w1.edit));
+ QTRY_COMPARE(QApplication::focusWidget(), w1.edit);
w2.activateWindow();
- QApplicationPrivate::setActiveWindow(&w2);
QVERIFY(QTest::qWaitForWindowActive(&w2));
- QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&w2));
+ QTRY_COMPARE(QApplication::activeWindow(), &w2);
QTest::mouseClick(&w2, Qt::LeftButton);
QTRY_COMPARE(QApplication::focusWidget(), nullptr);
}