| | |
| | | // Copyright (C) 2023-2024 Stdware Collections |
| | | // SPDX-License-Identifier: Apache-2.0 |
| | | |
| | | #include "quickwindowagent.h" |
| | | #include "quickwindowagent_p.h" |
| | | |
| | | #include "quickitemdelegate_p.h" |
| | | |
| | | #include <QtQuick/QQuickWindow> |
| | | #include <QtQuick/private/qquickanchors_p.h> |
| | | |
| | | #include "quickitemdelegate_p.h" |
| | | |
| | | namespace QWK { |
| | | |
| | | QuickWindowAgentPrivate::QuickWindowAgentPrivate() { |
| | | } |
| | | /*! |
| | | \class QuickWindowAgent |
| | | \brief QuickWindowAgent is the window agent for QtQuick. |
| | | |
| | | QuickWindowAgentPrivate::~QuickWindowAgentPrivate() { |
| | | } |
| | | 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. |
| | | */ |
| | | |
| | | QuickWindowAgentPrivate::QuickWindowAgentPrivate() = default; |
| | | |
| | | QuickWindowAgentPrivate::~QuickWindowAgentPrivate() = default; |
| | | |
| | | void QuickWindowAgentPrivate::init() { |
| | | } |
| | |
| | | : QuickWindowAgent(*new QuickWindowAgentPrivate(), parent) { |
| | | } |
| | | |
| | | QuickWindowAgent::~QuickWindowAgent() { |
| | | } |
| | | QuickWindowAgent::~QuickWindowAgent() = default; |
| | | |
| | | bool QuickWindowAgent::setup(QQuickWindow *window) { |
| | | Q_ASSERT(window); |
| | |
| | | } |
| | | |
| | | Q_D(QuickWindowAgent); |
| | | if (d->host) { |
| | | if (d->hostWindow) { |
| | | return false; |
| | | } |
| | | |
| | | if (!d->setup(window, std::make_shared<QuickItemDelegate>())) { |
| | | return true; |
| | | } |
| | | d->host = window; |
| | | d->setup(window, new QuickItemDelegate()); |
| | | d->hostWindow = window; |
| | | |
| | | #if defined(Q_OS_WINDOWS) && QWINDOWKIT_CONFIG(ENABLE_WINDOWS_SYSTEM_BORDERS) |
| | | d->setupWindows10BorderWorkaround(); |
| | | #endif |
| | | return true; |
| | | } |
| | | |
| | | bool QuickWindowAgent::isHitTestVisible(QQuickItem *item) const { |
| | | QQuickItem *QuickWindowAgent::titleBar() const { |
| | | Q_D(const QuickWindowAgent); |
| | | return d->eventHandler->isHitTestVisible(item); |
| | | return static_cast<QQuickItem *>(d->context->titleBar()); |
| | | } |
| | | |
| | | void QuickWindowAgent::setHitTestVisible(QQuickItem *item, bool visible) { |
| | | void QuickWindowAgent::setTitleBar(QQuickItem *item) { |
| | | Q_D(QuickWindowAgent); |
| | | d->eventHandler->setHitTestVisible(item, visible); |
| | | } |
| | | |
| | | void QuickWindowAgent::setHitTestVisible(const QRect &rect, bool visible) { |
| | | Q_D(QuickWindowAgent); |
| | | d->eventHandler->setHitTestVisible(rect, visible); |
| | | if (!d->context->setTitleBar(item)) { |
| | | return; |
| | | } |
| | | #ifdef Q_OS_MAC |
| | | setSystemButtonArea(nullptr); |
| | | #endif |
| | | Q_EMIT titleBarWidgetChanged(item); |
| | | } |
| | | |
| | | QQuickItem *QuickWindowAgent::systemButton(SystemButton button) const { |
| | | Q_D(const QuickWindowAgent); |
| | | return qobject_cast<QQuickItem *>(d->eventHandler->systemButton(button)); |
| | | return static_cast<QQuickItem *>(d->context->systemButton(button)); |
| | | } |
| | | |
| | | void QuickWindowAgent::setSystemButton(SystemButton button, QQuickItem *item) { |
| | | Q_D(QuickWindowAgent); |
| | | if (!d->eventHandler->setSystemButton(button, item)) { |
| | | if (!d->context->setSystemButton(button, item)) { |
| | | return; |
| | | } |
| | | Q_EMIT systemButtonChanged(button, item); |
| | | } |
| | | |
| | | QQuickItem *QuickWindowAgent::titleBar() const { |
| | | bool QuickWindowAgent::isHitTestVisible(const QQuickItem *item) const { |
| | | Q_D(const QuickWindowAgent); |
| | | return qobject_cast<QQuickItem *>(d->eventHandler->titleBar()); |
| | | return d->context->isHitTestVisible(item); |
| | | } |
| | | |
| | | void QuickWindowAgent::setTitleBar(QQuickItem *item) { |
| | | void QuickWindowAgent::setHitTestVisible(const QQuickItem *item, bool visible) { |
| | | Q_D(QuickWindowAgent); |
| | | if (!d->eventHandler->setTitleBar(item)) { |
| | | return; |
| | | } |
| | | Q_EMIT titleBarWidgetChanged(item); |
| | | d->context->setHitTestVisible(item, visible); |
| | | } |
| | | |
| | | /*! |
| | | \internal |
| | | */ |
| | | QuickWindowAgent::QuickWindowAgent(QuickWindowAgentPrivate &d, QObject *parent) |
| | | : CoreWindowAgent(d, parent) { |
| | | : WindowAgentBase(d, parent) { |
| | | d.init(); |
| | | } |
| | | } |
| | | |
| | | } |