From 8517f5b133f1aceff893a1a01417157136fe0715 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周一, 01 1月 2024 13:33:29 +0800 Subject: [PATCH] Add license and prepare to release --- src/quick/quickwindowagent_mac.cpp | 23 ++++++++++++++++++++--- 1 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/quick/quickwindowagent_mac.cpp b/src/quick/quickwindowagent_mac.cpp index 0e19772..58c5f8b 100644 --- a/src/quick/quickwindowagent_mac.cpp +++ b/src/quick/quickwindowagent_mac.cpp @@ -1,3 +1,6 @@ +// Copyright (C) 2023-2024 Stdware Collections +// SPDX-License-Identifier: Apache-2.0 + #include "quickwindowagent_p.h" namespace QWK { @@ -27,11 +30,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 +54,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