bool QmlCommerce::openApp(const QString& itemHref) { QUrl appHref(itemHref); // Read from the file to know what .html or .qml document to open QFile appFile(_appsPath + "/" + appHref.fileName()); if (!appFile.open(QIODevice::ReadOnly)) { qCDebug(commerce) << "Couldn't open local .app.json file:" << appFile; return false; } QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(appFile.readAll()); QJsonObject appFileJsonObject = appFileJsonDocument.object(); QString homeUrl = appFileJsonObject["homeURL"].toString(); auto tablet = dynamic_cast<TabletProxy*>( DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system")); if (homeUrl.contains(".qml", Qt::CaseInsensitive)) { tablet->loadQMLSource(homeUrl); } else if (homeUrl.contains(".html", Qt::CaseInsensitive)) { tablet->gotoWebScreen(homeUrl); } else { qCDebug(commerce) << "Attempted to open unknown type of homeURL!"; return false; } DependencyManager::get<HMDScriptingInterface>()->openTablet(); return true; }
void LoginDialog::showWithSelection() { auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); auto hmd = DependencyManager::get<HMDScriptingInterface>(); if (!qApp->isHMDMode()) { if (qApp->getLoginDialogPoppedUp()) { LoginDialog::show(); return; } else { if (!tablet->isPathLoaded(TABLET_LOGIN_DIALOG_URL)) { tablet->loadQMLSource(TABLET_LOGIN_DIALOG_URL); } } } else { if (!qApp->getLoginDialogPoppedUp()) { tablet->initialScreen(TABLET_LOGIN_DIALOG_URL); } else { qApp->createLoginDialogOverlay(); } } if (!hmd->getShouldShowTablet()) { hmd->openTablet(); } }
void QmlMarketplace::openMarketplace(const QString& marketplaceItemId) { auto tablet = dynamic_cast<TabletProxy*>( DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system")); tablet->loadQMLSource("hifi/commerce/marketplace/Marketplace.qml"); DependencyManager::get<HMDScriptingInterface>()->openTablet(); if (!marketplaceItemId.isEmpty()) { tablet->sendToQml(QVariantMap({ { "method", "marketplace_openItem" }, { "itemId", marketplaceItemId } })); } }
void DialogsManager::showAddressBar() { auto hmd = DependencyManager::get<HMDScriptingInterface>(); auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); if (!tablet->isPathLoaded(TABLET_ADDRESS_DIALOG)) { tablet->loadQMLSource(TABLET_ADDRESS_DIALOG); } if (!hmd->getShouldShowTablet()) { hmd->openTablet(); } qApp->setKeyboardFocusOverlay(hmd->getCurrentTabletScreenID()); setAddressBarVisible(true); }
void QmlCommerce::openSystemApp(const QString& appName) { static QMap<QString, QString> systemApps { {"GOTO", "hifi/tablet/TabletAddressDialog.qml"}, {"PEOPLE", "hifi/Pal.qml"}, {"WALLET", "hifi/commerce/wallet/Wallet.qml"}, {"MARKET", "/marketplace.html"} }; static QMap<QString, QString> systemInject{ {"MARKET", "/scripts/system/html/js/marketplacesInject.js"} }; auto tablet = dynamic_cast<TabletProxy*>( DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system")); QMap<QString, QString>::const_iterator appPathIter = systemApps.find(appName); if (appPathIter != systemApps.end()) { if (appPathIter->contains(".qml", Qt::CaseInsensitive)) { tablet->loadQMLSource(*appPathIter); } else if (appPathIter->contains(".html", Qt::CaseInsensitive)) { QMap<QString, QString>::const_iterator injectIter = systemInject.find(appName); if (appPathIter == systemInject.end()) { tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter); } else { QString inject = "file:///" + qApp->applicationDirPath() + *injectIter; tablet->gotoWebScreen(NetworkingConstants::METAVERSE_SERVER_URL().toString() + *appPathIter, inject); } } else { qCDebug(commerce) << "Attempted to open unknown type of URL!"; return; } } else { qCDebug(commerce) << "Attempted to open unknown APP!"; return; } DependencyManager::get<HMDScriptingInterface>()->openTablet(); }