Install marketplace item tester

This commit is contained in:
Kerry Ivan Kurian 2018-09-13 12:15:18 -07:00
parent 79cf1cb612
commit f2a046da91
4 changed files with 186 additions and 4 deletions

View file

@ -0,0 +1,157 @@
//
// marketplaceItemTester
// qml/hifi/commerce/marketplaceItemTester
//
// Load items not in the marketplace for testing purposes
//
// Created by Zach Fox on 2018-09-05
// Copyright 2018 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.5
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.0
import QtQuick.Layouts 1.1
import Hifi 1.0 as Hifi
import "../../../styles-uit" as HifiStylesUit
import "../../../controls-uit" as HifiControlsUit
Rectangle {
id:root
HifiStylesUit.HifiConstants { id: hifi }
color: hifi.colors.white
ListModel { id: listModel }
ListView {
anchors.fill: parent
anchors.leftMargin: 12
anchors.bottomMargin: 40
model: listModel
spacing: 5
delegate: RowLayout {
anchors.left: parent.left
width: parent.width
spacing: 5
Text {
text: {
var match = resource.match(/\/([^/]*)$/);
return match ? match[1] : resource;
}
font.pointSize: 12
Layout.preferredWidth: root.width * .6
horizontalAlignment: Text.AlignBottom
}
Text {
text: assetType
font.pointSize: 10
Layout.preferredWidth: root.width * .2
horizontalAlignment: Text.AlignBottom
}
property var actions: {
"forward": function(resource, assetType){
if ("application" == assetType) {
Commerce.installApp(resource);
Commerce.openApp(resource);
}
// XXX support other resource types here.
},
"trash": function(){
if ("application" == assetType) {
Commerce.uninstallApp(resource);
}
// XXX support other resource types here.
listModel.remove(index);
}
}
Repeater {
model: [
{ "name": "forward", "glyph": hifi.glyphs.forward, "size": 30 },
{ "name": "trash", "glyph": hifi.glyphs.trash, "size": 22}
]
HifiStylesUit.HiFiGlyphs {
text: modelData.glyph
size: modelData.size
color: hifi.colors.black
horizontalAlignment: Text.AlignHCenter
MouseArea {
anchors.fill: parent
onClicked: {
actions[modelData.name](resource, assetType);
}
}
}
}
}
headerPositioning: ListView.OverlayHeader
header: HifiStylesUit.RalewayRegular {
id: rootHeader
text: "Marketplace Item Tester"
height: 80
width: paintedWidth
size: 22
color: hifi.colors.black
anchors.left: parent.left
anchors.leftMargin: 12
}
footerPositioning: ListView.OverlayFooter
footer: Row {
id: rootActions
spacing: 20
anchors.horizontalCenter: parent.horizontalCenter
property string currentAction
function assetType(resource) {
return (resource.match(/\.app\.json$/) ? "application" :
resource.match(/\.(?:fbx|fst)$/) ? "avatar" :
resource.match(/\.json\.gz$/) ? "content set" :
resource.match(/\.json$/) ? "entity or wearable" :
"unknown")
}
function onResourceSelected(resource) {
// It is possible that we received the present signal
// from something other than our browserAsync window.
// Alas, there is nothing we can do about that so charge
// ahead as though we are sure the present signal is one
// we expect.
if ("load file" == currentAction) {
print("disconnecting load file");
Window.browseChanged.disconnect(onResourceSelected);
} else if ("load url" == currentAction) {
print("disconnecting load url");
Window.promptTextChanged.disconnect(onResourceSelected);
}
if (resource) {
listModel.append( {
"resource": resource.trim(),
"assetType": assetType(resource.trim()) } );
}
}
property var actions: {
"Load File": function(){
rootActions.currentAction = "load file";
Window.browseChanged.connect(onResourceSelected);
Window.browseAsync("Please select a file", "", "Assets (*.app.json *.json *.fbx *.json.gz)");
},
"Load URL": function(){
rootActions.currentAction = "load url";
Window.promptTextChanged.connect(onResourceSelected);
Window.promptAsync("Please enter a URL", "");
}
}
Repeater {
model: [ "Load File", "Load URL" ]
HifiControlsUit.Button {
color: hifi.buttons.blue
fontSize: 20
text: modelData
width: root.width / 3
height: 40
onClicked: actions[text]()
}
}
}
}
}

View file

@ -1691,21 +1691,21 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_WINDOWS, []() -> float {
#if defined(Q_OS_WIN)
#if defined(Q_OS_WIN)
return 1;
#else
return 0;
#endif
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_MAC, []() -> float {
#if defined(Q_OS_MAC)
#if defined(Q_OS_MAC)
return 1;
#else
return 0;
#endif
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_ANDROID, []() -> float {
#if defined(Q_OS_ANDROID)
#if defined(Q_OS_ANDROID)
return 1;
#else
return 0;
@ -2881,9 +2881,10 @@ void Application::initializeUi() {
QUrl{ "hifi/commerce/common/CommerceLightbox.qml" },
QUrl{ "hifi/commerce/common/EmulatedMarketplaceHeader.qml" },
QUrl{ "hifi/commerce/common/FirstUseTutorial.qml" },
QUrl{ "hifi/commerce/common/SortableListModel.qml" },
QUrl{ "hifi/commerce/common/sendAsset/SendAsset.qml" },
QUrl{ "hifi/commerce/common/SortableListModel.qml" },
QUrl{ "hifi/commerce/inspectionCertificate/InspectionCertificate.qml" },
QUrl{ "hifi/commerce/marketplaceItemTester/MarketplaceItemTester.qml"},
QUrl{ "hifi/commerce/purchases/PurchasedItem.qml" },
QUrl{ "hifi/commerce/purchases/Purchases.qml" },
QUrl{ "hifi/commerce/wallet/Help.qml" },

View file

@ -228,6 +228,7 @@ QString QmlCommerce::getInstalledApps(const QString& justInstalledAppID) {
// Thus, we protect against deleting the .app.json from the user's disk (below)
// by skipping that check for the app we just installed.
if ((justInstalledAppID != "") && ((justInstalledAppID + ".app.json") == appFileName)) {
installedAppsFromMarketplace += appFileName + ",";
continue;
}

View file

@ -583,6 +583,27 @@
//
// Manage the connection between the button and the window.
//
var DEVELOPER_MENU = "Developer";
var MARKETPLACE_ITEM_TESTER_LABEL = "Marktplace Item Tester";
var MARKETPLACE_ITEM_TESTER_QML_SOURCE = "hifi/commerce/marketplaceItemTester/MarketplaceItemTester.qml";
function installMarketplaceItemTester() {
if (!Menu.menuExists(DEVELOPER_MENU)) {
Menu.addMenu(DEVELOPER_MENU);
}
if (!Menu.menuItemExists(DEVELOPER_MENU, MARKETPLACE_ITEM_TESTER_LABEL)) {
Menu.addMenuItem({ menuName: DEVELOPER_MENU,
menuItemName: MARKETPLACE_ITEM_TESTER_LABEL,
isCheckable: false })
}
Menu.menuItemEvent.connect(function (menuItem) {
if (menuItem === MARKETPLACE_ITEM_TESTER_LABEL) {
tablet.loadQMLSource(MARKETPLACE_ITEM_TESTER_QML_SOURCE);
}
});
}
var button;
var buttonName = "WALLET";
var tablet = null;
@ -600,7 +621,9 @@
button.clicked.connect(onButtonClicked);
tablet.screenChanged.connect(onTabletScreenChanged);
}
installMarketplaceItemTester();
}
var isWired = false;
var isUpdateOverlaysWired = false;
function off() {