mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-04 00:41:17 +02:00
only show InteractiveWindow on top of interface window
This commit is contained in:
parent
acc7d493ec
commit
e08d8e9046
5 changed files with 51 additions and 14 deletions
|
@ -13,12 +13,19 @@
|
||||||
|
|
||||||
#include <QtQml/QQmlContext>
|
#include <QtQml/QQmlContext>
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
|
#include <QtGui/QGuiApplication>
|
||||||
|
#include <QtQuick/QQuickWindow>
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <RegisteredMetaTypes.h>
|
#include <RegisteredMetaTypes.h>
|
||||||
|
|
||||||
#include "OffscreenUi.h"
|
#include "OffscreenUi.h"
|
||||||
#include "shared/QtHelpers.h"
|
#include "shared/QtHelpers.h"
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <WinUser.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static auto CONTENT_WINDOW_QML = QUrl("InteractiveWindow.qml");
|
static auto CONTENT_WINDOW_QML = QUrl("InteractiveWindow.qml");
|
||||||
|
|
||||||
|
@ -87,6 +94,11 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
connect(object, SIGNAL(windowClosed()), this, SIGNAL(closed()), Qt::QueuedConnection);
|
connect(object, SIGNAL(windowClosed()), this, SIGNAL(closed()), Qt::QueuedConnection);
|
||||||
connect(object, SIGNAL(selfDestruct()), this, SLOT(close()), Qt::QueuedConnection);
|
connect(object, SIGNAL(selfDestruct()), this, SLOT(close()), Qt::QueuedConnection);
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
connect(object, SIGNAL(nativeWindowChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
||||||
|
connect(object, SIGNAL(interactiveWindowVisibleChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
||||||
|
#endif
|
||||||
|
|
||||||
QUrl sourceURL{ sourceUrl };
|
QUrl sourceURL{ sourceUrl };
|
||||||
// If the passed URL doesn't correspond to a known scheme, assume it's a local file path
|
// If the passed URL doesn't correspond to a known scheme, assume it's a local file path
|
||||||
if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) {
|
if (!KNOWN_SCHEMES.contains(sourceURL.scheme(), Qt::CaseInsensitive)) {
|
||||||
|
@ -279,6 +291,24 @@ int InteractiveWindow::getPresentationMode() const {
|
||||||
return _qmlWindow->property(PRESENTATION_MODE_PROPERTY).toInt();
|
return _qmlWindow->property(PRESENTATION_MODE_PROPERTY).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
void InteractiveWindow::parentNativeWindowToMainWindow() {
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "parentNativeWindowToMainWindow");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_qmlWindow.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto nativeWindowProperty = _qmlWindow->property("nativeWindow");
|
||||||
|
if (nativeWindowProperty.isNull() || !nativeWindowProperty.isValid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto nativeWindow = qvariant_cast<QQuickWindow*>(nativeWindowProperty);
|
||||||
|
SetWindowLongPtr((HWND)nativeWindow->winId(), GWLP_HWNDPARENT, (LONG)MainWindow::findMainWindow()->winId());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void InteractiveWindow::setPresentationMode(int presentationMode) {
|
void InteractiveWindow::setPresentationMode(int presentationMode) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "setPresentationMode", Q_ARG(int, presentationMode));
|
QMetaObject::invokeMethod(this, "setPresentationMode", Q_ARG(int, presentationMode));
|
||||||
|
|
|
@ -84,6 +84,10 @@ private:
|
||||||
Q_INVOKABLE void setPresentationMode(int presentationMode);
|
Q_INVOKABLE void setPresentationMode(int presentationMode);
|
||||||
Q_INVOKABLE int getPresentationMode() const;
|
Q_INVOKABLE int getPresentationMode() const;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
Q_INVOKABLE void parentNativeWindowToMainWindow();
|
||||||
|
#endif
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QWindow>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "ui/Logging.h"
|
#include "ui/Logging.h"
|
||||||
|
@ -39,6 +40,18 @@ MainWindow::~MainWindow() {
|
||||||
qCDebug(uiLogging) << "Destroying main window";
|
qCDebug(uiLogging) << "Destroying main window";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWindow* MainWindow::findMainWindow() {
|
||||||
|
auto windows = qApp->topLevelWindows();
|
||||||
|
QWindow* result = nullptr;
|
||||||
|
for (auto window : windows) {
|
||||||
|
if (window->objectName().contains("MainWindow")) {
|
||||||
|
result = window;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::restoreGeometry() {
|
void MainWindow::restoreGeometry() {
|
||||||
// Did not use setGeometry() on purpose,
|
// Did not use setGeometry() on purpose,
|
||||||
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
// see http://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application
|
||||||
|
|
|
@ -21,6 +21,8 @@ class MainWindow : public QMainWindow {
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget* parent = NULL);
|
explicit MainWindow(QWidget* parent = NULL);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
static QWindow* findMainWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void restoreGeometry();
|
void restoreGeometry();
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "ui/Logging.h"
|
#include "ui/Logging.h"
|
||||||
|
|
||||||
#include <PointerManager.h>
|
#include <PointerManager.h>
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @namespace OffscreenFlags
|
* @namespace OffscreenFlags
|
||||||
|
@ -649,20 +650,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QWindow* const _mainWindow { MainWindow::findMainWindow() };
|
||||||
static QWindow* findMainWindow() {
|
|
||||||
auto windows = qApp->topLevelWindows();
|
|
||||||
QWindow* result = nullptr;
|
|
||||||
for (auto window : windows) {
|
|
||||||
if (window->objectName().contains("MainWindow")) {
|
|
||||||
result = window;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QWindow* const _mainWindow { findMainWindow() };
|
|
||||||
QWindow* _hackWindow { nullptr };
|
QWindow* _hackWindow { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue