From 9e96ea43436d5ed200c57d6b229cddf9bdf9e55a Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <zhaoyuhang@rankyee.com> Date: 周一, 10 2月 2025 18:06:41 +0800 Subject: [PATCH] make demo a GUI application in CMake --- src/quick/quickwindowagent_mac.cpp | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/quick/quickwindowagent_mac.cpp b/src/quick/quickwindowagent_mac.cpp index 0e19772..c7a822e 100644 --- a/src/quick/quickwindowagent_mac.cpp +++ b/src/quick/quickwindowagent_mac.cpp @@ -1,3 +1,7 @@ +// 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_p.h" namespace QWK { @@ -27,11 +31,14 @@ &SystemButtonAreaItemHandler::updateSystemButtonArea); connect(item, &QQuickItem::heightChanged, this, &SystemButtonAreaItemHandler::updateSystemButtonArea); - updateSystemButtonArea(); + + ctx->setSystemButtonAreaCallback([item](const QSize &) { + return QRectF(item->mapToScene(QPointF(0, 0)), item->size()).toRect(); // + }); } void SystemButtonAreaItemHandler::updateSystemButtonArea() { - ctx->setSystemButtonArea(QRectF(item->mapToScene(QPointF(0, 0)), item->size()).toRect()); + ctx->virtual_hook(AbstractWindowContext::SystemButtonAreaChangedHook, nullptr); } QQuickItem *QuickWindowAgent::systemButtonArea() const { @@ -48,10 +55,21 @@ d->systemButtonAreaItem = item; if (!item) { d->systemButtonAreaItemHandler.reset(); - ctx->setSystemButtonArea({}); + ctx->setSystemButtonAreaCallback({}); return; } d->systemButtonAreaItemHandler = std::make_unique<SystemButtonAreaItemHandler>(item, ctx); } + ScreenRectCallback QuickWindowAgent::systemButtonAreaCallback() const { + Q_D(const QuickWindowAgent); + return d->systemButtonAreaItem ? nullptr : d->context->systemButtonAreaCallback(); + } + + void QuickWindowAgent::setSystemButtonAreaCallback(const ScreenRectCallback &callback) { + Q_D(QuickWindowAgent); + setSystemButtonArea(nullptr); + d->context->setSystemButtonAreaCallback(callback); + } + } -- Gitblit v1.9.1