From 9dcea027f16c4ce5852da3dfc8aca284c582bd7d Mon Sep 17 00:00:00 2001 From: sola.lu <sola.lu.greentest.com.cn> Date: 周五, 06 6月 2025 18:19:18 +0800 Subject: [PATCH] 1.注释掉custom margin,解决程序放大后,遮盖窗口底部内容的问题。 --- src/quick/quickwindowagent.cpp | 110 +++++++++++++----------------------------------------- 1 files changed, 27 insertions(+), 83 deletions(-) diff --git a/src/quick/quickwindowagent.cpp b/src/quick/quickwindowagent.cpp index 747daf0..5225a09 100644 --- a/src/quick/quickwindowagent.cpp +++ b/src/quick/quickwindowagent.cpp @@ -1,76 +1,28 @@ +// Copyright (C) 2023-2024 Stdware Collections (https://www.github.com/stdware) +// Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao) +// SPDX-License-Identifier: Apache-2.0 + #include "quickwindowagent.h" #include "quickwindowagent_p.h" #include <QtQuick/QQuickWindow> -#include <QtQuick/QQuickPaintedItem> -#include <QtQuick/private/qquickitem_p.h> #include <QtQuick/private/qquickanchors_p.h> - -#ifdef Q_OS_WINDOWS -# include <QWKCore/private/win10borderhandler_p.h> -#endif #include "quickitemdelegate_p.h" namespace QWK { - class BorderItem : public QQuickPaintedItem, public Win10BorderHandler { - Q_OBJECT - public: - explicit BorderItem(QQuickItem *parent = nullptr); - ~BorderItem() override; + /*! + \class QuickWindowAgent + \brief QuickWindowAgent is the window agent for QtQuick. - void updateGeometry() override; - void requestUpdate() override; + It provides interfaces for QtQuick and processes some Qt events related to the QQuickItem + instance. The usage of all APIs is consistent with the \a Widgets module. + */ - bool isActive() const override; + QuickWindowAgentPrivate::QuickWindowAgentPrivate() = default; - public: - void paint(QPainter *painter) override; - }; - - BorderItem::BorderItem(QQuickItem *parent) - : Win10BorderHandler(parent->window()), QQuickPaintedItem(parent) { - setAntialiasing(true); // ### FIXME: do we need to enable or disable this? - setMipmap(true); // ### FIXME: do we need to enable or disable this? - setFillColor({}); // Will improve the performance a little bit. - setOpaquePainting(true); // Will also improve the performance, we don't draw - // semi-transparent borders of course. - - auto parentPri = QQuickItemPrivate::get(parent); - auto anchors = QQuickItemPrivate::get(this)->anchors(); - anchors->setTop(parentPri->top()); - anchors->setLeft(parentPri->left()); - anchors->setRight(parentPri->right()); - - setZ(10); - } - - BorderItem::~BorderItem() = default; - - void BorderItem::updateGeometry() { - setHeight(m_borderThickness); - } - - void BorderItem::requestUpdate() { - update(); - } - - bool BorderItem::isActive() const { - return static_cast<QQuickWindow *>(m_window)->isActive(); - } - - void BorderItem::paint(QPainter *painter) { - QRect rect(QPoint(0, 0), size().toSize()); - QRegion region(rect); - Win10BorderHandler::paintBorder(*painter, rect, region); - } - - QuickWindowAgentPrivate::QuickWindowAgentPrivate() { - } - - QuickWindowAgentPrivate::~QuickWindowAgentPrivate() { - } + QuickWindowAgentPrivate::~QuickWindowAgentPrivate() = default; void QuickWindowAgentPrivate::init() { } @@ -79,8 +31,7 @@ : QuickWindowAgent(*new QuickWindowAgentPrivate(), parent) { } - QuickWindowAgent::~QuickWindowAgent() { - } + QuickWindowAgent::~QuickWindowAgent() = default; bool QuickWindowAgent::setup(QQuickWindow *window) { Q_ASSERT(window); @@ -93,21 +44,11 @@ return false; } - if (!d->setup(window, new QuickItemDelegate())) { - return false; - } + d->setup(window, new QuickItemDelegate()); d->hostWindow = window; -#ifdef Q_OS_WINDOWS - // Install painting hook - if (bool needPaintBorder; - QMetaObject::invokeMethod(d->context.get(), "needWin10BorderHandler", - Qt::DirectConnection, Q_RETURN_ARG(bool, needPaintBorder)), - needPaintBorder) { - QMetaObject::invokeMethod( - d->context.get(), "setWin10BorderHandler", Qt::DirectConnection, - Q_ARG(Win10BorderHandler *, new BorderItem(window->contentItem()))); - } +#if defined(Q_OS_WINDOWS) && QWINDOWKIT_CONFIG(ENABLE_WINDOWS_SYSTEM_BORDERS) + d->setupWindows10BorderWorkaround(); #endif return true; } @@ -122,6 +63,9 @@ if (!d->context->setTitleBar(item)) { return; } +#ifdef Q_OS_MAC + setSystemButtonArea(nullptr); +#endif Q_EMIT titleBarWidgetChanged(item); } @@ -138,26 +82,26 @@ Q_EMIT systemButtonChanged(button, item); } +#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) + bool QuickWindowAgent::isHitTestVisible(QQuickItem *item) const { +#else bool QuickWindowAgent::isHitTestVisible(const QQuickItem *item) const { +#endif Q_D(const QuickWindowAgent); return d->context->isHitTestVisible(item); } - void QuickWindowAgent::setHitTestVisible_item(const QQuickItem *item, bool visible) { + void QuickWindowAgent::setHitTestVisible(QQuickItem *item, bool visible) { Q_D(QuickWindowAgent); d->context->setHitTestVisible(item, visible); } - void QuickWindowAgent::setHitTestVisible_rect(const QRect &rect, bool visible) { - Q_D(QuickWindowAgent); - d->context->setHitTestVisible(rect, visible); - } - + /*! + \internal + */ QuickWindowAgent::QuickWindowAgent(QuickWindowAgentPrivate &d, QObject *parent) : WindowAgentBase(d, parent) { d.init(); } } - -#include "quickwindowagent.moc" \ No newline at end of file -- Gitblit v1.9.1