From ff8d757e222d0b9b8618b83e6c4186e366e917e9 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 4 Sep 2020 21:09:44 +0200 Subject: QWidget: mark obsolete function isTopLevel() as deprecated QWidget::isTopLevel() is deprecated and can be replaced 1:1 with isWindow(). Sadly it's was not marked with Q_DECL_DEPRECATED in 5.15 Change-Id: I4508fbde41927f3b82e47a75011179548325029d Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidget.cpp | 6 +++--- src/widgets/kernel/qwidget.h | 3 +++ src/widgets/kernel/qwidgetwindow.cpp | 2 +- src/widgets/styles/qfusionstyle.cpp | 2 +- src/widgets/widgets/qmainwindowlayout.cpp | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index bcd718d521..023a987dc4 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1328,7 +1328,7 @@ void QWidgetPrivate::create() if (!store) { if (q->windowType() != Qt::Desktop) { - if (q->isTopLevel()) + if (q->isWindow()) q->setBackingStore(new QBackingStore(win)); } else { q->setAttribute(Qt::WA_PaintOnScreen, true); @@ -11855,7 +11855,7 @@ void QWidget::setBackingStore(QBackingStore *store) { // ### createWinId() ?? - if (!isTopLevel()) + if (!isWindow()) return; Q_D(QWidget); @@ -11872,7 +11872,7 @@ void QWidget::setBackingStore(QBackingStore *store) if (!repaintManager) return; - if (isTopLevel()) { + if (isWindow()) { if (repaintManager->backingStore() != oldStore && repaintManager->backingStore() != store) delete repaintManager->backingStore(); repaintManager->setBackingStore(store); diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 14608a5f13..11d143d0e4 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -230,7 +230,10 @@ public: void setStyle(QStyle *); // Widget types and states +#if QT_DEPRECATED_SINCE(6, 2) + QT_DEPRECATED_VERSION_X_6_1("Use isWindow()") bool isTopLevel() const; +#endif bool isWindow() const; bool isModal() const; diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index e4e8f9f9d1..ae1e461d7a 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -800,7 +800,7 @@ void QWidgetWindow::handleMoveEvent(QMoveEvent *event) auto oldPosition = m_widget->data->crect.topLeft(); auto newPosition = geometry().topLeft(); - if (!m_widget->isTopLevel()) { + if (!m_widget->isWindow()) { if (auto *nativeParent = m_widget->nativeParentWidget()) newPosition = m_widget->parentWidget()->mapFrom(nativeParent, newPosition); } diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 8e7005fafa..a7a3c20e1a 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1091,7 +1091,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio QColor dimHighlight(qMin(highlight.red()/2 + 110, 255), qMin(highlight.green()/2 + 110, 255), qMin(highlight.blue()/2 + 110, 255)); - dimHighlight.setAlpha(widget && widget->isTopLevel() ? 255 : 80); + dimHighlight.setAlpha(widget && widget->isWindow() ? 255 : 80); QLinearGradient gradient(rect.topLeft(), QPoint(rect.bottomLeft().x(), rect.bottomLeft().y())); gradient.setColorAt(0, dimHighlight.lighter(120)); gradient.setColorAt(1, dimHighlight); diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 95ee90eb31..59e2e4e57a 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2593,7 +2593,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) continue; if (!qobject_cast(w) && !qobject_cast(w)) continue; - if (w != widget && w->isTopLevel() && w->isVisible() && !w->isMinimized()) + if (w != widget && w->isWindow() && w->isVisible() && !w->isMinimized()) candidates << w; if (QDockWidgetGroupWindow *group = qobject_cast(w)) { // Sometimes, there are floating QDockWidget that have a QDockWidgetGroupWindow as a parent. -- cgit v1.2.3