History

Merge pull request #7542 from birarda/refresh-on-asset-connect

refresh/close the asset browser dialog on domain switch

Seth Alves committed 10 years ago

Commit 5fa9f662 parents 6025a66 309d3277 files · +61 −12Browse files

Showing the changes to interface/src/Application.cpp (1 of 7 files). Show all

Unified · Split

interface/src/Application.cpp+33−4
@@ -680,6 +680,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 679 unmodified lines
680680
681681 connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded);
682682 connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled);
683+ connect(nodeList.data(), &NodeList::nodeActivated, this, &Application::nodeActivated);
683684 connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID);
684685 connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID);
685686 connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
@@ -4143,6 +4144,27 @@ void Application::nodeAdded(SharedNodePointer node) { · 3457 unmodified lines
41434144 }
41444145 }
41454146
4147+void Application::nodeActivated(SharedNodePointer node) {
4148+ if (node->getType() == NodeType::AssetServer) {
4149+ // asset server just connected - check if we have the asset browser showing
4150+
4151+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
4152+ auto assetDialog = offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer");
4153+
4154+ if (assetDialog) {
4155+ auto nodeList = DependencyManager::get<NodeList>();
4156+
4157+ if (nodeList->getThisNodeCanRez()) {
4158+ // call reload on the shown asset browser dialog to get the mappings (if permissions allow)
4159+ QMetaObject::invokeMethod(assetDialog, "reload");
4160+ } else {
4161+ // we switched to an Asset Server that we can't modify, hide the Asset Browser
4162+ assetDialog->setVisible(false);
4163+ }
4164+ }
4165+ }
4166+}
4167+
41464168 void Application::nodeKilled(SharedNodePointer node) {
41474169
41484170 // These are here because connecting NodeList::nodeKilled to OctreePacketProcessor::nodeKilled doesn't work:
@@ -4155,10 +4177,7 @@ void Application::nodeKilled(SharedNodePointer node) { · 6 unmodified lines
41554177
41564178 if (node->getType() == NodeType::AudioMixer) {
41574179 QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled");
4158− }
4159−
4160− if (node->getType() == NodeType::EntityServer) {
4161−
4180+ } else if (node->getType() == NodeType::EntityServer) {
41624181 QUuid nodeUUID = node->getUUID();
41634182 // see if this is the first we've heard of this node...
41644183 _entityServerJurisdictions.withReadLock([&] {
@@ -4189,6 +4208,16 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines
41894208 } else if (node->getType() == NodeType::AvatarMixer) {
41904209 // our avatar mixer has gone away - clear the hash of avatars
41914210 DependencyManager::get<AvatarManager>()->clearOtherAvatars();
4211+ } else if (node->getType() == NodeType::AssetServer) {
4212+ // asset server going away - check if we have the asset browser showing
4213+
4214+ auto offscreenUi = DependencyManager::get<OffscreenUi>();
4215+ auto assetDialog = offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer");
4216+
4217+ if (assetDialog) {
4218+ // call reload on the shown asset browser dialog
4219+ QMetaObject::invokeMethod(assetDialog, "clear");
4220+ }
41924221 }
41934222 }
41944223 void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) {