From a3d64dbd9c360d15fe53e706fde540db1ca83097 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Fri, 19 Aug 2016 14:14:31 -0700 Subject: [PATCH 1/2] code cleanup --- interface/resources/qml/AddressBarDialog.qml | 3 +-- interface/src/Application.h | 2 +- interface/src/scripting/WindowScriptingInterface.h | 2 +- interface/src/ui/AddressBarDialog.h | 5 ++++- interface/src/ui/Snapshot.cpp | 10 ++++------ .../html/{ShareSnapshot.html => SnapshotReview.html} | 0 scripts/system/snapshot.js | 10 ++++------ 7 files changed, 15 insertions(+), 17 deletions(-) rename scripts/system/html/{ShareSnapshot.html => SnapshotReview.html} (100%) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index 089bec07f4..b61b4111d6 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -73,8 +73,7 @@ Window { property var allStories: []; property int cardWidth: 200; property int cardHeight: 152; - property string metaverseBase: "https://metaverse.highfidelity.com/api/v1/"; - //property string metaverseBase: "http://10.0.0.241:3000/api/v1/"; + property string metaverseBase: addressBarDialog.metaverseServerUrl + "/api/v1/"; property bool useHTML: false; // fixme: remove this and all false branches after the server is updated AddressBarDialog { diff --git a/interface/src/Application.h b/interface/src/Application.h index 667969abf1..0ce1aac566 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -266,7 +266,7 @@ signals: void activeDisplayPluginChanged(); void uploadRequest(QString path); - void receivedHifiSchemeURL(QString path); + void receivedHifiSchemeURL(const QString& url); public slots: QVector pasteEntities(float x, float y, float z); diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index ca82753598..7a01be7fac 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -63,7 +63,7 @@ signals: void svoImportRequested(const QString& url); void domainConnectionRefused(const QString& reasonMessage, int reasonCode); void snapshotTaken(const QString& path, bool notify); - void snapshotShared(bool success); + void snapshotShared(const QString& error); private slots: WebWindowClass* doCreateWebWindow(const QString& title, const QString& url, int width, int height); diff --git a/interface/src/ui/AddressBarDialog.h b/interface/src/ui/AddressBarDialog.h index 68a12d4eb0..3197770433 100644 --- a/interface/src/ui/AddressBarDialog.h +++ b/interface/src/ui/AddressBarDialog.h @@ -14,6 +14,7 @@ #define hifi_AddressBarDialog_h #include +#include class AddressBarDialog : public OffscreenQmlDialog { Q_OBJECT @@ -21,6 +22,7 @@ class AddressBarDialog : public OffscreenQmlDialog { Q_PROPERTY(bool backEnabled READ backEnabled NOTIFY backEnabledChanged) Q_PROPERTY(bool forwardEnabled READ forwardEnabled NOTIFY forwardEnabledChanged) Q_PROPERTY(bool useFeed READ useFeed WRITE setUseFeed NOTIFY useFeedChanged) + Q_PROPERTY(QString metaverseServerUrl READ metaverseServerUrl) public: AddressBarDialog(QQuickItem* parent = nullptr); @@ -28,12 +30,13 @@ public: bool forwardEnabled() { return _forwardEnabled; } bool useFeed() { return _useFeed; } void setUseFeed(bool useFeed) { if (_useFeed != useFeed) { _useFeed = useFeed; emit useFeedChanged(); } } + QString metaverseServerUrl() { return NetworkingConstants::METAVERSE_SERVER_URL.toString(); } signals: void backEnabledChanged(); void forwardEnabledChanged(); void useFeedChanged(); - void receivedHifiSchemeURL(QString url); + void receivedHifiSchemeURL(const QString& url); protected: void displayAddressOfflineMessage(); diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index b7cdb1a126..4513894f5a 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -215,20 +215,18 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) { QJsonDocument(rootObject).toJson()); } else { - emit DependencyManager::get()->snapshotShared(false); + emit DependencyManager::get()->snapshotShared(contents); } } void SnapshotUploader::uploadFailure(QNetworkReply& reply) { - // TODO: parse response, potentially helpful for logging (?) - emit DependencyManager::get()->snapshotShared(false); + emit DependencyManager::get()->snapshotShared(reply.readAll()); } void SnapshotUploader::createStorySuccess(QNetworkReply& reply) { - emit DependencyManager::get()->snapshotShared(true); + emit DependencyManager::get()->snapshotShared(""); } void SnapshotUploader::createStoryFailure(QNetworkReply& reply) { - // TODO: parse response, potentially helpful for logging (?) - emit DependencyManager::get()->snapshotShared(false); + emit DependencyManager::get()->snapshotShared(reply.readAll()); } diff --git a/scripts/system/html/ShareSnapshot.html b/scripts/system/html/SnapshotReview.html similarity index 100% rename from scripts/system/html/ShareSnapshot.html rename to scripts/system/html/SnapshotReview.html diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 5c893fad4a..fab26a70e6 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -30,7 +30,7 @@ function showFeedWindow() { var outstanding; function confirmShare(data) { - var dialog = new OverlayWebWindow('Snapshot Review', Script.resolvePath("html/ShareSnapshot.html"), 800, 470); + var dialog = new OverlayWebWindow('Snapshot Review', Script.resolvePath("html/SnapshotReview.html"), 800, 470); function onMessage(message) { // Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following: // 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.) @@ -82,13 +82,11 @@ function confirmShare(data) { dialog.raise(); } -function snapshotShared(success) { - if (success) { - // for now just print status +function snapshotShared(errorMessage) { + if (!errorMessage) { print('snapshot uploaded and shared'); } else { - // for now just print an error. - print('snapshot upload/share failed'); + print(errorMessage); } if ((--outstanding <= 0) && shouldOpenFeedAfterShare()) { showFeedWindow(); From 1e08914f8d608e790dabcddabccc520bb705d143 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Fri, 19 Aug 2016 14:32:15 -0700 Subject: [PATCH 2/2] simplify --- scripts/system/snapshot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index fab26a70e6..9ce3cb366e 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -137,7 +137,7 @@ function resetButtons(path, notify) { confirmShare([ { localPath: path }, { - canShare: Boolean(Window.location.placename), + canShare: Boolean(location.placename), isLoggedIn: true, // Just have the dialog act as though we are. To be removed at both ends later. openFeedAfterShare: shouldOpenFeedAfterShare() }