From 194226103c5cabc1a6bd5e9129b5188a3d90d570 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 1 Apr 2016 11:13:59 -0700 Subject: [PATCH 1/4] refresh the Asset Browser when switching domains --- interface/resources/qml/AssetServer.qml | 6 ++++- interface/src/Application.cpp | 25 ++++++++++++++++--- .../AssetMappingsScriptingInterface.cpp | 14 +++++++++++ .../AssetMappingsScriptingInterface.h | 4 ++- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index 37291480b2..bcbd2a87e3 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -21,7 +21,7 @@ import "dialogs" Window { id: root objectName: "AssetServer" - title: "My Asset Server" + title: "Asset Browser" resizable: true destroyOnInvisible: true x: 40; y: 40 @@ -125,6 +125,10 @@ Window { }, false); } + function clear() { + Assets.mappingModel.clear(); + } + function reload() { Assets.mappingModel.refresh(); treeView.selection.clear(); diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ffc9b0333c..4b924d4095 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4121,6 +4121,16 @@ void Application::nodeAdded(SharedNodePointer node) { if (node->getType() == NodeType::AvatarMixer) { // new avatar mixer, send off our identity packet right away getMyAvatar()->sendIdentityPacket(); + } else if (node->getType() == NodeType::AssetServer) { + // asset server just connected - check if we have the asset browser showing + + auto offscreenUi = DependencyManager::get(); + auto assetDialog = offscreenUi->getRootItem()->findChild("AssetServer"); + + if (assetDialog) { + // call reload on the shown asset browser dialog to get the mappings (if permissions allow) + QMetaObject::invokeMethod(assetDialog, "reload"); + } } } @@ -4136,10 +4146,7 @@ void Application::nodeKilled(SharedNodePointer node) { if (node->getType() == NodeType::AudioMixer) { QMetaObject::invokeMethod(DependencyManager::get().data(), "audioMixerKilled"); - } - - if (node->getType() == NodeType::EntityServer) { - + } else if (node->getType() == NodeType::EntityServer) { QUuid nodeUUID = node->getUUID(); // see if this is the first we've heard of this node... _entityServerJurisdictions.withReadLock([&] { @@ -4170,6 +4177,16 @@ void Application::nodeKilled(SharedNodePointer node) { } else if (node->getType() == NodeType::AvatarMixer) { // our avatar mixer has gone away - clear the hash of avatars DependencyManager::get()->clearOtherAvatars(); + } else if (node->getType() == NodeType::AssetServer) { + // asset server going away - check if we have the asset browser showing + + auto offscreenUi = DependencyManager::get(); + auto assetDialog = offscreenUi->getRootItem()->findChild("AssetServer"); + + if (assetDialog) { + // call reload on the shown asset browser dialog + QMetaObject::invokeMethod(assetDialog, "clear"); + } } } void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) { diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.cpp b/interface/src/scripting/AssetMappingsScriptingInterface.cpp index 005f8a597c..3f11bd1fd8 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.cpp +++ b/interface/src/scripting/AssetMappingsScriptingInterface.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -20,6 +21,19 @@ #include #include +void AssetMappingModel::clear() { + // make sure we are on the same thread before we touch the hash + if (thread() != QThread::currentThread()) { + QMetaObject::invokeMethod(this, "clear"); + return; + } + + qDebug() << "Clearing loaded asset mappings for Asset Browser"; + + _pathToItemMap.clear(); + QStandardItemModel::clear(); +} + AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() { _proxyModel.setSourceModel(&_assetMappingModel); _proxyModel.setSortRole(Qt::DisplayRole); diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.h b/interface/src/scripting/AssetMappingsScriptingInterface.h index 831b30513a..459f01b512 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.h +++ b/interface/src/scripting/AssetMappingsScriptingInterface.h @@ -21,7 +21,6 @@ #include - class AssetMappingModel : public QStandardItemModel { Q_OBJECT public: @@ -30,6 +29,9 @@ public: bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); } bool isKnownFolder(QString path) const; +public slots: + void clear(); + signals: void errorGettingMappings(QString errorString); From 459cbebcee18b208a74b54731d57a06e16ef7463 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 1 Apr 2016 11:15:32 -0700 Subject: [PATCH 2/4] don't show the My Asset Server option beside Reload All Content --- interface/src/Menu.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 63c67f6b9f..12cec7b383 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -137,16 +137,15 @@ Menu::Menu() { QObject::connect(nodeList.data(), &NodeList::canRezChanged, assetServerAction, &QAction::setEnabled); assetServerAction->setEnabled(nodeList->getThisNodeCanRez()); - // Edit > Reload All Content [advanced] - addActionToQMenuAndActionHash(editMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()), - QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); - - // Edit > Package Model... [advanced] addActionToQMenuAndActionHash(editMenu, MenuOption::PackageModel, 0, qApp, SLOT(packageModel()), QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); + // Edit > Reload All Content [advanced] + addActionToQMenuAndActionHash(editMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()), + QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); + // Audio menu ---------------------------------- MenuWrapper* audioMenu = addMenu("Audio"); From ee7bee95f8a94e67ff596c5bdbe81426248ff2ed Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 1 Apr 2016 11:35:33 -0700 Subject: [PATCH 3/4] use nodeActivated to trigger refresh of Asset Browser --- interface/src/Application.cpp | 18 +++++++++++++++--- interface/src/Application.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 4b924d4095..ea02589f69 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -680,6 +680,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled); + connect(nodeList.data(), &NodeList::nodeActivated, this, &Application::nodeActivated); connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID); connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID); connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); @@ -4121,15 +4122,26 @@ void Application::nodeAdded(SharedNodePointer node) { if (node->getType() == NodeType::AvatarMixer) { // new avatar mixer, send off our identity packet right away getMyAvatar()->sendIdentityPacket(); - } else if (node->getType() == NodeType::AssetServer) { + } +} + +void Application::nodeActivated(SharedNodePointer node) { + if (node->getType() == NodeType::AssetServer) { // asset server just connected - check if we have the asset browser showing auto offscreenUi = DependencyManager::get(); auto assetDialog = offscreenUi->getRootItem()->findChild("AssetServer"); if (assetDialog) { - // call reload on the shown asset browser dialog to get the mappings (if permissions allow) - QMetaObject::invokeMethod(assetDialog, "reload"); + auto nodeList = DependencyManager::get(); + + if (nodeList->getThisNodeCanRez()) { + // call reload on the shown asset browser dialog to get the mappings (if permissions allow) + QMetaObject::invokeMethod(assetDialog, "reload"); + } else { + // we switched to an Asset Server that we can't modify, hide the Asset Browser + assetDialog->setVisible(false); + } } } } diff --git a/interface/src/Application.h b/interface/src/Application.h index 31c865ad90..086b1062c1 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -312,6 +312,7 @@ private slots: void domainChanged(const QString& domainHostname); void updateWindowTitle(); void nodeAdded(SharedNodePointer node); + void nodeActivated(SharedNodePointer node); void nodeKilled(SharedNodePointer node); void packetSent(quint64 length); void updateDisplayMode(); From 309d327a3789239f285d492fdfc3875c30d0c879 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 1 Apr 2016 13:02:26 -0700 Subject: [PATCH 4/4] change My Asset Server to Asset Browser in Menu --- interface/src/Menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 361271b7c8..3488f03b0e 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -34,7 +34,7 @@ namespace MenuOption { const QString AnimDebugDrawDefaultPose = "Debug Draw Default Pose"; const QString AnimDebugDrawPosition= "Debug Draw Position"; const QString AssetMigration = "ATP Asset Migration"; - const QString AssetServer = "My Asset Server"; + const QString AssetServer = "Asset Browser"; const QString Attachments = "Attachments..."; const QString AudioNetworkStats = "Audio Network Stats"; const QString AudioNoiseReduction = "Audio Noise Reduction";