History

Allow drag-and-drop of snapshots into Interface

stojce committed 12 years ago

Commit 68584c61 parent 803d0fd9 files · +190 −73Browse files

Showing the changes to interface/src/Application.cpp (1 of 9 files). Show all

Unified · Split

interface/src/Application.cpp+31−3
@@ -48,6 +48,8 @@ · 47 unmodified lines
4848 #include <QXmlStreamReader>
4949 #include <QXmlStreamAttributes>
5050 #include <QMediaPlayer>
51+#include <QMimeData>
52+#include <QMessageBox>
5153
5254 #include <AudioInjector.h>
5355 #include <Logging.h>
@@ -197,7 +199,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 143 unmodified lines
197199 connect(audioThread, SIGNAL(started()), &_audio, SLOT(start()));
198200
199201 audioThread->start();
200−
202+
201203 connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
202204 connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded);
203205 connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled);
@@ -1378,6 +1380,32 @@ void Application::wheelEvent(QWheelEvent* event) { · 1174 unmodified lines
13781380 }
13791381 }
13801382
1383+void Application::dropEvent(QDropEvent *event) {
1384+ QString snapshotPath;
1385+ const QMimeData *mimeData = event->mimeData();
1386+ foreach (QUrl url, mimeData->urls()) {
1387+ if (url.url().toLower().endsWith("jpg")) {
1388+ snapshotPath = url.url().remove("file://");
1389+ break;
1390+ }
1391+ }
1392+
1393+ SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
1394+ if (snapshotData != NULL) {
1395+ if (!snapshotData->getDomain().isEmpty()) {
1396+ Menu::getInstance()->goToDomain(snapshotData->getDomain());
1397+ }
1398+
1399+ _myAvatar->setPosition(snapshotData->getLocation());
1400+ _myAvatar->setOrientation(snapshotData->getOrientation());
1401+ } else {
1402+ QMessageBox msgBox;
1403+ msgBox.setText("No location details were found in this JPG, try dragging in an authentic Hifi snapshot.");
1404+ msgBox.setStandardButtons(QMessageBox::Ok);
1405+ msgBox.exec();
1406+ }
1407+}
1408+
13811409 void Application::sendPingPackets() {
13821410 QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
13831411 controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
@@ -3794,7 +3822,7 @@ void Application::updateWindowTitle(){ · 2410 unmodified lines
37943822
37953823 QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString()
37963824 + " @ " + nodeList->getDomainHostname() + buildVersion;
3797−
3825+
37983826 qDebug("Application title set to: %s", title.toStdString().c_str());
37993827 _window->setWindowTitle(title);
38003828 }
@@ -4170,6 +4198,6 @@ void Application::takeSnapshot() { · 369 unmodified lines
41704198 player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
41714199 player->play();
41724200
4173− Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar->getPosition());
4201+ Snapshot::saveSnapshot(_glWidget, &_profile, _myAvatar);
41744202 }
41754203

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t