mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 01:07:09 +02:00
Move logic for confirmation into Application.cpp for handling files directly
This commit is contained in:
parent
76cc833747
commit
32ddffd9c8
4 changed files with 48 additions and 17 deletions
|
@ -222,6 +222,7 @@ static const int MIN_PROCESSING_THREAD_POOL_SIZE = 1;
|
||||||
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
||||||
static const QString SVO_EXTENSION = ".svo";
|
static const QString SVO_EXTENSION = ".svo";
|
||||||
static const QString SVO_JSON_EXTENSION = ".svo.json";
|
static const QString SVO_JSON_EXTENSION = ".svo.json";
|
||||||
|
static const QString JSON_GZ_EXTENSION = ".json.gz";
|
||||||
static const QString JSON_EXTENSION = ".json";
|
static const QString JSON_EXTENSION = ".json";
|
||||||
static const QString JS_EXTENSION = ".js";
|
static const QString JS_EXTENSION = ".js";
|
||||||
static const QString FST_EXTENSION = ".fst";
|
static const QString FST_EXTENSION = ".fst";
|
||||||
|
@ -254,13 +255,14 @@ static const QString DESKTOP_DISPLAY_PLUGIN_NAME = "Desktop";
|
||||||
|
|
||||||
static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
|
static const QString SYSTEM_TABLET = "com.highfidelity.interface.tablet.system";
|
||||||
|
|
||||||
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions{
|
||||||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||||
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
||||||
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
||||||
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
||||||
{ JS_EXTENSION, &Application::askToLoadScript },
|
{ JS_EXTENSION, &Application::askToLoadScript },
|
||||||
{ FST_EXTENSION, &Application::askToSetAvatarUrl }
|
{ FST_EXTENSION, &Application::askToSetAvatarUrl },
|
||||||
|
{ JSON_GZ_EXTENSION, &Application::askToReplaceDomainContent }
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeadlockWatchdogThread : public QThread {
|
class DeadlockWatchdogThread : public QThread {
|
||||||
|
@ -2724,7 +2726,6 @@ void Application::handleSandboxStatus(QNetworkReply* reply) {
|
||||||
bool Application::importJSONFromURL(const QString& urlString) {
|
bool Application::importJSONFromURL(const QString& urlString) {
|
||||||
// we only load files that terminate in just .json (not .svo.json and not .ava.json)
|
// we only load files that terminate in just .json (not .svo.json and not .ava.json)
|
||||||
// if they come from the High Fidelity Marketplace Assets CDN
|
// if they come from the High Fidelity Marketplace Assets CDN
|
||||||
|
|
||||||
QUrl jsonURL { urlString };
|
QUrl jsonURL { urlString };
|
||||||
|
|
||||||
if (jsonURL.host().endsWith(MARKETPLACE_CDN_HOSTNAME)) {
|
if (jsonURL.host().endsWith(MARKETPLACE_CDN_HOSTNAME)) {
|
||||||
|
@ -6036,6 +6037,41 @@ bool Application::askToWearAvatarAttachmentUrl(const QString& url) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Application::askToReplaceDomainContent(const QString& url) {
|
||||||
|
|
||||||
|
if (DependencyManager::get<NodeList>()->getThisNodeCanReplaceContent()) {
|
||||||
|
// Create a confirmation dialog when this call is made
|
||||||
|
static const QString infoText = "Your domain's content will be replaced but backup files of your "
|
||||||
|
"domain's content will not immediately be changed.\n Save a manual backup of your"
|
||||||
|
"models.json.gz file, usually stored at:\n"
|
||||||
|
"C:/Users/[username]/AppData/Roaming/High Fidelity/assignment-client/entities/models.json.gz";
|
||||||
|
|
||||||
|
bool agreeToReplaceContent = false; // assume false
|
||||||
|
agreeToReplaceContent = QMessageBox::Yes == OffscreenUi::question("Are you sure you want to replace this domain's content set?",
|
||||||
|
infoText, QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
|
||||||
|
|
||||||
|
if (agreeToReplaceContent) {
|
||||||
|
// Given confirmation, send request to domain server to replace content
|
||||||
|
QByteArray _url(url.toUtf8());
|
||||||
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
limitedNodeList->eachMatchingNode([](const SharedNodePointer& node) {
|
||||||
|
return node->getType() == NodeType::EntityServer && node->getActiveSocket();
|
||||||
|
}, [&_url, limitedNodeList](const SharedNodePointer& octreeNode) {
|
||||||
|
auto octreeFilePacketList = NLPacketList::create(PacketType::OctreeFileReplacementFromUrl, QByteArray(), true, true);
|
||||||
|
octreeFilePacketList->write(_url);
|
||||||
|
qCDebug(entities) << "Attempting to send an octree file url to replace domain content";
|
||||||
|
|
||||||
|
limitedNodeList->sendPacketList(std::move(octreeFilePacketList), *octreeNode);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OffscreenUi::warning("Unable to replace content", "You do not have permissions to replace domain content", QMessageBox::Ok, QMessageBox::Ok);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Application::displayAvatarAttachmentWarning(const QString& message) const {
|
void Application::displayAvatarAttachmentWarning(const QString& message) const {
|
||||||
auto avatarAttachmentWarningTitle = tr("Avatar Attachment Failure");
|
auto avatarAttachmentWarningTitle = tr("Avatar Attachment Failure");
|
||||||
OffscreenUi::warning(avatarAttachmentWarningTitle, message);
|
OffscreenUi::warning(avatarAttachmentWarningTitle, message);
|
||||||
|
|
|
@ -311,6 +311,8 @@ signals:
|
||||||
void uploadRequest(QString path);
|
void uploadRequest(QString path);
|
||||||
void receivedHifiSchemeURL(const QString& url);
|
void receivedHifiSchemeURL(const QString& url);
|
||||||
|
|
||||||
|
void requestDomainContentReplacement(const QString& url);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||||
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs, const glm::vec3* givenOffset = nullptr);
|
||||||
|
@ -426,6 +428,8 @@ private slots:
|
||||||
void displayAvatarAttachmentWarning(const QString& message) const;
|
void displayAvatarAttachmentWarning(const QString& message) const;
|
||||||
bool displayAvatarAttachmentConfirmationDialog(const QString& name) const;
|
bool displayAvatarAttachmentConfirmationDialog(const QString& name) const;
|
||||||
|
|
||||||
|
bool askToReplaceDomainContent(const QString& url);
|
||||||
|
|
||||||
void setSessionUUID(const QUuid& sessionUUID) const;
|
void setSessionUUID(const QUuid& sessionUUID) const;
|
||||||
|
|
||||||
void domainChanged(const QString& domainHostname);
|
void domainChanged(const QString& domainHostname);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "DomainManagementScriptingInterface.h"
|
#include "DomainManagementScriptingInterface.h"
|
||||||
#include "EntitiesLogging.h"
|
#include "EntitiesLogging.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "OffscreenUi.h"
|
||||||
|
|
||||||
DomainManagementScriptingInterface::DomainManagementScriptingInterface()
|
DomainManagementScriptingInterface::DomainManagementScriptingInterface()
|
||||||
{
|
{
|
||||||
|
@ -28,18 +29,6 @@ bool DomainManagementScriptingInterface::canReplaceDomainContent() {
|
||||||
return nodeList->getThisNodeCanReplaceContent();
|
return nodeList->getThisNodeCanReplaceContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainManagementScriptingInterface::replaceDomainContentSet(const QString url){
|
void DomainManagementScriptingInterface::replaceDomainContentSet(const QString& url){
|
||||||
if (DependencyManager::get<NodeList>()->getThisNodeCanReplaceContent()) {
|
|
||||||
QByteArray _url(url.toUtf8());
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
|
||||||
limitedNodeList->eachMatchingNode([](const SharedNodePointer& node) {
|
|
||||||
return node->getType() == NodeType::EntityServer && node->getActiveSocket();
|
|
||||||
}, [&_url, limitedNodeList](const SharedNodePointer& octreeNode) {
|
|
||||||
auto octreeFilePacketList = NLPacketList::create(PacketType::OctreeFileReplacementFromUrl, QByteArray(), true, true);
|
|
||||||
octreeFilePacketList->write(_url);
|
|
||||||
qCDebug(entities) << "Attempting to send an octree file url to replace domain content";
|
|
||||||
|
|
||||||
limitedNodeList->sendPacketList(std::move(octreeFilePacketList), *octreeNode);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
Q_INVOKABLE bool canReplaceDomainContent();
|
Q_INVOKABLE bool canReplaceDomainContent();
|
||||||
Q_INVOKABLE void replaceDomainContentSet(const QString fileURL);
|
|
||||||
|
protected:
|
||||||
|
void replaceDomainContentSet(const QString& fileURL);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void canReplaceDomainContentChanged(bool canReplaceDomainContent);
|
void canReplaceDomainContentChanged(bool canReplaceDomainContent);
|
||||||
|
|
Loading…
Reference in a new issue