mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
It's working!
This commit is contained in:
parent
de0eee52d6
commit
10fa3fa346
5 changed files with 54 additions and 25 deletions
|
@ -47,7 +47,7 @@ Item {
|
|||
property bool showConfirmation: false;
|
||||
property bool hasPermissionToRezThis;
|
||||
property bool permissionExplanationCardVisible;
|
||||
property bool isInstalled: false;
|
||||
property bool isInstalled;
|
||||
|
||||
property string originalStatusText;
|
||||
property string originalStatusColor;
|
||||
|
@ -69,6 +69,12 @@ Item {
|
|||
root.isInstalled = true;
|
||||
}
|
||||
}
|
||||
|
||||
onAppUninstalled: {
|
||||
if (appHref === root.itemHref) {
|
||||
root.isInstalled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
|
@ -88,10 +94,6 @@ Item {
|
|||
} else {
|
||||
root.hasPermissionToRezThis = true;
|
||||
}
|
||||
|
||||
if (itemType === "app") {
|
||||
root.isInstalled = Commerce.isAppInstalled(root.itemHref);
|
||||
}
|
||||
}
|
||||
|
||||
onPurchaseStatusChangedChanged: {
|
||||
|
@ -496,6 +498,8 @@ Item {
|
|||
colorScheme: hifi.colorSchemes.light;
|
||||
anchors.top: parent.top;
|
||||
anchors.right: parent.right;
|
||||
anchors.left: parent.left;
|
||||
width: 92;
|
||||
height: 44;
|
||||
text: "OPEN"
|
||||
onClicked: {
|
||||
|
@ -509,6 +513,7 @@ Item {
|
|||
colorScheme: hifi.colorSchemes.light;
|
||||
anchors.bottom: parent.bottom;
|
||||
anchors.right: parent.right;
|
||||
anchors.left: parent.left;
|
||||
height: 44;
|
||||
text: "UNINSTALL"
|
||||
onClicked: {
|
||||
|
|
|
@ -36,6 +36,7 @@ Rectangle {
|
|||
property bool isShowingMyItems: false;
|
||||
property bool isDebuggingFirstUseTutorial: false;
|
||||
property int pendingItemCount: 0;
|
||||
property var installedApps;
|
||||
// Style
|
||||
color: hifi.colors.white;
|
||||
Connections {
|
||||
|
@ -61,6 +62,8 @@ Rectangle {
|
|||
root.activeView = "firstUseTutorial";
|
||||
} else if (!Settings.getValue("isFirstUseOfPurchases", true) && root.activeView === "initialize") {
|
||||
root.activeView = "purchasesMain";
|
||||
root.installedApps = Commerce.getInstalledApps();
|
||||
console.log("ZRF! " + root.installedApps);
|
||||
Commerce.inventory();
|
||||
}
|
||||
} else {
|
||||
|
@ -269,6 +272,7 @@ Rectangle {
|
|||
case 'tutorial_finished':
|
||||
Settings.setValue("isFirstUseOfPurchases", false);
|
||||
root.activeView = "purchasesMain";
|
||||
root.installedApps = Commerce.getInstalledApps();
|
||||
Commerce.inventory();
|
||||
break;
|
||||
}
|
||||
|
@ -394,6 +398,7 @@ Rectangle {
|
|||
limitedRun: model.limited_run;
|
||||
displayedItemCount: model.displayedItemCount;
|
||||
permissionExplanationCardVisible: model.permissionExplanationCardVisible;
|
||||
isInstalled: model.isInstalled;
|
||||
itemType: {
|
||||
if (model.root_file_url.indexOf(".fst") > -1) {
|
||||
"avatar";
|
||||
|
@ -680,9 +685,16 @@ Rectangle {
|
|||
|
||||
if (sameItemCount !== tempPurchasesModel.count || filterBar.text !== filterBar.previousText) {
|
||||
filteredPurchasesModel.clear();
|
||||
var currentId;
|
||||
for (var i = 0; i < tempPurchasesModel.count; i++) {
|
||||
currentId = tempPurchasesModel.get(i).id;
|
||||
console.log("ZRF HERE 2 " + root.installedApps);
|
||||
console.log("ZRF HERE 3 " + currentId);
|
||||
console.log("ZRF HERE 4 " + ((root.installedApps).indexOf(currentId) > -1));
|
||||
|
||||
filteredPurchasesModel.append(tempPurchasesModel.get(i));
|
||||
filteredPurchasesModel.setProperty(i, 'permissionExplanationCardVisible', false);
|
||||
filteredPurchasesModel.setProperty(i, 'isInstalled', ((root.installedApps).indexOf(currentId) > -1));
|
||||
}
|
||||
|
||||
populateDisplayedItemCounts();
|
||||
|
|
|
@ -45,7 +45,7 @@ QmlCommerce::QmlCommerce() {
|
|||
setPassphrase("");
|
||||
});
|
||||
|
||||
_appsPath = PathUtils::getAppDataPath() + "Apps";
|
||||
_appsPath = PathUtils::getAppDataPath() + "Apps/";
|
||||
}
|
||||
|
||||
void QmlCommerce::getWalletStatus() {
|
||||
|
@ -190,26 +190,38 @@ void QmlCommerce::alreadyOwned(const QString& marketplaceId) {
|
|||
ledger->alreadyOwned(marketplaceId);
|
||||
}
|
||||
|
||||
bool QmlCommerce::isAppInstalled(const QString& itemHref) {
|
||||
QUrl appHref(itemHref);
|
||||
QStringList QmlCommerce::getInstalledApps() {
|
||||
QStringList installedAppsFromMarketplace;
|
||||
QStringList runningScripts = DependencyManager::get<ScriptEngines>()->getRunningScripts();
|
||||
|
||||
// First check if .app.json exists
|
||||
QFileInfo appFile(_appsPath + "/" + appHref.fileName());
|
||||
if (!(appFile.exists() && appFile.isFile())) {
|
||||
return false;
|
||||
}
|
||||
QDir directory(_appsPath);
|
||||
qCDebug(commerce) << "ZRF FIXME" << _appsPath;
|
||||
QStringList apps = directory.entryList(QStringList("*.app.json"));
|
||||
foreach(QString appFileName, apps) {
|
||||
installedAppsFromMarketplace.append(appFileName);
|
||||
qCDebug(commerce) << "ZRF FIXME" << appFileName;
|
||||
QFile appFile(_appsPath + appFileName);
|
||||
if (appFile.open(QIODevice::ReadOnly)) {
|
||||
QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(appFile.readAll());
|
||||
|
||||
// Then check to see if script is running
|
||||
auto runningScripts = DependencyManager::get<ScriptEngines>()->getRunningScripts();
|
||||
foreach(const QString& runningScript, runningScripts) {
|
||||
QUrl runningScriptURL = QUrl(runningScript);
|
||||
qCDebug(commerce) << "ZRF FIXME" << runningScriptURL;
|
||||
if (runningScriptURL == appHref) {
|
||||
return true;
|
||||
appFile.close();
|
||||
|
||||
QJsonObject appFileJsonObject = appFileJsonDocument.object();
|
||||
QString scriptURL = appFileJsonObject["scriptURL"].toString();
|
||||
|
||||
// If the script .app.json is on the user's local disk but the associated script isn't running
|
||||
// for some reason, start that script again.
|
||||
if (!runningScripts.contains(scriptURL)) {
|
||||
if ((DependencyManager::get<ScriptEngines>()->loadScript(scriptURL.trimmed())).isNull()) {
|
||||
qCDebug(commerce) << "Couldn't start script while checking installed apps.";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qCDebug(commerce) << "Couldn't open local .app.json file for reading.";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return installedAppsFromMarketplace;
|
||||
}
|
||||
|
||||
bool QmlCommerce::installApp(const QString& itemHref) {
|
||||
|
|
|
@ -51,8 +51,8 @@ signals:
|
|||
|
||||
void contentSetChanged(const QString& contentSetHref);
|
||||
|
||||
void appInstalled(const QString& appFileName);
|
||||
void appUninstalled(const QString& appFileName);
|
||||
void appInstalled(const QString& appHref);
|
||||
void appUninstalled(const QString& appHref);
|
||||
|
||||
protected:
|
||||
Q_INVOKABLE void getWalletStatus();
|
||||
|
@ -81,7 +81,7 @@ protected:
|
|||
|
||||
Q_INVOKABLE void replaceContentSet(const QString& itemHref);
|
||||
|
||||
Q_INVOKABLE bool isAppInstalled(const QString& appHref);
|
||||
Q_INVOKABLE QStringList getInstalledApps();
|
||||
Q_INVOKABLE bool installApp(const QString& appHref);
|
||||
Q_INVOKABLE bool uninstallApp(const QString& appHref);
|
||||
Q_INVOKABLE bool openApp(const QString& appHref);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
// for toolbar-mode: go back to home screen, this will close the window.
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
tablet.loadQMLSource(WALLET_QML_SOURCE);
|
||||
tablet.loadQMLSource(MARKETPLACE_PURCHASES_QML_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue