mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:17:35 +02:00
Ensure that geometryChanged is emitted after docked widget is resized
This commit is contained in:
parent
b40d5658e3
commit
083470e4fe
4 changed files with 22 additions and 1 deletions
|
@ -109,6 +109,10 @@ void InteractiveWindow::forwardKeyReleaseEvent(int key, int modifiers) {
|
||||||
QCoreApplication::postEvent(QCoreApplication::instance(), event);
|
QCoreApplication::postEvent(QCoreApplication::instance(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InteractiveWindow::emitMainWindowResizeEvent() {
|
||||||
|
emit qApp->getWindow()->windowGeometryChanged(qApp->getWindow()->geometry());
|
||||||
|
}
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* A set of properties used when creating an <code>InteractiveWindow</code>.
|
* A set of properties used when creating an <code>InteractiveWindow</code>.
|
||||||
* @typedef {object} InteractiveWindow.Properties
|
* @typedef {object} InteractiveWindow.Properties
|
||||||
|
@ -215,10 +219,11 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
QObject::connect(rootItem, SIGNAL(keyReleaseEvent(int, int)), this, SLOT(forwardKeyReleaseEvent(int, int)),
|
QObject::connect(rootItem, SIGNAL(keyReleaseEvent(int, int)), this, SLOT(forwardKeyReleaseEvent(int, int)),
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
emit mainWindow->windowGeometryChanged(qApp->getWindow()->geometry());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QObject::connect(_dockWidget.get(), SIGNAL(onResizeEvent()), this, SLOT(emitMainWindowResizeEvent()));
|
||||||
|
|
||||||
_dockWidget->setSource(QUrl(sourceUrl));
|
_dockWidget->setSource(QUrl(sourceUrl));
|
||||||
mainWindow->addDockWidget(dockArea, _dockWidget.get());
|
mainWindow->addDockWidget(dockArea, _dockWidget.get());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -319,6 +319,7 @@ protected slots:
|
||||||
|
|
||||||
void forwardKeyPressEvent(int key, int modifiers);
|
void forwardKeyPressEvent(int key, int modifiers);
|
||||||
void forwardKeyReleaseEvent(int key, int modifiers);
|
void forwardKeyReleaseEvent(int key, int modifiers);
|
||||||
|
void emitMainWindowResizeEvent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QmlWindowProxy> _qmlWindowProxy;
|
std::shared_ptr<QmlWindowProxy> _qmlWindowProxy;
|
||||||
|
|
|
@ -47,3 +47,10 @@ QQuickItem* DockWidget::getRootItem() const {
|
||||||
std::shared_ptr<QQuickView> DockWidget::getQuickView() const {
|
std::shared_ptr<QQuickView> DockWidget::getQuickView() const {
|
||||||
return _quickView;
|
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();
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
class QQuickView;
|
class QQuickView;
|
||||||
class QQuickItem;
|
class QQuickItem;
|
||||||
class DockWidget : public QDockWidget {
|
class DockWidget : public QDockWidget {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DockWidget(const QString& title, QWidget* parent = nullptr);
|
DockWidget(const QString& title, QWidget* parent = nullptr);
|
||||||
~DockWidget() = default;
|
~DockWidget() = default;
|
||||||
|
@ -26,6 +27,13 @@ public:
|
||||||
void setSource(const QUrl& url);
|
void setSource(const QUrl& url);
|
||||||
QQuickItem* getRootItem() const;
|
QQuickItem* getRootItem() const;
|
||||||
std::shared_ptr<QQuickView> getQuickView() const;
|
std::shared_ptr<QQuickView> getQuickView() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void onResizeEvent();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QQuickView> _quickView;
|
std::shared_ptr<QQuickView> _quickView;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue