mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 01:30:18 +02:00
Add parameter that enables automatically adding download model to world
This commit is contained in:
parent
97407e1cd5
commit
12747d26e0
6 changed files with 26 additions and 8 deletions
|
@ -257,7 +257,7 @@ ScrollingWindow {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
desktop.initWebviewProfileHandlers(webview.profile)
|
||||
desktop.initWebviewProfileHandlers(webview.profile, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,10 +88,12 @@ OriginalDesktop.Desktop {
|
|||
property string currentUrl: ""
|
||||
property string adaptedPath: ""
|
||||
property string tempDir: ""
|
||||
property bool autoAdd: false
|
||||
|
||||
function initWebviewProfileHandlers(profile) {
|
||||
function initWebviewProfileHandlers(profile, auto) {
|
||||
console.log("The webview url in desktop is: " + currentUrl);
|
||||
if (webViewProfileSetup) return;
|
||||
autoAdd = auto;
|
||||
webViewProfileSetup = true;
|
||||
|
||||
profile.downloadRequested.connect(function(download){
|
||||
|
@ -109,7 +111,7 @@ OriginalDesktop.Desktop {
|
|||
|
||||
profile.downloadFinished.connect(function(download){
|
||||
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
|
||||
File.runUnzip(download.path, currentUrl);
|
||||
File.runUnzip(download.path, currentUrl, autoAdd);
|
||||
} else {
|
||||
console.log("The download was corrupted, state: " + download.state);
|
||||
}
|
||||
|
|
|
@ -1769,7 +1769,7 @@ void Application::initializeUi() {
|
|||
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||
FileScriptingInterface* fileDownload = new FileScriptingInterface(engine);
|
||||
rootContext->setContextProperty("File", fileDownload);
|
||||
connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::showAssetServerWidget);
|
||||
connect(fileDownload, &FileScriptingInterface::unzipSuccess, this, &Application::handleUnzip);
|
||||
rootContext->setContextProperty("MyAvatar", getMyAvatar().get());
|
||||
rootContext->setContextProperty("Messages", DependencyManager::get<MessagesClient>().data());
|
||||
rootContext->setContextProperty("Recording", DependencyManager::get<RecordingScriptingInterface>().data());
|
||||
|
@ -5330,6 +5330,20 @@ void Application::showAssetServerWidget(QString filePath) {
|
|||
startUpload(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void Application::addAssetToWorld(QString filePath) {
|
||||
// Automatically upload and add asset to world rather than proceeding manually per showAssetServerWidget().
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Application::handleUnzip(QString filePath, bool autoAdd) {
|
||||
if (autoAdd && !filePath.isEmpty()) {
|
||||
addAssetToWorld(filePath);
|
||||
} else {
|
||||
showAssetServerWidget(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
void Application::packageModel() {
|
||||
ModelPackager::package();
|
||||
}
|
||||
|
|
|
@ -306,6 +306,8 @@ public slots:
|
|||
void toggleLogDialog();
|
||||
void toggleRunningScriptsWidget() const;
|
||||
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
||||
void addAssetToWorld(QString filePath);
|
||||
void handleUnzip(QString filePath = "", bool autoAdd = false);
|
||||
|
||||
void handleLocalServerConnection() const;
|
||||
void readArgumentsFromLocalSocket() const;
|
||||
|
|
|
@ -31,7 +31,7 @@ FileScriptingInterface::FileScriptingInterface(QObject* parent) : QObject(parent
|
|||
// nothing for now
|
||||
}
|
||||
|
||||
void FileScriptingInterface::runUnzip(QString path, QUrl url) {
|
||||
void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd) {
|
||||
qDebug() << "Url that was downloaded: " + url.toString();
|
||||
qDebug() << "Path where download is saved: " + path;
|
||||
QString fileName = "/" + path.section("/", -1);
|
||||
|
@ -47,7 +47,7 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url) {
|
|||
if (file != "") {
|
||||
qDebug() << "Object file to upload: " + file;
|
||||
QUrl url = QUrl::fromLocalFile(file);
|
||||
emit unzipSuccess(url.toString());
|
||||
emit unzipSuccess(url.toString(), autoAdd);
|
||||
} else {
|
||||
qDebug() << "unzip failed";
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ public slots:
|
|||
bool isZipped(QUrl url);
|
||||
bool isClaraLink(QUrl url);
|
||||
QString convertUrlToPath(QUrl url);
|
||||
void runUnzip(QString path, QUrl url);
|
||||
void runUnzip(QString path, QUrl url, bool autoAdd);
|
||||
QString getTempDir();
|
||||
|
||||
signals:
|
||||
void unzipSuccess(QString url);
|
||||
void unzipSuccess(QString url, bool autoAdd);
|
||||
|
||||
private:
|
||||
bool isTempDir(QString tempDir);
|
||||
|
|
Loading…
Reference in a new issue