From c3c2a75f48184ee3011940fda6b8d86c19f95086 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Wed, 11 Mar 2015 15:38:15 -0700 Subject: [PATCH] Handle .svo drop events and emit svoImportRequested --- interface/src/Application.cpp | 10 ++++++++-- interface/src/Application.h | 3 +++ interface/src/GLCanvas.cpp | 3 ++- interface/src/scripting/WindowScriptingInterface.cpp | 1 + interface/src/scripting/WindowScriptingInterface.h | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1dde90aeaa..91b4cc5923 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -882,9 +882,15 @@ bool Application::event(QEvent* event) { if (event->type() == QEvent::FileOpen) { QFileOpenEvent* fileEvent = static_cast(event); + + QUrl url = fileEvent->url(); - if (!fileEvent->url().isEmpty()) { - DependencyManager::get()->handleLookupString(fileEvent->url().toString()); + if (!url.isEmpty()) { + if (url.scheme() == HIFI_URL_SCHEME) { + DependencyManager::get()->handleLookupString(fileEvent->url().toString()); + } else if (url.url().toLower().endsWith(SVO_EXTENSION)) { + emit svoImportRequested(url.url()); + } } return false; diff --git a/interface/src/Application.h b/interface/src/Application.h index d8d9132de9..262afac39a 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -94,6 +94,7 @@ static const float NODE_KILLED_GREEN = 0.0f; static const float NODE_KILLED_BLUE = 0.0f; static const QString SNAPSHOT_EXTENSION = ".jpg"; +static const QString SVO_EXTENSION = ".svo"; static const float BILLBOARD_FIELD_OF_VIEW = 30.0f; // degrees static const float BILLBOARD_DISTANCE = 5.56f; // meters @@ -315,6 +316,8 @@ signals: void scriptLocationChanged(const QString& newPath); + void svoImportRequested(const QString& url); + public slots: void domainChanged(const QString& domainHostname); void updateWindowTitle(); diff --git a/interface/src/GLCanvas.cpp b/interface/src/GLCanvas.cpp index b72c00c779..4ece8f0857 100644 --- a/interface/src/GLCanvas.cpp +++ b/interface/src/GLCanvas.cpp @@ -170,7 +170,8 @@ void GLCanvas::wheelEvent(QWheelEvent* event) { void GLCanvas::dragEnterEvent(QDragEnterEvent* event) { const QMimeData *mimeData = event->mimeData(); foreach (QUrl url, mimeData->urls()) { - if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) { + auto lower = url.url().toLower(); + if (lower.endsWith(SNAPSHOT_EXTENSION) || lower.endsWith(SVO_EXTENSION)) { event->acceptProposedAction(); break; } diff --git a/interface/src/scripting/WindowScriptingInterface.cpp b/interface/src/scripting/WindowScriptingInterface.cpp index d64c75c345..52de31df3c 100644 --- a/interface/src/scripting/WindowScriptingInterface.cpp +++ b/interface/src/scripting/WindowScriptingInterface.cpp @@ -32,6 +32,7 @@ WindowScriptingInterface::WindowScriptingInterface() : { const DomainHandler& domainHandler = DependencyManager::get()->getDomainHandler(); connect(&domainHandler, &DomainHandler::hostnameChanged, this, &WindowScriptingInterface::domainChanged); + connect(Application::getInstance(), &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested); } WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) { diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 3bf3c5fb0c..34942366eb 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -60,6 +60,7 @@ signals: void domainChanged(const QString& domainHostname); void inlineButtonClicked(const QString& name); void nonBlockingFormClosed(); + void svoImportRequested(const QString& url); private slots: QScriptValue showAlert(const QString& message);