diff --git a/interface/src/ui/InteractiveWindow.cpp b/interface/src/ui/InteractiveWindow.cpp index a313c7873e..e1f89ef558 100644 --- a/interface/src/ui/InteractiveWindow.cpp +++ b/interface/src/ui/InteractiveWindow.cpp @@ -109,6 +109,10 @@ void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) { QCoreApplication::postEvent(QCoreApplication::instance(), event); } +void InteractiveWindow::emitMainWindowResizeEvent() { + emit qApp->getWindow()->windowGeometryChanged(qApp->getWindow()->geometry()); +} + /**jsdoc * A set of properties used when creating an InteractiveWindow. * @typedef {object} InteractiveWindow.Properties @@ -215,10 +219,11 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap Qt::QueuedConnection); QObject::connect(rootItem, SIGNAL(keyReleaseEvent(int, int)), this, SLOT(forwardKeyReleaseEvent(int, int)), Qt::QueuedConnection); - emit mainWindow->windowGeometryChanged(qApp->getWindow()->geometry()); } }); + QObject::connect(_dockWidget.get(), SIGNAL(onResizeEvent()), this, SLOT(emitMainWindowResizeEvent())); + _dockWidget->setSource(QUrl(sourceUrl)); mainWindow->addDockWidget(dockArea, _dockWidget.get()); } else { diff --git a/interface/src/ui/InteractiveWindow.h b/interface/src/ui/InteractiveWindow.h index 67f0a9ea2e..cc7536af85 100644 --- a/interface/src/ui/InteractiveWindow.h +++ b/interface/src/ui/InteractiveWindow.h @@ -319,6 +319,7 @@ protected slots: void forwardKeyPressEvent(int key, int modifiers); void forwardKeyReleaseEvent(int key, int modifiers); + void emitMainWindowResizeEvent(); private: std::shared_ptr _qmlWindowProxy; diff --git a/libraries/ui/src/DockWidget.cpp b/libraries/ui/src/DockWidget.cpp index 44bac1f670..13c4d9a548 100644 --- a/libraries/ui/src/DockWidget.cpp +++ b/libraries/ui/src/DockWidget.cpp @@ -47,3 +47,10 @@ QQuickItem* DockWidget::getRootItem() const { std::shared_ptr DockWidget::getQuickView() const { return _quickView; } + +void DockWidget::resizeEvent(QResizeEvent* event) { + // This signal is currently handled in `InteractiveWindow.cpp`. There, it's used to + // emit a `windowGeometryChanged()` signal, which is handled by scripts + // that need to know when to change the position of their overlay UI elements. + emit onResizeEvent(); +} \ No newline at end of file diff --git a/libraries/ui/src/DockWidget.h b/libraries/ui/src/DockWidget.h index e9669264e7..4ee9b56550 100644 --- a/libraries/ui/src/DockWidget.h +++ b/libraries/ui/src/DockWidget.h @@ -19,6 +19,7 @@ class QQuickView; class QQuickItem; class DockWidget : public QDockWidget { +Q_OBJECT public: DockWidget(const QString& title, QWidget* parent = nullptr); ~DockWidget() = default; @@ -26,6 +27,13 @@ public: void setSource(const QUrl& url); QQuickItem* getRootItem() const; std::shared_ptr getQuickView() const; + +signals: + void onResizeEvent(); + +protected: + void resizeEvent(QResizeEvent* event) override; + private: std::shared_ptr _quickView; };