diff options
Diffstat (limited to 'src/widgets/widgets/qsizegrip.cpp')
-rw-r--r-- | src/widgets/widgets/qsizegrip.cpp | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp index 946839c373..2500983450 100644 --- a/src/widgets/widgets/qsizegrip.cpp +++ b/src/widgets/widgets/qsizegrip.cpp @@ -1,47 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qsizegrip.h" #include "qapplication.h" #include "qevent.h" -#include "qpainter.h" +#include "qstylepainter.h" #include "qwindow.h" #include <qpa/qplatformwindow.h> #include "qstyle.h" @@ -50,8 +14,12 @@ #include "qdebug.h" #include <private/qwidget_p.h> +#include "private/qapplication_p.h" +#include <qpa/qplatformtheme.h> #include <QtWidgets/qabstractscrollarea.h> +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE static QWidget *qt_sizegrip_topLevelWidget(QWidget* w) @@ -107,7 +75,7 @@ public: void _q_showIfNotHidden() { Q_Q(QSizeGrip); - bool showSizeGrip = !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)); + bool showSizeGrip = !isExplicitlyHidden(); updateTopLevelWidget(); if (tlw && showSizeGrip) { Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen; @@ -171,6 +139,10 @@ Qt::Corner QSizeGripPrivate::corner() const On some platforms the size grip automatically hides itself when the window is shown full screen or maximised. + \note On macOS, size grips are no longer part of the human interface + guideline, and won't show unless used in a QMdiSubWindow. Set another + style on size grips that you want to be visible in main windows. + \table 50% \row \li \inlineimage fusion-statusbar-sizegrip.png Screenshot of a Fusion style size grip \li A size grip widget at the bottom-right corner of a main window, shown in the @@ -242,11 +214,11 @@ void QSizeGrip::paintEvent(QPaintEvent *event) { Q_UNUSED(event); Q_D(QSizeGrip); - QPainter painter(this); + QStylePainter painter(this); QStyleOptionSizeGrip opt; opt.initFrom(this); opt.corner = d->m_corner; - style()->drawControl(QStyle::CE_SizeGrip, &opt, &painter, this); + painter.drawControl(QStyle::CE_SizeGrip, opt); } /*! @@ -268,6 +240,18 @@ static Qt::Edges edgesFromCorner(Qt::Corner corner) return Qt::Edges{}; } +static bool usePlatformSizeGrip(const QWidget *tlw) +{ + const QString &platformName = QGuiApplication::platformName(); + if (platformName.contains(u"xcb")) // ### FIXME QTBUG-69716 + return false; + if (tlw->testAttribute(Qt::WA_TranslucentBackground) + && platformName == u"windows") { + return false; // QTBUG-90628, flicker when using translucency + } + return true; +} + void QSizeGrip::mousePressEvent(QMouseEvent * e) { if (e->button() != Qt::LeftButton) { @@ -287,11 +271,11 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) && tlw->windowHandle() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint) && !tlw->testAttribute(Qt::WA_DontShowOnScreen) - && !tlw->hasHeightForWidth()) { + && !tlw->hasHeightForWidth() + && usePlatformSizeGrip(tlw)) { QPlatformWindow *platformWindow = tlw->windowHandle()->handle(); const Qt::Edges edges = edgesFromCorner(d->m_corner); - if (!QGuiApplication::platformName().contains(QStringLiteral("xcb"))) // ### FIXME QTBUG-69716 - d->m_platformSizeGrip = platformWindow && platformWindow->startSystemResize(edges); + d->m_platformSizeGrip = platformWindow->startSystemResize(edges); } if (d->m_platformSizeGrip) @@ -301,8 +285,12 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) QRect availableGeometry; bool hasVerticalSizeConstraint = true; bool hasHorizontalSizeConstraint = true; - if (tlw->isWindow()) - availableGeometry = QWidgetPrivate::availableScreenGeometry(tlw); + if (tlw->isWindow()) { + if (QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::InteractiveResizeAcrossScreens).toBool()) + availableGeometry = tlw->screen()->availableVirtualGeometry(); + else + availableGeometry = QWidgetPrivate::availableScreenGeometry(tlw); + } else { const QWidget *tlwParent = tlw->parentWidget(); // Check if tlw is inside QAbstractScrollArea/QScrollArea. @@ -463,7 +451,7 @@ void QSizeGrip::setVisible(bool visible) bool QSizeGrip::eventFilter(QObject *o, QEvent *e) { Q_D(QSizeGrip); - if ((isHidden() && testAttribute(Qt::WA_WState_ExplicitShowHide)) + if (d->isExplicitlyHidden() || e->type() != QEvent::WindowStateChange || o != d->tlw) { return QWidget::eventFilter(o, e); |