mirror of
https://github.com/JulianGro/overte.git
synced 2025-07-10 09:57:41 +02:00
Merge pull request #971 from HifiExperiments/apitraceFix
Fix crashes when running with QML disabled in VR
This commit is contained in:
commit
8f3ed5d66d
20 changed files with 167 additions and 136 deletions
|
@ -57,15 +57,15 @@ void AboutUtil::openUrl(const QString& url) const {
|
||||||
|
|
||||||
auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system");
|
auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system");
|
||||||
auto hmd = DependencyManager::get<HMDScriptingInterface>();
|
auto hmd = DependencyManager::get<HMDScriptingInterface>();
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
|
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && offscreenUI) {
|
||||||
offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
|
offscreenUI->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
|
||||||
newObject->setProperty("url", url);
|
newObject->setProperty("url", url);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) {
|
if (!hmd->getShouldShowTablet() && !qApp->isHMDMode() && offscreenUI) {
|
||||||
offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
|
offscreenUI->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
|
||||||
newObject->setProperty("url", url);
|
newObject->setProperty("url", url);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,7 +61,6 @@ void Bookmarks::deleteBookmark(const QString& bookmarkName) {
|
||||||
void Bookmarks::addBookmarkToFile(const QString& bookmarkName, const QVariant& bookmark) {
|
void Bookmarks::addBookmarkToFile(const QString& bookmarkName, const QVariant& bookmark) {
|
||||||
Menu* menubar = Menu::getInstance();
|
Menu* menubar = Menu::getInstance();
|
||||||
if (contains(bookmarkName)) {
|
if (contains(bookmarkName)) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
ModalDialogListener* dlg = OffscreenUi::asyncWarning("Duplicate Bookmark",
|
ModalDialogListener* dlg = OffscreenUi::asyncWarning("Duplicate Bookmark",
|
||||||
"The bookmark name you entered already exists in your list.",
|
"The bookmark name you entered already exists in your list.",
|
||||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||||
|
|
|
@ -58,7 +58,9 @@ bool AvatarPackager::open() {
|
||||||
|
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode()) {
|
||||||
static const QUrl url{ "hifi/AvatarPackagerWindow.qml" };
|
static const QUrl url{ "hifi/AvatarPackagerWindow.qml" };
|
||||||
DependencyManager::get<OffscreenUi>()->show(url, "AvatarPackager", packageModelDialogCreated);
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
|
offscreenUI->show(url, "AvatarPackager", packageModelDialogCreated);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,13 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping,
|
||||||
"Use the field below to place your file in a specific folder or to rename it. "
|
"Use the field below to place your file in a specific folder or to rename it. "
|
||||||
"Specifying a new folder name will automatically create that folder for you.";
|
"Specifying a new folder name will automatically create that folder for you.";
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
auto result = offscreenUi->inputDialog(OffscreenUi::ICON_INFORMATION, "Specify Asset Path",
|
if (!offscreenUI) {
|
||||||
|
completedCallback.call({ -1 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto result = offscreenUI->inputDialog(OffscreenUi::ICON_INFORMATION, "Specify Asset Path",
|
||||||
dropEvent ? dropHelpText : helpText, mapping);
|
dropEvent ? dropHelpText : helpText, mapping);
|
||||||
|
|
||||||
if (!result.isValid() || result.toString() == "") {
|
if (!result.isValid() || result.toString() == "") {
|
||||||
|
@ -94,7 +99,7 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping,
|
||||||
// Check for override
|
// Check for override
|
||||||
if (isKnownMapping(mapping)) {
|
if (isKnownMapping(mapping)) {
|
||||||
auto message = mapping + "\n" + "This file already exists. Do you want to overwrite it?";
|
auto message = mapping + "\n" + "This file already exists. Do you want to overwrite it?";
|
||||||
auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "Overwrite File", message,
|
auto button = offscreenUI->messageBox(OffscreenUi::ICON_QUESTION, "Overwrite File", message,
|
||||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||||
if (button == QMessageBox::No) {
|
if (button == QMessageBox::No) {
|
||||||
completedCallback.call({ -1 });
|
completedCallback.call({ -1 });
|
||||||
|
|
|
@ -99,11 +99,16 @@ void DesktopScriptingInterface::setHUDAlpha(float alpha) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopScriptingInterface::show(const QString& path, const QString& title) {
|
void DesktopScriptingInterface::show(const QString& path, const QString& title) {
|
||||||
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
|
if (!offscreenUI) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection, Q_ARG(QString, path), Q_ARG(QString, title));
|
QMetaObject::invokeMethod(this, "show", Qt::QueuedConnection, Q_ARG(QString, path), Q_ARG(QString, title));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DependencyManager::get<OffscreenUi>()->show(path, title);
|
offscreenUI->show(path, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) {
|
InteractiveWindowPointer DesktopScriptingInterface::createWindow(const QString& sourceUrl, const QVariantMap& properties) {
|
||||||
|
|
|
@ -96,8 +96,9 @@ bool HMDScriptingInterface::shouldShowHandControllers() const {
|
||||||
|
|
||||||
void HMDScriptingInterface::activateHMDHandMouse() {
|
void HMDScriptingInterface::activateHMDHandMouse() {
|
||||||
QWriteLocker lock(&_hmdHandMouseLock);
|
QWriteLocker lock(&_hmdHandMouseLock);
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", true);
|
offscreenUI->getDesktop()->setProperty("hmdHandMouseActive", true);
|
||||||
|
}
|
||||||
_hmdHandMouseCount++;
|
_hmdHandMouseCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,8 +106,9 @@ void HMDScriptingInterface::deactivateHMDHandMouse() {
|
||||||
QWriteLocker lock(&_hmdHandMouseLock);
|
QWriteLocker lock(&_hmdHandMouseLock);
|
||||||
_hmdHandMouseCount = std::max(_hmdHandMouseCount - 1, 0);
|
_hmdHandMouseCount = std::max(_hmdHandMouseCount - 1, 0);
|
||||||
if (_hmdHandMouseCount == 0) {
|
if (_hmdHandMouseCount == 0) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
offscreenUi->getDesktop()->setProperty("hmdHandMouseActive", false);
|
offscreenUI->getDesktop()->setProperty("hmdHandMouseActive", false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,8 +200,8 @@ void WindowScriptingInterface::setInterstitialModeEnabled(bool enableInterstitia
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
|
bool WindowScriptingInterface::isPointOnDesktopWindow(QVariant point) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
return offscreenUi->isPointOnDesktopWindow(point);
|
return offscreenUI ? offscreenUI->isPointOnDesktopWindow(point) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Makes sure that the reticle is visible, use this in blocking forms that require a reticle and
|
/// Makes sure that the reticle is visible, use this in blocking forms that require a reticle and
|
||||||
|
@ -553,12 +553,14 @@ int WindowScriptingInterface::openMessageBox(QString title, QString text, int bu
|
||||||
* @typedef {number} Window.MessageBoxButton
|
* @typedef {number} Window.MessageBoxButton
|
||||||
*/
|
*/
|
||||||
int WindowScriptingInterface::createMessageBox(QString title, QString text, int buttons, int defaultButton) {
|
int WindowScriptingInterface::createMessageBox(QString title, QString text, int buttons, int defaultButton) {
|
||||||
auto messageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
|
auto messageBox = offscreenUI->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
|
||||||
static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton));
|
static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton));
|
||||||
connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int)));
|
connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int)));
|
||||||
|
|
||||||
_lastMessageBoxID += 1;
|
_lastMessageBoxID += 1;
|
||||||
_messageBoxes.insert(_lastMessageBoxID, messageBox);
|
_messageBoxes.insert(_lastMessageBoxID, messageBox);
|
||||||
|
}
|
||||||
|
|
||||||
return _lastMessageBoxID;
|
return _lastMessageBoxID;
|
||||||
}
|
}
|
||||||
|
@ -646,13 +648,17 @@ void WindowScriptingInterface::setActiveDisplayPlugin(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::openWebBrowser(const QString& url) {
|
void WindowScriptingInterface::openWebBrowser(const QString& url) {
|
||||||
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
|
if (!offscreenUI) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "openWebBrowser", Q_ARG(const QString&, url));
|
QMetaObject::invokeMethod(this, "openWebBrowser", Q_ARG(const QString&, url));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
offscreenUI->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
|
||||||
offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) {
|
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
newObject->setProperty("url", url);
|
newObject->setProperty("url", url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,10 +100,10 @@ void ApplicationOverlay::renderQmlUi(RenderArgs* renderArgs) {
|
||||||
// threads, we need to use a sync object to deteremine when
|
// threads, we need to use a sync object to deteremine when
|
||||||
// the current UI texture is no longer being read from, and only
|
// the current UI texture is no longer being read from, and only
|
||||||
// then release it back to the UI for re-use
|
// then release it back to the UI for re-use
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
|
|
||||||
OffscreenQmlSurface::TextureAndFence newTextureAndFence;
|
OffscreenQmlSurface::TextureAndFence newTextureAndFence;
|
||||||
bool newTextureAvailable = offscreenUi->fetchTexture(newTextureAndFence);
|
bool newTextureAvailable = offscreenUI ? offscreenUI->fetchTexture(newTextureAndFence) : false;
|
||||||
if (newTextureAvailable) {
|
if (newTextureAvailable) {
|
||||||
_uiTexture->setExternalTexture(newTextureAndFence.first, newTextureAndFence.second);
|
_uiTexture->setExternalTexture(newTextureAndFence.first, newTextureAndFence.second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,10 +362,11 @@ InteractiveWindow::InteractiveWindow(const QString& sourceUrl, const QVariantMap
|
||||||
object->setObjectName("InteractiveWindow");
|
object->setObjectName("InteractiveWindow");
|
||||||
object->setProperty(SOURCE_PROPERTY, sourceURL);
|
object->setProperty(SOURCE_PROPERTY, sourceURL);
|
||||||
};
|
};
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
|
|
||||||
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
// Build the event bridge and wrapper on the main thread
|
// Build the event bridge and wrapper on the main thread
|
||||||
offscreenUi->loadInNewContext(CONTENT_WINDOW_QML, objectInitLambda, contextInitLambda);
|
offscreenUI->loadInNewContext(CONTENT_WINDOW_QML, objectInitLambda, contextInitLambda);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1212,8 +1212,8 @@ float Overlays::width() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
return offscreenUi->getWindow()->size().width();
|
return offscreenUI ? offscreenUI->getWindow()->size().width() : -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Overlays::height() {
|
float Overlays::height() {
|
||||||
|
@ -1224,8 +1224,8 @@ float Overlays::height() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
return offscreenUi->getWindow()->size().height();
|
return offscreenUI ? offscreenUI->getWindow()->size().height() : -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::mousePressOnPointerEvent(const QUuid& id, const PointerEvent& event) {
|
void Overlays::mousePressOnPointerEvent(const QUuid& id, const PointerEvent& event) {
|
||||||
|
|
|
@ -24,13 +24,17 @@ QmlOverlay::QmlOverlay(const QUrl& url, const QmlOverlay* overlay)
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlOverlay::buildQmlElement(const QUrl& url) {
|
void QmlOverlay::buildQmlElement(const QUrl& url) {
|
||||||
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
|
if (!offscreenUI) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "buildQmlElement", Q_ARG(QUrl, url));
|
QMetaObject::invokeMethod(this, "buildQmlElement", Q_ARG(QUrl, url));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
offscreenUI->load(url, [=](QQmlContext* context, QObject* object) {
|
||||||
offscreenUi->load(url, [=](QQmlContext* context, QObject* object) {
|
|
||||||
_qmlElement = dynamic_cast<QQuickItem*>(object);
|
_qmlElement = dynamic_cast<QQuickItem*>(object);
|
||||||
connect(_qmlElement, &QObject::destroyed, this, &QmlOverlay::qmlElementDestroyed);
|
connect(_qmlElement, &QObject::destroyed, this, &QmlOverlay::qmlElementDestroyed);
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,8 +26,8 @@ static void quickViewDeleter(QQuickView* quickView) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DockWidget::DockWidget(const QString& title, QWidget* parent) : QDockWidget(title, parent) {
|
DockWidget::DockWidget(const QString& title, QWidget* parent) : QDockWidget(title, parent) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
auto qmlEngine = offscreenUi->getSurfaceContext()->engine();
|
auto qmlEngine = offscreenUI->getSurfaceContext()->engine();
|
||||||
_quickView = std::shared_ptr<QQuickView>(new QQuickView(qmlEngine, nullptr), quickViewDeleter);
|
_quickView = std::shared_ptr<QQuickView>(new QQuickView(qmlEngine, nullptr), quickViewDeleter);
|
||||||
_quickView->setFormat(getDefaultOpenGLSurfaceFormat());
|
_quickView->setFormat(getDefaultOpenGLSurfaceFormat());
|
||||||
QWidget* widget = QWidget::createWindowContainer(_quickView.get());
|
QWidget* widget = QWidget::createWindowContainer(_quickView.get());
|
||||||
|
@ -35,6 +35,7 @@ DockWidget::DockWidget(const QString& title, QWidget* parent) : QDockWidget(titl
|
||||||
QWidget* headerWidget = new QWidget();
|
QWidget* headerWidget = new QWidget();
|
||||||
setTitleBarWidget(headerWidget);
|
setTitleBarWidget(headerWidget);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DockWidget::setSource(const QUrl& url) {
|
void DockWidget::setSource(const QUrl& url) {
|
||||||
_quickView->setSource(url);
|
_quickView->setSource(url);
|
||||||
|
|
|
@ -65,9 +65,9 @@ void InfoView::show(const QString& path, bool firstOrChangedOnly, QString urlQue
|
||||||
}
|
}
|
||||||
infoVersion.set(version);
|
infoVersion.set(version);
|
||||||
}
|
}
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
QString infoViewName(NAME + "_" + path);
|
QString infoViewName(NAME + "_" + path);
|
||||||
offscreenUi->show(QML, NAME + "_" + path, [=](QQmlContext* context, QObject* newObject){
|
offscreenUI->show(QML, NAME + "_" + path, [=] (QQmlContext* context, QObject* newObject) {
|
||||||
QQuickItem* item = dynamic_cast<QQuickItem*>(newObject);
|
QQuickItem* item = dynamic_cast<QQuickItem*>(newObject);
|
||||||
item->setWidth(1024);
|
item->setWidth(1024);
|
||||||
item->setHeight(720);
|
item->setHeight(720);
|
||||||
|
@ -77,6 +77,7 @@ void InfoView::show(const QString& path, bool firstOrChangedOnly, QString urlQue
|
||||||
newInfoView->setUrl(url);
|
newInfoView->setUrl(url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QUrl InfoView::url() {
|
QUrl InfoView::url() {
|
||||||
return _url;
|
return _url;
|
||||||
|
|
|
@ -53,25 +53,30 @@ private:
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void x::show(std::function<void(QQmlContext*, QObject*)> f) { \
|
void x::show(std::function<void(QQmlContext*, QObject*)> f) { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
auto offscreenUI = DependencyManager::get<OffscreenUi>(); \
|
||||||
if (!registered) { \
|
if (!registered) { \
|
||||||
x::registerType(); \
|
x::registerType(); \
|
||||||
} \
|
} \
|
||||||
offscreenUi->show(QML, NAME, f); \
|
if (offscreenUI) { \
|
||||||
|
offscreenUI->show(QML, NAME, f); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void x::hide() { \
|
void x::hide() { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->hide(NAME); \
|
offscreenUI->hide(NAME); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
|
void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->toggle(QML, NAME, f); \
|
offscreenUI->toggle(QML, NAME, f); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
void x::load(std::function<void(QQmlContext*, QObject*)> f) { \
|
void x::load(std::function<void(QQmlContext*, QObject*)> f) { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->load(QML, f); \
|
offscreenUI->load(QML, f); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HIFI_QML_DEF_LAMBDA(x, f) \
|
#define HIFI_QML_DEF_LAMBDA(x, f) \
|
||||||
|
@ -82,21 +87,25 @@ private:
|
||||||
qmlRegisterType<x>("Hifi", 1, 0, NAME.toLocal8Bit().constData()); \
|
qmlRegisterType<x>("Hifi", 1, 0, NAME.toLocal8Bit().constData()); \
|
||||||
} \
|
} \
|
||||||
void x::show() { \
|
void x::show() { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->show(QML, NAME, f); \
|
offscreenUI->show(QML, NAME, f); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
void x::hide() { \
|
void x::hide() { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->hide(NAME); \
|
offscreenUI->hide(NAME); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void x::toggle() { \
|
void x::toggle() { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->toggle(QML, NAME, f); \
|
offscreenUI->toggle(QML, NAME, f); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
void x::load() { \
|
void x::load() { \
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) { \
|
||||||
offscreenUi->load(QML, f); \
|
offscreenUI->load(QML, f); \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -189,11 +189,13 @@ void OffscreenUi::show(const QUrl& url, const QString& name, std::function<void(
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::hideDesktopWindows() {
|
void OffscreenUi::hideDesktopWindows() {
|
||||||
|
if (_desktop) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
BLOCKING_INVOKE_METHOD(this, "hideDesktopWindows");
|
BLOCKING_INVOKE_METHOD(this, "hideDesktopWindows");
|
||||||
}
|
}
|
||||||
QMetaObject::invokeMethod(_desktop, "hideDesktopWindows");
|
QMetaObject::invokeMethod(_desktop, "hideDesktopWindows");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f) {
|
void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f) {
|
||||||
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
|
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
|
||||||
|
@ -208,12 +210,15 @@ void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<voi
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffscreenUi::isPointOnDesktopWindow(QVariant point) {
|
bool OffscreenUi::isPointOnDesktopWindow(QVariant point) {
|
||||||
|
if (_desktop) {
|
||||||
QVariant result;
|
QVariant result;
|
||||||
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
|
BLOCKING_INVOKE_METHOD(_desktop, "isPointOnWindow",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, point));
|
Q_ARG(QVariant, point));
|
||||||
return result.toBool();
|
return result.toBool();
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void OffscreenUi::hide(const QString& name) {
|
void OffscreenUi::hide(const QString& name) {
|
||||||
auto rootItem = getRootItem();
|
auto rootItem = getRootItem();
|
||||||
|
@ -226,13 +231,15 @@ void OffscreenUi::hide(const QString& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffscreenUi::isVisible(const QString& name) {
|
bool OffscreenUi::isVisible(const QString& name) {
|
||||||
QQuickItem* item = getRootItem()->findChild<QQuickItem*>(name);
|
auto rootItem = getRootItem();
|
||||||
|
if (rootItem) {
|
||||||
|
QQuickItem* item = rootItem->findChild<QQuickItem*>(name);
|
||||||
if (item) {
|
if (item) {
|
||||||
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
return QQmlProperty(item, OFFSCREEN_VISIBILITY_PROPERTY).read().toBool();
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
class MessageBoxListener : public ModalDialogListener {
|
class MessageBoxListener : public ModalDialogListener {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -280,12 +287,11 @@ QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
|
@ -533,21 +539,21 @@ ModalDialogListener* OffscreenUi::customInputDialogAsync(const Icon icon, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::togglePinned() {
|
void OffscreenUi::togglePinned() {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "togglePinned");
|
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "togglePinned");
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to toggle window visibility";
|
qWarning() << "Failed to toggle window visibility";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::setPinned(bool pinned) {
|
void OffscreenUi::setPinned(bool pinned) {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "setPinned", Q_ARG(QVariant, pinned));
|
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "setPinned", Q_ARG(QVariant, pinned));
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to set window visibility";
|
qWarning() << "Failed to set window visibility";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::setConstrainToolbarToCenterX(bool constrained) {
|
void OffscreenUi::setConstrainToolbarToCenterX(bool constrained) {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "setConstrainToolbarToCenterX", Q_ARG(QVariant, constrained));
|
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "setConstrainToolbarToCenterX", Q_ARG(QVariant, constrained));
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to set toolbar constraint";
|
qWarning() << "Failed to set toolbar constraint";
|
||||||
}
|
}
|
||||||
|
@ -575,17 +581,17 @@ QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
|
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
emit tabletScriptingInterface->tabletNotification();
|
emit tabletScriptingInterface->tabletNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!invokeResult) {
|
if (!invokeResult) {
|
||||||
qWarning() << "Failed to create message box";
|
qWarning() << "Failed to create message box";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -603,12 +609,11 @@ QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString&
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
|
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog",
|
||||||
Q_RETURN_ARG(QVariant, result),
|
Q_RETURN_ARG(QVariant, result),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(map)));
|
Q_ARG(QVariant, QVariant::fromValue(map)));
|
||||||
|
@ -718,7 +723,7 @@ QObject* OffscreenUi::getRootMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenUi::unfocusWindows() {
|
void OffscreenUi::unfocusWindows() {
|
||||||
bool invokeResult = QMetaObject::invokeMethod(_desktop, "unfocusWindows");
|
bool invokeResult = _desktop && QMetaObject::invokeMethod(_desktop, "unfocusWindows");
|
||||||
Q_ASSERT(invokeResult);
|
Q_ASSERT(invokeResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,12 +757,11 @@ QString OffscreenUi::fileDialog(const QVariantMap& properties) {
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
@ -782,12 +786,11 @@ ModalDialogListener* OffscreenUi::fileDialogAsync(const QVariantMap& properties)
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
@ -1003,12 +1006,11 @@ QString OffscreenUi::assetDialog(const QVariantMap& properties) {
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
@ -1034,12 +1036,11 @@ ModalDialogListener *OffscreenUi::assetDialogAsync(const QVariantMap& properties
|
||||||
bool invokeResult;
|
bool invokeResult;
|
||||||
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
|
||||||
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||||
if (tablet->getToolbarMode()) {
|
if (tablet->getToolbarMode() && _desktop) {
|
||||||
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(_desktop, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
} else {
|
} else if (QQuickItem* tabletRoot = tablet->getTabletRoot()) {
|
||||||
QQuickItem* tabletRoot = tablet->getTabletRoot();
|
|
||||||
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
invokeResult = QMetaObject::invokeMethod(tabletRoot, "assetDialog",
|
||||||
Q_RETURN_ARG(QVariant, buildDialogResult),
|
Q_RETURN_ARG(QVariant, buildDialogResult),
|
||||||
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
Q_ARG(QVariant, QVariant::fromValue(properties)));
|
||||||
|
|
|
@ -14,9 +14,6 @@
|
||||||
|
|
||||||
#include <shared/QtHelpers.h>
|
#include <shared/QtHelpers.h>
|
||||||
|
|
||||||
#include "OffscreenUi.h"
|
|
||||||
|
|
||||||
|
|
||||||
std::mutex QmlFragmentClass::_mutex;
|
std::mutex QmlFragmentClass::_mutex;
|
||||||
std::map<QString, QScriptValue> QmlFragmentClass::_fragments;
|
std::map<QString, QScriptValue> QmlFragmentClass::_fragments;
|
||||||
|
|
||||||
|
@ -40,7 +37,6 @@ QScriptValue QmlFragmentClass::internal_constructor(QScriptContext* context, QSc
|
||||||
}
|
}
|
||||||
|
|
||||||
auto properties = parseArguments(context);
|
auto properties = parseArguments(context);
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
QmlFragmentClass* retVal = new QmlFragmentClass(restricted, qml.toString());
|
QmlFragmentClass* retVal = new QmlFragmentClass(restricted, qml.toString());
|
||||||
Q_ASSERT(retVal);
|
Q_ASSERT(retVal);
|
||||||
if (QThread::currentThread() != qApp->thread()) {
|
if (QThread::currentThread() != qApp->thread()) {
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include <QtScript/QScriptEngine>
|
#include <QtScript/QScriptEngine>
|
||||||
|
|
||||||
#include <shared/QtHelpers.h>
|
#include <shared/QtHelpers.h>
|
||||||
#include "OffscreenUi.h"
|
|
||||||
|
|
||||||
static const char* const URL_PROPERTY = "source";
|
static const char* const URL_PROPERTY = "source";
|
||||||
static const char* const SCRIPT_PROPERTY = "scriptUrl";
|
static const char* const SCRIPT_PROPERTY = "scriptUrl";
|
||||||
|
@ -22,7 +21,6 @@ static const char* const SCRIPT_PROPERTY = "scriptUrl";
|
||||||
// Method called by Qt scripts to create a new web window in the overlay
|
// Method called by Qt scripts to create a new web window in the overlay
|
||||||
QScriptValue QmlWebWindowClass::internal_constructor(QScriptContext* context, QScriptEngine* engine, bool restricted) {
|
QScriptValue QmlWebWindowClass::internal_constructor(QScriptContext* context, QScriptEngine* engine, bool restricted) {
|
||||||
auto properties = parseArguments(context);
|
auto properties = parseArguments(context);
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
QmlWebWindowClass* retVal = new QmlWebWindowClass(restricted);
|
QmlWebWindowClass* retVal = new QmlWebWindowClass(restricted);
|
||||||
Q_ASSERT(retVal);
|
Q_ASSERT(retVal);
|
||||||
if (QThread::currentThread() != qApp->thread()) {
|
if (QThread::currentThread() != qApp->thread()) {
|
||||||
|
|
|
@ -72,7 +72,6 @@ QVariantMap QmlWindowClass::parseArguments(QScriptContext* context) {
|
||||||
// Method called by Qt scripts to create a new web window in the overlay
|
// Method called by Qt scripts to create a new web window in the overlay
|
||||||
QScriptValue QmlWindowClass::internal_constructor(QScriptContext* context, QScriptEngine* engine, bool restricted) {
|
QScriptValue QmlWindowClass::internal_constructor(QScriptContext* context, QScriptEngine* engine, bool restricted) {
|
||||||
auto properties = parseArguments(context);
|
auto properties = parseArguments(context);
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
QmlWindowClass* retVal = new QmlWindowClass(restricted);
|
QmlWindowClass* retVal = new QmlWindowClass(restricted);
|
||||||
Q_ASSERT(retVal);
|
Q_ASSERT(retVal);
|
||||||
if (QThread::currentThread() != qApp->thread()) {
|
if (QThread::currentThread() != qApp->thread()) {
|
||||||
|
@ -349,7 +348,6 @@ void QmlWindowClass::raise() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
if (_qmlWindow) {
|
if (_qmlWindow) {
|
||||||
QMetaObject::invokeMethod(asQuickItem(), "raise", Qt::DirectConnection);
|
QMetaObject::invokeMethod(asQuickItem(), "raise", Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,8 +321,8 @@ void TabletScriptingInterface::processEvent(const QKeyEvent* event) {
|
||||||
|
|
||||||
QObject* TabletScriptingInterface::getFlags() {
|
QObject* TabletScriptingInterface::getFlags() {
|
||||||
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
Q_ASSERT(QThread::currentThread() == qApp->thread());
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
return offscreenUi->getFlags();
|
return offscreenUI ? offscreenUI->getFlags() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -364,8 +364,6 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
||||||
|
|
||||||
_toolbarMode = toolbarMode;
|
_toolbarMode = toolbarMode;
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
|
|
||||||
if (toolbarMode) {
|
if (toolbarMode) {
|
||||||
#if !defined(DISABLE_QML)
|
#if !defined(DISABLE_QML)
|
||||||
closeDialog();
|
closeDialog();
|
||||||
|
@ -388,13 +386,18 @@ void TabletProxy::setToolbarMode(bool toolbarMode) {
|
||||||
if (_currentPathLoaded != TABLET_HOME_SOURCE_URL) {
|
if (_currentPathLoaded != TABLET_HOME_SOURCE_URL) {
|
||||||
loadHomeScreen(true);
|
loadHomeScreen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
|
if (offscreenUI) {
|
||||||
//check if running scripts window opened and save it for reopen in Tablet
|
//check if running scripts window opened and save it for reopen in Tablet
|
||||||
if (offscreenUi->isVisible("RunningScripts")) {
|
if (offscreenUI->isVisible("RunningScripts")) {
|
||||||
offscreenUi->hide("RunningScripts");
|
offscreenUI->hide("RunningScripts");
|
||||||
_showRunningScripts = true;
|
_showRunningScripts = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
offscreenUi->hideDesktopWindows();
|
offscreenUI->hideDesktopWindows();
|
||||||
|
}
|
||||||
|
|
||||||
// destroy desktop window
|
// destroy desktop window
|
||||||
if (_desktopWindow) {
|
if (_desktopWindow) {
|
||||||
_desktopWindow->deleteLater();
|
_desktopWindow->deleteLater();
|
||||||
|
@ -577,9 +580,9 @@ void TabletProxy::gotoMenuScreen(const QString& submenu) {
|
||||||
root = _desktopWindow->asQuickItem();
|
root = _desktopWindow->asQuickItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root) {
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
if (root && offscreenUI) {
|
||||||
QObject* menu = offscreenUi->getRootMenu();
|
QObject* menu = offscreenUI->getRootMenu();
|
||||||
QMetaObject::invokeMethod(root, "setMenuProperties", Q_ARG(QVariant, QVariant::fromValue(menu)), Q_ARG(const QVariant&, QVariant(submenu)));
|
QMetaObject::invokeMethod(root, "setMenuProperties", Q_ARG(QVariant, QVariant::fromValue(menu)), Q_ARG(const QVariant&, QVariant(submenu)));
|
||||||
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));
|
QMetaObject::invokeMethod(root, "loadSource", Q_ARG(const QVariant&, QVariant(VRMENU_SOURCE_URL)));
|
||||||
_state = State::Menu;
|
_state = State::Menu;
|
||||||
|
|
|
@ -203,14 +203,14 @@ void updateFromOpenVrKeyboardInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishOpenVrKeyboardInput() {
|
void finishOpenVrKeyboardInput() {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUI = DependencyManager::get<OffscreenUi>();
|
||||||
updateFromOpenVrKeyboardInput();
|
updateFromOpenVrKeyboardInput();
|
||||||
// Simulate an enter press on the top level window to trigger the action
|
// Simulate an enter press on the top level window to trigger the action
|
||||||
if (0 == (_currentHints & Qt::ImhMultiLine)) {
|
if (0 == (_currentHints & Qt::ImhMultiLine) && offscreenUI) {
|
||||||
auto keyPress = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::KeyboardModifiers(), QString("\n"));
|
auto keyPress = QKeyEvent(QEvent::KeyPress, Qt::Key_Return, Qt::KeyboardModifiers(), QString("\n"));
|
||||||
auto keyRelease = QKeyEvent(QEvent::KeyRelease, Qt::Key_Return, Qt::KeyboardModifiers());
|
auto keyRelease = QKeyEvent(QEvent::KeyRelease, Qt::Key_Return, Qt::KeyboardModifiers());
|
||||||
qApp->sendEvent(offscreenUi->getWindow(), &keyPress);
|
qApp->sendEvent(offscreenUI->getWindow(), &keyPress);
|
||||||
qApp->sendEvent(offscreenUi->getWindow(), &keyRelease);
|
qApp->sendEvent(offscreenUI->getWindow(), &keyRelease);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,10 +221,8 @@ void enableOpenVrKeyboard(PluginContainer* container) {
|
||||||
if (disableSteamVrKeyboard) {
|
if (disableSteamVrKeyboard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
_overlay = vr::VROverlay();
|
_overlay = vr::VROverlay();
|
||||||
|
|
||||||
|
|
||||||
auto menu = container->getPrimaryMenu();
|
auto menu = container->getPrimaryMenu();
|
||||||
auto action = menu->getActionForOption(MenuOption::Overlays);
|
auto action = menu->getActionForOption(MenuOption::Overlays);
|
||||||
|
|
||||||
|
@ -282,7 +280,9 @@ void handleOpenVrEvents() {
|
||||||
case vr::VREvent_KeyboardClosed:
|
case vr::VREvent_KeyboardClosed:
|
||||||
_keyboardFocusObject = nullptr;
|
_keyboardFocusObject = nullptr;
|
||||||
_keyboardShown = false;
|
_keyboardShown = false;
|
||||||
DependencyManager::get<OffscreenUi>()->unfocusWindows();
|
if (auto offscreenUI = DependencyManager::get<OffscreenUi>()) {
|
||||||
|
offscreenUI->unfocusWindows();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue