mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-10 17:23:15 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into black-bis
This commit is contained in:
commit
129e2ce188
6 changed files with 54 additions and 15 deletions
|
@ -146,7 +146,8 @@ Windows.Window {
|
|||
Qt.WindowCloseButtonHint |
|
||||
Qt.WindowMaximizeButtonHint |
|
||||
Qt.WindowMinimizeButtonHint;
|
||||
if ((flags & Desktop.ALWAYS_ON_TOP) === Desktop.ALWAYS_ON_TOP) {
|
||||
// only use the always on top feature for non Windows OS
|
||||
if (Qt.platform.os !== "windows" && (flags & Desktop.ALWAYS_ON_TOP)) {
|
||||
nativeWindowFlags |= Qt.WindowStaysOnTopHint;
|
||||
}
|
||||
nativeWindow.flags = nativeWindowFlags;
|
||||
|
|
|
@ -13,12 +13,19 @@
|
|||
|
||||
#include <QtQml/QQmlContext>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtQuick/QQuickWindow>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <RegisteredMetaTypes.h>
|
||||
|
||||
#include "OffscreenUi.h"
|
||||
#include "shared/QtHelpers.h"
|
||||
#include "MainWindow.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <WinUser.h>
|
||||
#endif
|
||||
|
||||
static auto CONTENT_WINDOW_QML = QUrl("InteractiveWindow.qml");
|
||||
|
||||
|
@ -87,6 +94,12 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
|||
connect(object, SIGNAL(windowClosed()), this, SIGNAL(closed()), 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);
|
||||
connect(object, SIGNAL(presentationModeChanged()), this, SLOT(parentNativeWindowToMainWindow()), Qt::QueuedConnection);
|
||||
#endif
|
||||
|
||||
QUrl sourceURL{ sourceUrl };
|
||||
// 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)) {
|
||||
|
@ -279,6 +292,24 @@ int InteractiveWindow::getPresentationMode() const {
|
|||
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) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "setPresentationMode", Q_ARG(int, presentationMode));
|
||||
|
|
|
@ -84,6 +84,10 @@ private:
|
|||
Q_INVOKABLE void setPresentationMode(int presentationMode);
|
||||
Q_INVOKABLE int getPresentationMode() const;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
Q_INVOKABLE void parentNativeWindowToMainWindow();
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
|
||||
/**jsdoc
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
#include <QWindow>
|
||||
#include <QDebug>
|
||||
|
||||
#include "ui/Logging.h"
|
||||
|
@ -39,6 +40,18 @@ MainWindow::~MainWindow() {
|
|||
qCDebug(uiLogging) << "Destroying main window";
|
||||
}
|
||||
|
||||
QWindow* MainWindow::findMainWindow() {
|
||||
auto windows = qApp->topLevelWindows();
|
||||
QWindow* result = nullptr;
|
||||
for (const auto& window : windows) {
|
||||
if (window->objectName().contains("MainWindow")) {
|
||||
result = window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void MainWindow::restoreGeometry() {
|
||||
// Did not use setGeometry() on purpose,
|
||||
// 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:
|
||||
explicit MainWindow(QWidget* parent = NULL);
|
||||
~MainWindow();
|
||||
|
||||
static QWindow* findMainWindow();
|
||||
|
||||
public slots:
|
||||
void restoreGeometry();
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "ui/Logging.h"
|
||||
|
||||
#include <PointerManager.h>
|
||||
#include "MainWindow.h"
|
||||
|
||||
/**jsdoc
|
||||
* @namespace OffscreenFlags
|
||||
|
@ -649,20 +650,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
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* const _mainWindow { MainWindow::findMainWindow() };
|
||||
QWindow* _hackWindow { nullptr };
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue