| | |
| | | // Copyright (C) 2023-2024 Stdware Collections |
| | | // SPDX-License-Identifier: Apache-2.0 |
| | | |
| | | #include "quickwindowagent_p.h" |
| | | |
| | | namespace QWK { |
| | |
| | | &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 { |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |