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

refresh/close the asset browser dialog on domain switch
This commit is contained in:
Seth Alves 2016-04-01 18:08:59 -07:00
commit 5fa9f662fc
7 changed files with 61 additions and 12 deletions

View file

@ -21,7 +21,7 @@ import "dialogs"
Window { Window {
id: root id: root
objectName: "AssetServer" objectName: "AssetServer"
title: "My Asset Server" title: "Asset Browser"
resizable: true resizable: true
destroyOnInvisible: true destroyOnInvisible: true
x: 40; y: 40 x: 40; y: 40
@ -125,6 +125,10 @@ Window {
}, false); }, false);
} }
function clear() {
Assets.mappingModel.clear();
}
function reload() { function reload() {
Assets.mappingModel.refresh(); Assets.mappingModel.refresh();
treeView.selection.clear(); treeView.selection.clear();

View file

@ -680,6 +680,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded); connect(nodeList.data(), &NodeList::nodeAdded, this, &Application::nodeAdded);
connect(nodeList.data(), &NodeList::nodeKilled, this, &Application::nodeKilled); 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, getMyAvatar(), &MyAvatar::setSessionUUID);
connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID); connect(nodeList.data(), &NodeList::uuidChanged, this, &Application::setSessionUUID);
connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset); connect(nodeList.data(), &NodeList::limitOfSilentDomainCheckInsReached, nodeList.data(), &NodeList::reset);
@ -4143,6 +4144,27 @@ void Application::nodeAdded(SharedNodePointer node) {
} }
} }
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<OffscreenUi>();
auto assetDialog = offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer");
if (assetDialog) {
auto nodeList = DependencyManager::get<NodeList>();
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);
}
}
}
}
void Application::nodeKilled(SharedNodePointer node) { void Application::nodeKilled(SharedNodePointer node) {
// These are here because connecting NodeList::nodeKilled to OctreePacketProcessor::nodeKilled doesn't work: // These are here because connecting NodeList::nodeKilled to OctreePacketProcessor::nodeKilled doesn't work:
@ -4155,10 +4177,7 @@ void Application::nodeKilled(SharedNodePointer node) {
if (node->getType() == NodeType::AudioMixer) { if (node->getType() == NodeType::AudioMixer) {
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled"); QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "audioMixerKilled");
} } else if (node->getType() == NodeType::EntityServer) {
if (node->getType() == NodeType::EntityServer) {
QUuid nodeUUID = node->getUUID(); QUuid nodeUUID = node->getUUID();
// see if this is the first we've heard of this node... // see if this is the first we've heard of this node...
_entityServerJurisdictions.withReadLock([&] { _entityServerJurisdictions.withReadLock([&] {
@ -4189,6 +4208,16 @@ void Application::nodeKilled(SharedNodePointer node) {
} else if (node->getType() == NodeType::AvatarMixer) { } else if (node->getType() == NodeType::AvatarMixer) {
// our avatar mixer has gone away - clear the hash of avatars // our avatar mixer has gone away - clear the hash of avatars
DependencyManager::get<AvatarManager>()->clearOtherAvatars(); DependencyManager::get<AvatarManager>()->clearOtherAvatars();
} else if (node->getType() == NodeType::AssetServer) {
// asset server going away - check if we have the asset browser showing
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto assetDialog = offscreenUi->getRootItem()->findChild<QQuickItem*>("AssetServer");
if (assetDialog) {
// call reload on the shown asset browser dialog
QMetaObject::invokeMethod(assetDialog, "clear");
}
} }
} }
void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) { void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) {

View file

@ -312,6 +312,7 @@ private slots:
void domainChanged(const QString& domainHostname); void domainChanged(const QString& domainHostname);
void updateWindowTitle(); void updateWindowTitle();
void nodeAdded(SharedNodePointer node); void nodeAdded(SharedNodePointer node);
void nodeActivated(SharedNodePointer node);
void nodeKilled(SharedNodePointer node); void nodeKilled(SharedNodePointer node);
void packetSent(quint64 length); void packetSent(quint64 length);
void updateDisplayMode(); void updateDisplayMode();

View file

@ -137,16 +137,15 @@ Menu::Menu() {
QObject::connect(nodeList.data(), &NodeList::canRezChanged, assetServerAction, &QAction::setEnabled); QObject::connect(nodeList.data(), &NodeList::canRezChanged, assetServerAction, &QAction::setEnabled);
assetServerAction->setEnabled(nodeList->getThisNodeCanRez()); 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] // Edit > Package Model... [advanced]
addActionToQMenuAndActionHash(editMenu, MenuOption::PackageModel, 0, addActionToQMenuAndActionHash(editMenu, MenuOption::PackageModel, 0,
qApp, SLOT(packageModel()), qApp, SLOT(packageModel()),
QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); 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 ---------------------------------- // Audio menu ----------------------------------
MenuWrapper* audioMenu = addMenu("Audio"); MenuWrapper* audioMenu = addMenu("Audio");

View file

@ -34,7 +34,7 @@ namespace MenuOption {
const QString AnimDebugDrawDefaultPose = "Debug Draw Default Pose"; const QString AnimDebugDrawDefaultPose = "Debug Draw Default Pose";
const QString AnimDebugDrawPosition= "Debug Draw Position"; const QString AnimDebugDrawPosition= "Debug Draw Position";
const QString AssetMigration = "ATP Asset Migration"; const QString AssetMigration = "ATP Asset Migration";
const QString AssetServer = "My Asset Server"; const QString AssetServer = "Asset Browser";
const QString Attachments = "Attachments..."; const QString Attachments = "Attachments...";
const QString AudioNetworkStats = "Audio Network Stats"; const QString AudioNetworkStats = "Audio Network Stats";
const QString AudioNoiseReduction = "Audio Noise Reduction"; const QString AudioNoiseReduction = "Audio Noise Reduction";

View file

@ -13,6 +13,7 @@
#include <QtScript/QScriptEngine> #include <QtScript/QScriptEngine>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QThread>
#include <AssetRequest.h> #include <AssetRequest.h>
#include <AssetUpload.h> #include <AssetUpload.h>
@ -20,6 +21,19 @@
#include <NetworkLogging.h> #include <NetworkLogging.h>
#include <OffscreenUi.h> #include <OffscreenUi.h>
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() { AssetMappingsScriptingInterface::AssetMappingsScriptingInterface() {
_proxyModel.setSourceModel(&_assetMappingModel); _proxyModel.setSourceModel(&_assetMappingModel);
_proxyModel.setSortRole(Qt::DisplayRole); _proxyModel.setSortRole(Qt::DisplayRole);

View file

@ -21,7 +21,6 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
class AssetMappingModel : public QStandardItemModel { class AssetMappingModel : public QStandardItemModel {
Q_OBJECT Q_OBJECT
public: public:
@ -30,6 +29,9 @@ public:
bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); } bool isKnownMapping(QString path) const { return _pathToItemMap.contains(path); }
bool isKnownFolder(QString path) const; bool isKnownFolder(QString path) const;
public slots:
void clear();
signals: signals:
void errorGettingMappings(QString errorString); void errorGettingMappings(QString errorString);