I'm a big dumb idiot

This commit is contained in:
HifiExperiments 2021-01-21 17:38:55 -08:00
parent 2667af3682
commit ff6f7233e4

View file

@ -199,9 +199,9 @@ void WindowScriptingInterface::setInterstitialModeEnabled(bool enableInterstitia
DependencyManager::get<NodeList>()->getDomainHandler().setInterstitialModeEnabled(enableInterstitialMode); DependencyManager::get<NodeList>()->getDomainHandler().setInterstitialModeEnabled(enableInterstitialMode);
} }
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>()) {
static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton)); auto messageBox = offscreenUI->createMessageBox(OffscreenUi::ICON_INFORMATION, title, text,
connect(messageBox, SIGNAL(selected(int)), this, SLOT(onMessageBoxSelected(int))); static_cast<QFlags<QMessageBox::StandardButton>>(buttons), static_cast<QMessageBox::StandardButton>(defaultButton));
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);
} }