From 6ad4fffc17895815f9cfd86589f7935e8d6b4880 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Sun, 18 Feb 2024 19:02:10 -0800 Subject: [PATCH] feat: expose ProxyWindowBase contentItem --- src/cpp/proxywindow.cpp | 21 +++++++++++---------- src/cpp/proxywindow.hpp | 4 +++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/cpp/proxywindow.cpp b/src/cpp/proxywindow.cpp index 02b05fe3..53ddbe8d 100644 --- a/src/cpp/proxywindow.cpp +++ b/src/cpp/proxywindow.cpp @@ -13,8 +13,8 @@ #include "reload.hpp" ProxyWindowBase::ProxyWindowBase(QObject* parent): Reloadable(parent) { - this->contentItem = new QQuickItem(); // NOLINT - this->contentItem->setParent(this); + this->mContentItem = new QQuickItem(); // NOLINT + this->mContentItem->setParent(this); QObject::connect(this, &ProxyWindowBase::widthChanged, this, &ProxyWindowBase::onWidthChanged); QObject::connect(this, &ProxyWindowBase::heightChanged, this, &ProxyWindowBase::onHeightChanged); @@ -37,12 +37,12 @@ void ProxyWindowBase::onReload(QObject* oldInstance) { this->setupWindow(); - Reloadable::reloadRecursive(this->contentItem, oldInstance); + Reloadable::reloadRecursive(this->mContentItem, oldInstance); - this->contentItem->setParentItem(this->window->contentItem()); + this->mContentItem->setParentItem(this->window->contentItem()); - this->contentItem->setWidth(this->width()); - this->contentItem->setHeight(this->height()); + this->mContentItem->setWidth(this->width()); + this->mContentItem->setHeight(this->height()); emit this->windowConnected(); this->window->setVisible(this->mVisible); @@ -69,7 +69,7 @@ void ProxyWindowBase::setupWindow() { QQuickWindow* ProxyWindowBase::disownWindow() { QObject::disconnect(this->window, nullptr, this, nullptr); - this->contentItem->setParentItem(nullptr); + this->mContentItem->setParentItem(nullptr); auto* window = this->window; this->window = nullptr; @@ -77,6 +77,7 @@ QQuickWindow* ProxyWindowBase::disownWindow() { } QQuickWindow* ProxyWindowBase::backingWindow() const { return this->window; } +QQuickItem* ProxyWindowBase::contentItem() const { return this->mContentItem; } bool ProxyWindowBase::isVisible() const { if (this->window == nullptr) return this->mVisible; @@ -161,12 +162,12 @@ void ProxyWindowBase::updateMask() { } QQmlListProperty ProxyWindowBase::data() { - return this->contentItem->property("data").value>(); + return this->mContentItem->property("data").value>(); } -void ProxyWindowBase::onWidthChanged() { this->contentItem->setWidth(this->width()); } +void ProxyWindowBase::onWidthChanged() { this->mContentItem->setWidth(this->width()); } -void ProxyWindowBase::onHeightChanged() { this->contentItem->setHeight(this->height()); } +void ProxyWindowBase::onHeightChanged() { this->mContentItem->setHeight(this->height()); } void ProxyFloatingWindow::setWidth(qint32 width) { if (this->window == nullptr || !this->window->isVisible()) this->ProxyWindowBase::setWidth(width); diff --git a/src/cpp/proxywindow.hpp b/src/cpp/proxywindow.hpp index 682e2470..c2e08d9a 100644 --- a/src/cpp/proxywindow.hpp +++ b/src/cpp/proxywindow.hpp @@ -33,6 +33,7 @@ class ProxyWindowBase: public Reloadable { /// > /// > Use **only** if you know what you are doing. Q_PROPERTY(QQuickWindow* _backingWindow READ backingWindow); + Q_PROPERTY(QQuickItem* contentItem READ contentItem); /// If the window is shown or hidden. Defaults to true. Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged); Q_PROPERTY(qint32 width READ width WRITE setWidth NOTIFY widthChanged); @@ -117,6 +118,7 @@ public: virtual QQuickWindow* disownWindow(); [[nodiscard]] QQuickWindow* backingWindow() const; + [[nodiscard]] QQuickItem* contentItem() const; [[nodiscard]] virtual bool isVisible() const; virtual void setVisible(bool visible); @@ -155,7 +157,7 @@ protected: QColor mColor = Qt::white; PendingRegion* mMask = nullptr; QQuickWindow* window = nullptr; - QQuickItem* contentItem = nullptr; + QQuickItem* mContentItem = nullptr; private: void updateMask();