示例#1
0
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;
}
示例#2
0
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();
}
示例#3
0
void LoginDialog::openUrl(const QString& url) const {

    auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
    auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
    auto hmd = DependencyManager::get<HMDScriptingInterface>();
    auto offscreenUi = DependencyManager::get<OffscreenUi>();

    if (tablet->getToolbarMode()) {
        auto browser = offscreenUi->load("Browser.qml");
        browser->setProperty("url", url);
    } else {
        if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) {
            auto browser = offscreenUi->load("Browser.qml");
            browser->setProperty("url", url);
        } else {
            tablet->gotoWebScreen(url);
        }
    }
}