diff --git a/libraries/ui/src/QmlWebWindowClass.cpp b/libraries/ui/src/QmlWebWindowClass.cpp index a370d7999b..13fc9cc018 100644 --- a/libraries/ui/src/QmlWebWindowClass.cpp +++ b/libraries/ui/src/QmlWebWindowClass.cpp @@ -37,7 +37,7 @@ QScriptValue QmlWebWindowClass::constructor(QScriptContext* context, QScriptEngi QString QmlWebWindowClass::getURL() { if (QThread::currentThread() != thread()) { - QString result = false; + QString result; hifi::qt::blockingInvokeMethod(this, "getURL", Q_RETURN_ARG(QString, result)); return result; } diff --git a/libraries/ui/src/QmlWindowClass.cpp b/libraries/ui/src/QmlWindowClass.cpp index e773ea0c5d..8d93af15f5 100644 --- a/libraries/ui/src/QmlWindowClass.cpp +++ b/libraries/ui/src/QmlWindowClass.cpp @@ -93,9 +93,10 @@ QmlWindowClass::QmlWindowClass() { void QmlWindowClass::initQml(QVariantMap properties) { auto offscreenUi = DependencyManager::get(); - _toolWindow = properties.contains(TOOLWINDOW_PROPERTY) && properties[TOOLWINDOW_PROPERTY].toBool(); _source = properties[SOURCE_PROPERTY].toString(); +#if QML_TOOL_WINDOW + _toolWindow = properties.contains(TOOLWINDOW_PROPERTY) && properties[TOOLWINDOW_PROPERTY].toBool(); if (_toolWindow) { // Build the event bridge and wrapper on the main thread _qmlWindow = offscreenUi->getToolWindow(); @@ -106,6 +107,7 @@ void QmlWindowClass::initQml(QVariantMap properties) { Q_ARG(QVariant, QVariant::fromValue(properties))); Q_ASSERT(invokeResult); } else { +#endif // Build the event bridge and wrapper on the main thread offscreenUi->loadInNewContext(qmlSource(), [&](QQmlContext* context, QObject* object) { _qmlWindow = object; @@ -136,7 +138,9 @@ void QmlWindowClass::initQml(QVariantMap properties) { connect(_qmlWindow, SIGNAL(moved(QVector2D)), this, SLOT(hasMoved(QVector2D)), Qt::QueuedConnection); connect(_qmlWindow, SIGNAL(windowClosed()), this, SLOT(hasClosed()), Qt::QueuedConnection); }); +#if QML_TOOL_WINDOW } +#endif Q_ASSERT(_qmlWindow); Q_ASSERT(dynamic_cast(_qmlWindow.data())); } @@ -210,9 +214,11 @@ QmlWindowClass::~QmlWindowClass() { } QQuickItem* QmlWindowClass::asQuickItem() const { +#if QML_TOOL_WINDOW if (_toolWindow) { return DependencyManager::get()->getToolWindow(); } +#endif return _qmlWindow.isNull() ? nullptr : dynamic_cast(_qmlWindow.data()); } @@ -223,13 +229,15 @@ void QmlWindowClass::setVisible(bool visible) { } QQuickItem* targetWindow = asQuickItem(); +#if QML_TOOL_WINDOW if (_toolWindow) { // For tool window tabs we special case visibility as a function call on the tab parent // The tool window itself has special logic based on whether any tabs are visible QMetaObject::invokeMethod(targetWindow, "showTabForUrl", Qt::QueuedConnection, Q_ARG(QVariant, _source), Q_ARG(QVariant, visible)); - } else { - targetWindow->setProperty(OFFSCREEN_VISIBILITY_PROPERTY, visible); - } + return; + } +#endif + targetWindow->setProperty(OFFSCREEN_VISIBILITY_PROPERTY, visible); } bool QmlWindowClass::isVisible() { @@ -244,10 +252,12 @@ bool QmlWindowClass::isVisible() { return false; } +#if QML_TOOL_WINDOW if (_toolWindow) { return dynamic_cast(_qmlWindow.data())->isEnabled(); } - +#endif + return asQuickItem()->isVisible(); } @@ -332,6 +342,7 @@ void QmlWindowClass::close() { return; } +#if QML_TOOL_WINDOW if (_toolWindow) { auto offscreenUi = DependencyManager::get(); auto toolWindow = offscreenUi->getToolWindow(); @@ -339,7 +350,10 @@ void QmlWindowClass::close() { Q_ARG(QVariant, _source)); Q_ASSERT(invokeResult); return; - } else if (_qmlWindow) { + } +#endif + + if (_qmlWindow) { _qmlWindow->deleteLater(); } _qmlWindow = nullptr; diff --git a/libraries/ui/src/QmlWindowClass.h b/libraries/ui/src/QmlWindowClass.h index d3e1912d45..e01bc8f14b 100644 --- a/libraries/ui/src/QmlWindowClass.h +++ b/libraries/ui/src/QmlWindowClass.h @@ -19,6 +19,8 @@ class QScriptEngine; class QScriptContext; +#define QML_TOOL_WINDOW 0 + // FIXME refactor this class to be a QQuickItem derived type and eliminate the needless wrapping class QmlWindowClass : public QObject { Q_OBJECT @@ -85,9 +87,12 @@ protected: virtual QString qmlSource() const { return "QmlWindow.qml"; } +#if QML_TOOL_WINDOW // FIXME needs to be initialized in the ctor once we have support // for tool window panes in QML bool _toolWindow { false }; +#endif + QPointer _qmlWindow; QString _source;