mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 09:53:11 +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 SVO_EXTENSION = ".svo";
|
||||
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 JS_EXTENSION = ".js";
|
||||
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";
|
||||
|
||||
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
||||
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions{
|
||||
{ SVO_EXTENSION, &Application::importSVOFromURL },
|
||||
{ SVO_JSON_EXTENSION, &Application::importSVOFromURL },
|
||||
{ AVA_JSON_EXTENSION, &Application::askToWearAvatarAttachmentUrl },
|
||||
{ JSON_EXTENSION, &Application::importJSONFromURL },
|
||||
{ JS_EXTENSION, &Application::askToLoadScript },
|
||||
{ FST_EXTENSION, &Application::askToSetAvatarUrl }
|
||||
{ FST_EXTENSION, &Application::askToSetAvatarUrl },
|
||||
{ JSON_GZ_EXTENSION, &Application::askToReplaceDomainContent }
|
||||
};
|
||||
|
||||
class DeadlockWatchdogThread : public QThread {
|
||||
|
@ -2724,7 +2726,6 @@ void Application::handleSandboxStatus(QNetworkReply* reply) {
|
|||
bool Application::importJSONFromURL(const QString& urlString) {
|
||||
// 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
|
||||
|
||||
QUrl jsonURL { urlString };
|
||||
|
||||
if (jsonURL.host().endsWith(MARKETPLACE_CDN_HOSTNAME)) {
|
||||
|
@ -6036,6 +6037,41 @@ bool Application::askToWearAvatarAttachmentUrl(const QString& url) {
|
|||
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 {
|
||||
auto avatarAttachmentWarningTitle = tr("Avatar Attachment Failure");
|
||||
OffscreenUi::warning(avatarAttachmentWarningTitle, message);
|
||||
|
|
|
@ -311,6 +311,8 @@ signals:
|
|||
void uploadRequest(QString path);
|
||||
void receivedHifiSchemeURL(const QString& url);
|
||||
|
||||
void requestDomainContentReplacement(const QString& url);
|
||||
|
||||
public slots:
|
||||
QVector<EntityItemID> pasteEntities(float x, float y, float z);
|
||||
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;
|
||||
bool displayAvatarAttachmentConfirmationDialog(const QString& name) const;
|
||||
|
||||
bool askToReplaceDomainContent(const QString& url);
|
||||
|
||||
void setSessionUUID(const QUuid& sessionUUID) const;
|
||||
|
||||
void domainChanged(const QString& domainHostname);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "DomainManagementScriptingInterface.h"
|
||||
#include "EntitiesLogging.h"
|
||||
#include "Application.h"
|
||||
#include "OffscreenUi.h"
|
||||
|
||||
DomainManagementScriptingInterface::DomainManagementScriptingInterface()
|
||||
{
|
||||
|
@ -28,18 +29,6 @@ bool DomainManagementScriptingInterface::canReplaceDomainContent() {
|
|||
return nodeList->getThisNodeCanReplaceContent();
|
||||
}
|
||||
|
||||
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";
|
||||
void DomainManagementScriptingInterface::replaceDomainContentSet(const QString& url){
|
||||
|
||||
limitedNodeList->sendPacketList(std::move(octreeFilePacketList), *octreeNode);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,7 +31,9 @@ public:
|
|||
|
||||
public slots:
|
||||
Q_INVOKABLE bool canReplaceDomainContent();
|
||||
Q_INVOKABLE void replaceDomainContentSet(const QString fileURL);
|
||||
|
||||
protected:
|
||||
void replaceDomainContentSet(const QString& fileURL);
|
||||
|
||||
signals:
|
||||
void canReplaceDomainContentChanged(bool canReplaceDomainContent);
|
||||
|
|
Loading…
Reference in a new issue