Tons of improvements

This commit is contained in:
Zach Fox 2018-10-19 15:21:37 -07:00 committed by Kerry Ivan Kurian
parent bccca94111
commit d44f9e2ccc
6 changed files with 79 additions and 73 deletions

View file

@ -29,7 +29,7 @@ Rectangle {
"forward": function(resource, assetType, resourceObjectId){ "forward": function(resource, assetType, resourceObjectId){
switch(assetType) { switch(assetType) {
case "application": case "application":
Commerce.openApp(resource); Commerce.installApp(resource, true);
break; break;
case "avatar": case "avatar":
MyAvatar.useFullAvatarURL(resource); MyAvatar.useFullAvatarURL(resource);
@ -137,7 +137,7 @@ Rectangle {
"entity": hifi.glyphs.wand, "entity": hifi.glyphs.wand,
"trash": hifi.glyphs.trash, "trash": hifi.glyphs.trash,
"unknown": hifi.glyphs.circleSlash, "unknown": hifi.glyphs.circleSlash,
"wearable": hifi.glyphs.hat, "wearable": hifi.glyphs.hat
} }
property int color: hifi.buttons.blue; property int color: hifi.buttons.blue;
property int colorScheme: hifi.colorSchemes.dark; property int colorScheme: hifi.colorSchemes.dark;
@ -149,8 +149,19 @@ Rectangle {
enabled: comboBox.model[comboBox.currentIndex] !== "unknown" enabled: comboBox.model[comboBox.currentIndex] !== "unknown"
onClicked: { onClicked: {
if (model.currentlyRecordingResources) {
model.currentlyRecordingResources = false;
} else {
model.resourceAccessEventText = "";
model.currentlyRecordingResources = true;
root.actions["forward"](resource, comboBox.currentText, resourceObjectId); root.actions["forward"](resource, comboBox.currentText, resourceObjectId);
} }
sendToScript({
method: "tester_updateResourceRecordingStatus",
objectId: resourceListModel.get(index).resourceObjectId,
status: model.currentlyRecordingResources
});
}
background: Rectangle { background: Rectangle {
radius: 4; radius: 4;
@ -189,7 +200,7 @@ Rectangle {
contentItem: Item { contentItem: Item {
HifiStylesUit.HiFiGlyphs { HifiStylesUit.HiFiGlyphs {
id: rezIcon; id: rezIcon;
text: actionButton.glyphs[comboBox.model[comboBox.currentIndex]]; text: model.currentlyRecordingResources ? hifi.glyphs.scriptStop : actionButton.glyphs[comboBox.model[comboBox.currentIndex]];
anchors.fill: parent anchors.fill: parent
size: 30; size: 30;
horizontalAlignment: Text.AlignHCenter; horizontalAlignment: Text.AlignHCenter;
@ -304,9 +315,9 @@ Rectangle {
color: hifi.colors.white color: hifi.colors.white
text: { text: {
if (root.detailsExpanded) { if (root.detailsExpanded) {
return resourceAccessEventText return model.resourceAccessEventText
} else { } else {
return (resourceAccessEventText.split("\n").length - 1).toString() + " resources loaded..." return (model.resourceAccessEventText.split("\n").length - 1).toString() + " resources loaded..."
} }
} }
font: Qt.font({ family: "Courier", pointSize: 8, weight: Font.Normal }) font: Qt.font({ family: "Courier", pointSize: 8, weight: Font.Normal })
@ -340,7 +351,7 @@ Rectangle {
anchors.top: detailsTextContainer.bottom anchors.top: detailsTextContainer.bottom
anchors.topMargin: 8 anchors.topMargin: 8
anchors.right: parent.right anchors.right: parent.right
width: 150 width: 160
height: 30 height: 30
text: "Copy to Clipboard" text: "Copy to Clipboard"

View file

@ -24,17 +24,13 @@ Rectangle {
id: root id: root
property string installedApps property string installedApps
property string resourceAccessEventText
property var nextResourceObjectId: 0 property var nextResourceObjectId: 0
property var startDate
HifiStylesUit.HifiConstants { id: hifi } HifiStylesUit.HifiConstants { id: hifi }
ListModel { id: resourceListModel } ListModel { id: resourceListModel }
color: hifi.colors.darkGray color: hifi.colors.darkGray
Component.onCompleted: startDate = new Date()
// //
// TITLE BAR START // TITLE BAR START
// //
@ -147,8 +143,7 @@ Rectangle {
model: resourceListModel model: resourceListModel
spacing: 8 spacing: 8
delegate: ItemUnderTest { delegate: ItemUnderTest { }
}
} }
Item { Item {
@ -194,8 +189,6 @@ Rectangle {
if (resource) { if (resource) {
print("!!!! building resource object"); print("!!!! building resource object");
var resourceObj = buildResourceObj(resource); var resourceObj = buildResourceObj(resource);
print("!!!! installing resource object");
installResourceObj(resourceObj);
print("!!!! notifying script of resource object"); print("!!!! notifying script of resource object");
sendToScript({ sendToScript({
method: 'tester_newResourceObject', method: 'tester_newResourceObject',
@ -235,6 +228,7 @@ Rectangle {
switch (message.method) { switch (message.method) {
case "newResourceObjectInTest": case "newResourceObjectInTest":
var resourceObject = message.resourceObject; var resourceObject = message.resourceObject;
resourceListModel.clear(); // REMOVE THIS once we support specific referrers
resourceListModel.append(resourceObject); resourceListModel.append(resourceObject);
spinner.visible = false; spinner.visible = false;
break; break;
@ -244,21 +238,9 @@ Rectangle {
spinner.visible = false; spinner.visible = false;
break; break;
case "resourceRequestEvent": case "resourceRequestEvent":
try { // When we support multiple items under test simultaneously,
var date = new Date(JSON.parse(message.data.date)); // we'll have to replace "0" with the correct index.
} catch(err) { resourceListModel.setProperty(0, "resourceAccessEventText", message.resourceAccessEventText);
print("!!!!! Date conversion failed: " + JSON.stringify(message.data));
}
// XXX Eventually this date check goes away b/c we will
// be able to match up resouce access events to resource
// object ids, ignoring those that have -1 resource
// object ids.
if (date >= startDate) {
resourceAccessEventText += (
"[" + date.toISOString() + "] " +
message.data.url.toString().replace("__NONE__,", "") + "\n"
);
}
break; break;
} }
} }
@ -270,17 +252,13 @@ Rectangle {
resource.match(/\.json\.gz$/) ? "content set" : resource.match(/\.json\.gz$/) ? "content set" :
resource.match(/\.json$/) ? "entity or wearable" : resource.match(/\.json$/) ? "entity or wearable" :
"unknown"); "unknown");
return { "resourceObjectId": nextResourceObjectId++, // Uncomment this once we support more than one item in test at the same time
//nextResourceObjectId++;
return { "resourceObjectId": nextResourceObjectId,
"resource": resource, "resource": resource,
"assetType": assetType }; "assetType": assetType };
} }
function installResourceObj(resourceObj) {
if ("application" === resourceObj.assetType) {
Commerce.installApp(resourceObj.resource);
}
}
function toUrl(resource) { function toUrl(resource) {
var httpPattern = /^http/i; var httpPattern = /^http/i;
return httpPattern.test(resource) ? resource : "file:///" + resource; return httpPattern.test(resource) ? resource : "file:///" + resource;

View file

@ -315,7 +315,7 @@ QString QmlCommerce::getInstalledApps(const QString& justInstalledAppID) {
return installedAppsFromMarketplace; return installedAppsFromMarketplace;
} }
bool QmlCommerce::installApp(const QString& itemHref) { bool QmlCommerce::installApp(const QString& itemHref, const bool& alsoOpenImmediately) {
if (!QDir(_appsPath).exists()) { if (!QDir(_appsPath).exists()) {
if (!QDir().mkdir(_appsPath)) { if (!QDir().mkdir(_appsPath)) {
qCDebug(commerce) << "Couldn't make _appsPath directory."; qCDebug(commerce) << "Couldn't make _appsPath directory.";
@ -325,8 +325,8 @@ bool QmlCommerce::installApp(const QString& itemHref) {
QUrl appHref(itemHref); QUrl appHref(itemHref);
auto request = DependencyManager::get<ResourceManager>()->createResourceRequest( auto request =
this, appHref, true, -1, "QmlCommerce::installApp"); DependencyManager::get<ResourceManager>()->createResourceRequest(this, appHref, true, -1, "QmlCommerce::installApp");
if (!request) { if (!request) {
qCDebug(commerce) << "Couldn't create resource request for app."; qCDebug(commerce) << "Couldn't create resource request for app.";
@ -358,6 +358,9 @@ bool QmlCommerce::installApp(const QString& itemHref) {
QJsonObject appFileJsonObject = appFileJsonDocument.object(); QJsonObject appFileJsonObject = appFileJsonDocument.object();
QString scriptUrl = appFileJsonObject["scriptURL"].toString(); QString scriptUrl = appFileJsonObject["scriptURL"].toString();
// Don't try to re-load (install) a script if it's already running
QStringList runningScripts = DependencyManager::get<ScriptEngines>()->getRunningScripts();
if (!runningScripts.contains(scriptUrl)) {
if ((DependencyManager::get<ScriptEngines>()->loadScript(scriptUrl.trimmed())).isNull()) { if ((DependencyManager::get<ScriptEngines>()->loadScript(scriptUrl.trimmed())).isNull()) {
qCDebug(commerce) << "Couldn't load script."; qCDebug(commerce) << "Couldn't load script.";
return false; return false;
@ -365,6 +368,12 @@ bool QmlCommerce::installApp(const QString& itemHref) {
QFileInfo appFileInfo(appFile); QFileInfo appFileInfo(appFile);
emit appInstalled(appFileInfo.baseName()); emit appInstalled(appFileInfo.baseName());
}
if (alsoOpenImmediately) {
QmlCommerce::openApp(itemHref);
}
return true; return true;
}); });
request->send(); request->send();

View file

@ -88,7 +88,7 @@ protected:
Q_INVOKABLE void replaceContentSet(const QString& itemHref, const QString& certificateID); Q_INVOKABLE void replaceContentSet(const QString& itemHref, const QString& certificateID);
Q_INVOKABLE QString getInstalledApps(const QString& justInstalledAppID = ""); Q_INVOKABLE QString getInstalledApps(const QString& justInstalledAppID = "");
Q_INVOKABLE bool installApp(const QString& appHref); Q_INVOKABLE bool installApp(const QString& appHref, const bool& alsoOpenImmediately = false);
Q_INVOKABLE bool uninstallApp(const QString& appHref); Q_INVOKABLE bool uninstallApp(const QString& appHref);
Q_INVOKABLE bool openApp(const QString& appHref); Q_INVOKABLE bool openApp(const QString& appHref);

View file

@ -46,17 +46,11 @@ bool ClipboardScriptingInterface::exportEntities(const QString& filename, float
return retVal; return retVal;
} }
bool ClipboardScriptingInterface::importEntities( bool ClipboardScriptingInterface::importEntities(const QString& filename) {
const QString& filename,
const bool isObservable,
const qint64 callerId
) {
bool retVal; bool retVal;
BLOCKING_INVOKE_METHOD(qApp, "importEntities", BLOCKING_INVOKE_METHOD(qApp, "importEntities",
Q_RETURN_ARG(bool, retVal), Q_RETURN_ARG(bool, retVal),
Q_ARG(const QString&, filename), Q_ARG(const QString&, filename));
Q_ARG(const bool, isObservable),
Q_ARG(const qint64, callerId));
return retVal; return retVal;
} }

View file

@ -52,28 +52,31 @@ var NO_PERMISSIONS_ERROR_MESSAGE = "Cannot download model because you can't writ
var resourceRequestEvents = []; var resourceRequestEvents = [];
function signalResourceRequestEvent(data) { function signalResourceRequestEvent(data) {
// Once we can tie resource request events to specific resources,
// we will have to update the "0" in here.
resourceObjectsInTest[0].resourceAccessEventText += "[" + data.date.toISOString() + "] " +
data.url.toString().replace("__NONE__,", "") + "\n";
ui.tablet.sendToQml({ ui.tablet.sendToQml({
method: "resourceRequestEvent", method: "resourceRequestEvent",
data: data }); data: data,
resourceAccessEventText: resourceObjectsInTest[0].resourceAccessEventText
});
} }
function onResourceRequestEvent(data) { function onResourceRequestEvent(data) {
// Once we can tie resource request events to specific resources,
// we will have to update the "0" in here.
if (resourceObjectsInTest[0] && resourceObjectsInTest[0].currentlyRecordingResources) {
var resourceRequestEvent = { var resourceRequestEvent = {
"date": JSON.stringify(new Date()), "date": new Date(),
"url": data.url, "url": data.url,
"callerId": data.callerId, "callerId": data.callerId,
"extra": data.extra }; "extra": data.extra
};
resourceRequestEvents.push(resourceRequestEvent); resourceRequestEvents.push(resourceRequestEvent);
signalResourceRequestEvent(resourceRequestEvent); signalResourceRequestEvent(resourceRequestEvent);
} }
function pushResourceRequestEvents() {
var length = resourceRequestEvents.length
for (var i = 0; i < length; i++) {
if (i in resourceRequestEvents) {
signalResourceRequestEvent(resourceRequestEvents[i]);
}
}
} }
function onMessageBoxClosed(id, button) { function onMessageBoxClosed(id, button) {
@ -849,7 +852,8 @@ var resourceObjectsInTest = [];
function signalNewResourceObjectInTest(resourceObject) { function signalNewResourceObjectInTest(resourceObject) {
ui.tablet.sendToQml({ ui.tablet.sendToQml({
method: "newResourceObjectInTest", method: "newResourceObjectInTest",
resourceObject: resourceObject }); resourceObject: resourceObject
});
} }
var onQmlMessageReceived = function onQmlMessageReceived(message) { var onQmlMessageReceived = function onQmlMessageReceived(message) {
@ -915,6 +919,9 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
break; break;
case 'tester_newResourceObject': case 'tester_newResourceObject':
var resourceObject = message.resourceObject; var resourceObject = message.resourceObject;
resourceObjectsInTest = []; // REMOVE THIS once we support specific referrers
resourceObject.currentlyRecordingResources = false;
resourceObject.resourceAccessEventText = "";
resourceObjectsInTest[resourceObject.resourceObjectId] = resourceObject; resourceObjectsInTest[resourceObject.resourceObjectId] = resourceObject;
signalNewResourceObjectInTest(resourceObject); signalNewResourceObjectInTest(resourceObject);
break; break;
@ -924,6 +931,12 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
case 'tester_deleteResourceObject': case 'tester_deleteResourceObject':
delete resourceObjectsInTest[message.objectId]; delete resourceObjectsInTest[message.objectId];
break; break;
case 'tester_updateResourceRecordingStatus':
resourceObjectsInTest[message.objectId].currentlyRecordingResources = message.status;
if (message.status) {
resourceObjectsInTest[message.objectId].resourceAccessEventText = "";
}
break;
case 'header_marketplaceImageClicked': case 'header_marketplaceImageClicked':
case 'purchases_backClicked': case 'purchases_backClicked':
openMarketplace(message.referrerURL); openMarketplace(message.referrerURL);
@ -1076,7 +1089,9 @@ function pushResourceObjectsInTest() {
// that the marketplace item tester QML has heard from us, at least // that the marketplace item tester QML has heard from us, at least
// so that it can indicate to the user that all of the resoruce // so that it can indicate to the user that all of the resoruce
// objects in test have been transmitted to it. // objects in test have been transmitted to it.
ui.tablet.sendToQml({ method: "nextObjectIdInTest", id: maxResourceObjectId + 1 }); //ui.tablet.sendToQml({ method: "nextObjectIdInTest", id: maxResourceObjectId + 1 });
// Since, for now, we only support 1 object in test, always send id: 0
ui.tablet.sendToQml({ method: "nextObjectIdInTest", id: 0 });
} }
// Function Name: onTabletScreenChanged() // Function Name: onTabletScreenChanged()
@ -1165,7 +1180,6 @@ var onTabletScreenChanged = function onTabletScreenChanged(type, url) {
// variable amount of time to come up, in practice less than // variable amount of time to come up, in practice less than
// 750ms. // 750ms.
Script.setTimeout(pushResourceObjectsInTest, 750); Script.setTimeout(pushResourceObjectsInTest, 750);
Script.setTimeout(pushResourceRequestEvents, 750);
} }
console.debug(ui.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type + console.debug(ui.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type +