Handle .svo drop events and emit svoImportRequested

This commit is contained in:
Ryan Huffman 2015-03-11 15:38:15 -07:00
parent 2f885bb7f2
commit c3c2a75f48
5 changed files with 15 additions and 3 deletions

View file

@ -882,9 +882,15 @@ bool Application::event(QEvent* event) {
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
QUrl url = fileEvent->url();
if (!fileEvent->url().isEmpty()) {
DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
if (!url.isEmpty()) {
if (url.scheme() == HIFI_URL_SCHEME) {
DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
} else if (url.url().toLower().endsWith(SVO_EXTENSION)) {
emit svoImportRequested(url.url());
}
}
return false;

View file

@ -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();

View file

@ -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;
}

View file

@ -32,6 +32,7 @@ WindowScriptingInterface::WindowScriptingInterface() :
{
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->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) {

View file

@ -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);