refresh/close the asset browser dialog on domain switch
Showing the changes to interface/src/Application.cpp (1 of 7 files). Show all
Unified · Split
| @@ -680,6 +680,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : · 679 unmodified lines | ||
| 680 | 680 | |
| 681 | 681 | connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); |
| 682 | 682 | connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled); |
| 683 | + connect(nodeList.data(), &NodeList::nodeActivated, this, &Application::nodeActivated); | |
| 683 | 684 | connect(nodeList.data(), &NodeList::uuidChanged, getMyAvatar(), &MyAvatar::setSessionUUID); |
| 684 | 685 | connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID); |
| 685 | 686 | connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); |
| @@ -4143,6 +4144,27 @@ void Application::nodeAdded(SharedNodePointer node) { · 3457 unmodified lines | ||
| 4143 | 4144 | } |
| 4144 | 4145 | } |
| 4145 | 4146 | |
| 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 | + | |
| 4146 | 4168 | void Application::nodeKilled(SharedNodePointer node) { |
| 4147 | 4169 | |
| 4148 | 4170 | // 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 | ||
| 4155 | 4177 | |
| 4156 | 4178 | if (node->getType() == NodeType::AudioMixer) { |
| 4157 | 4179 | QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled"); |
| 4158 | − } | |
| 4159 | − | |
| 4160 | − if (node->getType() == NodeType::EntityServer) { | |
| 4161 | − | |
| 4180 | + } else if (node->getType() == NodeType::EntityServer) { | |
| 4162 | 4181 | QUuid nodeUUID = node->getUUID(); |
| 4163 | 4182 | // see if this is the first we've heard of this node... |
| 4164 | 4183 | _entityServerJurisdictions.withReadLock([&] { |
| @@ -4189,6 +4208,16 @@ void Application::nodeKilled(SharedNodePointer node) { · 24 unmodified lines | ||
| 4189 | 4208 | } else if (node->getType() == NodeType::AvatarMixer) { |
| 4190 | 4209 | // our avatar mixer has gone away - clear the hash of avatars |
| 4191 | 4210 | 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 | + } | |
| 4192 | 4221 | } |
| 4193 | 4222 | } |
| 4194 | 4223 | void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) { |