mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:16:58 +02:00
commit
83db02642e
10 changed files with 142 additions and 20 deletions
|
@ -48,6 +48,8 @@
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamAttributes>
|
#include <QXmlStreamAttributes>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <AudioInjector.h>
|
#include <AudioInjector.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
|
@ -199,7 +201,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||||
connect(audioThread, SIGNAL(started()), &_audio, SLOT(start()));
|
connect(audioThread, SIGNAL(started()), &_audio, SLOT(start()));
|
||||||
|
|
||||||
audioThread->start();
|
audioThread->start();
|
||||||
|
|
||||||
connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
connect(nodeList, SIGNAL(domainChanged(const QString&)), SLOT(domainChanged(const QString&)));
|
||||||
connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded);
|
connect(nodeList, &NodeList::nodeAdded, this, &Application::nodeAdded);
|
||||||
connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled);
|
connect(nodeList, &NodeList::nodeKilled, this, &Application::nodeKilled);
|
||||||
|
@ -1415,6 +1417,32 @@ void Application::wheelEvent(QWheelEvent* event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::dropEvent(QDropEvent *event) {
|
||||||
|
QString snapshotPath;
|
||||||
|
const QMimeData *mimeData = event->mimeData();
|
||||||
|
foreach (QUrl url, mimeData->urls()) {
|
||||||
|
if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {
|
||||||
|
snapshotPath = url.url().remove("file://");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapshotMetaData* snapshotData = Snapshot::parseSnapshotData(snapshotPath);
|
||||||
|
if (snapshotData != NULL) {
|
||||||
|
if (!snapshotData->getDomain().isEmpty()) {
|
||||||
|
Menu::getInstance()->goToDomain(snapshotData->getDomain());
|
||||||
|
}
|
||||||
|
|
||||||
|
_myAvatar->setPosition(snapshotData->getLocation());
|
||||||
|
_myAvatar->setOrientation(snapshotData->getOrientation());
|
||||||
|
} else {
|
||||||
|
QMessageBox msgBox;
|
||||||
|
msgBox.setText("No location details were found in this JPG, try dragging in an authentic Hifi snapshot.");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
msgBox.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::sendPingPackets() {
|
void Application::sendPingPackets() {
|
||||||
QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
|
QByteArray pingPacket = NodeList::getInstance()->constructPingPacket();
|
||||||
controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
|
controlledBroadcastToNodes(pingPacket, NodeSet() << NodeType::VoxelServer
|
||||||
|
@ -3830,7 +3858,7 @@ void Application::updateWindowTitle(){
|
||||||
|
|
||||||
QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString()
|
QString title = QString() + _profile.getUsername() + " " + nodeList->getSessionUUID().toString()
|
||||||
+ " @ " + nodeList->getDomainHostname() + buildVersion;
|
+ " @ " + nodeList->getDomainHostname() + buildVersion;
|
||||||
|
|
||||||
qDebug("Application title set to: %s", title.toStdString().c_str());
|
qDebug("Application title set to: %s", title.toStdString().c_str());
|
||||||
_window->setWindowTitle(title);
|
_window->setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -4234,6 +4262,6 @@ void Application::takeSnapshot() {
|
||||||
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
||||||
player->play();
|
player->play();
|
||||||
|
|
||||||
Snapshot::saveSnapshot(_glWidget, _profile.getUsername(), _myAvatar->getPosition());
|
Snapshot::saveSnapshot(_glWidget, &_profile, _myAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ static const float NODE_KILLED_RED = 1.0f;
|
||||||
static const float NODE_KILLED_GREEN = 0.0f;
|
static const float NODE_KILLED_GREEN = 0.0f;
|
||||||
static const float NODE_KILLED_BLUE = 0.0f;
|
static const float NODE_KILLED_BLUE = 0.0f;
|
||||||
|
|
||||||
|
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
||||||
|
|
||||||
class Application : public QApplication {
|
class Application : public QApplication {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -127,6 +129,7 @@ public:
|
||||||
void touchUpdateEvent(QTouchEvent* event);
|
void touchUpdateEvent(QTouchEvent* event);
|
||||||
|
|
||||||
void wheelEvent(QWheelEvent* event);
|
void wheelEvent(QWheelEvent* event);
|
||||||
|
void dropEvent(QDropEvent *event);
|
||||||
|
|
||||||
bool event(QEvent* event);
|
bool event(QEvent* event);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include "GLCanvas.h"
|
#include "GLCanvas.h"
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)) {
|
GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuffer)) {
|
||||||
}
|
}
|
||||||
|
@ -16,6 +18,7 @@ GLCanvas::GLCanvas() : QGLWidget(QGLFormat(QGL::NoDepthBuffer, QGL::NoStencilBuf
|
||||||
void GLCanvas::initializeGL() {
|
void GLCanvas::initializeGL() {
|
||||||
Application::getInstance()->initializeGL();
|
Application::getInstance()->initializeGL();
|
||||||
setAttribute(Qt::WA_AcceptTouchEvents);
|
setAttribute(Qt::WA_AcceptTouchEvents);
|
||||||
|
setAcceptDrops(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas::paintGL() {
|
void GLCanvas::paintGL() {
|
||||||
|
@ -67,4 +70,18 @@ bool GLCanvas::event(QEvent* event) {
|
||||||
|
|
||||||
void GLCanvas::wheelEvent(QWheelEvent* event) {
|
void GLCanvas::wheelEvent(QWheelEvent* event) {
|
||||||
Application::getInstance()->wheelEvent(event);
|
Application::getInstance()->wheelEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLCanvas::dragEnterEvent(QDragEnterEvent* event) {
|
||||||
|
const QMimeData *mimeData = event->mimeData();
|
||||||
|
foreach (QUrl url, mimeData->urls()) {
|
||||||
|
if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {
|
||||||
|
event->acceptProposedAction();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLCanvas::dropEvent(QDropEvent* event) {
|
||||||
|
Application::getInstance()->dropEvent(event);
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,9 @@ protected:
|
||||||
virtual bool event(QEvent* event);
|
virtual bool event(QEvent* event);
|
||||||
|
|
||||||
virtual void wheelEvent(QWheelEvent* event);
|
virtual void wheelEvent(QWheelEvent* event);
|
||||||
|
|
||||||
|
virtual void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
virtual void dropEvent(QDropEvent* event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__GLCanvas__) */
|
#endif /* defined(__hifi__GLCanvas__) */
|
||||||
|
|
|
@ -112,7 +112,7 @@ Menu::Menu() :
|
||||||
MenuOption::GoToDomain,
|
MenuOption::GoToDomain,
|
||||||
Qt::CTRL | Qt::Key_D,
|
Qt::CTRL | Qt::Key_D,
|
||||||
this,
|
this,
|
||||||
SLOT(goToDomain()));
|
SLOT(goToDomainDialog()));
|
||||||
addActionToQMenuAndActionHash(fileMenu,
|
addActionToQMenuAndActionHash(fileMenu,
|
||||||
MenuOption::GoToLocation,
|
MenuOption::GoToLocation,
|
||||||
Qt::CTRL | Qt::SHIFT | Qt::Key_L,
|
Qt::CTRL | Qt::SHIFT | Qt::Key_L,
|
||||||
|
@ -897,7 +897,7 @@ void Menu::goToDomain(const QString newDomain) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::goToDomain() {
|
void Menu::goToDomainDialog() {
|
||||||
|
|
||||||
QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
|
QString currentDomainHostname = NodeList::getInstance()->getDomainHostname();
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ private slots:
|
||||||
void aboutApp();
|
void aboutApp();
|
||||||
void login();
|
void login();
|
||||||
void editPreferences();
|
void editPreferences();
|
||||||
void goToDomain();
|
void goToDomainDialog();
|
||||||
void goToLocation();
|
void goToLocation();
|
||||||
void bandwidthDetailsClosed();
|
void bandwidthDetailsClosed();
|
||||||
void voxelStatsDetailsClosed();
|
void voxelStatsDetailsClosed();
|
||||||
|
|
|
@ -45,5 +45,6 @@ private:
|
||||||
TouchState _touchState;
|
TouchState _touchState;
|
||||||
timeval* _lastReceivedPacket;
|
timeval* _lastReceivedPacket;
|
||||||
|
|
||||||
#endif /* defined(__hifi__Transmitter__) */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif /* defined(__hifi__Transmitter__) */
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
// filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg
|
// filename format: hifi-snap-by-%username%-on-%date%_%time%_@-%location%.jpg
|
||||||
// %1 <= username, %2 <= date and time, %3 <= current location
|
// %1 <= username, %2 <= date and time, %3 <= current location
|
||||||
|
@ -21,18 +20,69 @@ const QString FILENAME_PATH_FORMAT = "hifi-snap-by-%1-on-%2@%3.jpg";
|
||||||
const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss";
|
const QString DATETIME_FORMAT = "yyyy-MM-dd_hh-mm-ss";
|
||||||
const QString SNAPSHOTS_DIRECTORY = "Snapshots";
|
const QString SNAPSHOTS_DIRECTORY = "Snapshots";
|
||||||
|
|
||||||
void Snapshot::saveSnapshot(QGLWidget* widget, QString username, glm::vec3 location) {
|
const QString LOCATION_X = "location-x";
|
||||||
QImage shot = widget->grabFrameBuffer();
|
const QString LOCATION_Y = "location-y";
|
||||||
|
const QString LOCATION_Z = "location-z";
|
||||||
|
|
||||||
|
const QString ORIENTATION_X = "orientation-x";
|
||||||
|
const QString ORIENTATION_Y = "orientation-y";
|
||||||
|
const QString ORIENTATION_Z = "orientation-z";
|
||||||
|
const QString ORIENTATION_W = "orientation-w";
|
||||||
|
|
||||||
|
const QString DOMAIN_KEY = "domain";
|
||||||
|
|
||||||
|
|
||||||
|
SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) {
|
||||||
|
|
||||||
|
if (!QFile(snapshotPath).exists()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
QImage shot(snapshotPath);
|
||||||
|
|
||||||
|
// no location data stored
|
||||||
|
if (shot.text(LOCATION_X).isEmpty() || shot.text(LOCATION_Y).isEmpty() || shot.text(LOCATION_Z).isEmpty()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapshotMetaData* data = new SnapshotMetaData();
|
||||||
|
data->setLocation(glm::vec3(shot.text(LOCATION_X).toFloat(),
|
||||||
|
shot.text(LOCATION_Y).toFloat(),
|
||||||
|
shot.text(LOCATION_Z).toFloat()));
|
||||||
|
|
||||||
|
data->setOrientation(glm::quat(shot.text(ORIENTATION_W).toFloat(),
|
||||||
|
shot.text(ORIENTATION_X).toFloat(),
|
||||||
|
shot.text(ORIENTATION_Y).toFloat(),
|
||||||
|
shot.text(ORIENTATION_Z).toFloat()));
|
||||||
|
|
||||||
|
data->setDomain(shot.text(DOMAIN_KEY));
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Snapshot::saveSnapshot(QGLWidget* widget, Profile* profile, Avatar* avatar) {
|
||||||
|
QImage shot = widget->grabFrameBuffer();
|
||||||
|
|
||||||
|
glm::vec3 location = avatar->getPosition();
|
||||||
|
glm::quat orientation = avatar->getHead().getOrientation();
|
||||||
|
|
||||||
// add metadata
|
// add metadata
|
||||||
shot.setText("location-x", QString::number(location.x));
|
shot.setText(LOCATION_X, QString::number(location.x));
|
||||||
shot.setText("location-y", QString::number(location.y));
|
shot.setText(LOCATION_Y, QString::number(location.y));
|
||||||
shot.setText("location-z", QString::number(location.z));
|
shot.setText(LOCATION_Z, QString::number(location.z));
|
||||||
|
|
||||||
|
shot.setText(ORIENTATION_X, QString::number(orientation.x));
|
||||||
|
shot.setText(ORIENTATION_Y, QString::number(orientation.y));
|
||||||
|
shot.setText(ORIENTATION_Z, QString::number(orientation.z));
|
||||||
|
shot.setText(ORIENTATION_W, QString::number(orientation.w));
|
||||||
|
|
||||||
|
shot.setText(DOMAIN_KEY, profile->getLastDomain());
|
||||||
|
|
||||||
QString formattedLocation = QString("%1_%2_%3").arg(location.x).arg(location.y).arg(location.z);
|
QString formattedLocation = QString("%1_%2_%3").arg(location.x).arg(location.y).arg(location.z);
|
||||||
// replace decimal . with '-'
|
// replace decimal . with '-'
|
||||||
formattedLocation.replace('.', '-');
|
formattedLocation.replace('.', '-');
|
||||||
|
|
||||||
|
QString username = profile->getUsername();
|
||||||
// normalize username, replace all non alphanumeric with '-'
|
// normalize username, replace all non alphanumeric with '-'
|
||||||
username.replace(QRegExp("[^A-Za-z0-9_]"), "-");
|
username.replace(QRegExp("[^A-Za-z0-9_]"), "-");
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,38 @@
|
||||||
#ifndef __hifi__Snapshot__
|
#ifndef __hifi__Snapshot__
|
||||||
#define __hifi__Snapshot__
|
#define __hifi__Snapshot__
|
||||||
|
|
||||||
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include "avatar/Avatar.h"
|
||||||
|
#include "avatar/Profile.h"
|
||||||
|
|
||||||
|
class SnapshotMetaData {
|
||||||
|
public:
|
||||||
|
|
||||||
|
QString getDomain() { return _domain; }
|
||||||
|
void setDomain(QString domain) { _domain = domain; }
|
||||||
|
|
||||||
|
glm::vec3 getLocation() { return _location; }
|
||||||
|
void setLocation(glm::vec3 location) { _location = location; }
|
||||||
|
|
||||||
|
glm::quat getOrientation() { return _orientation; }
|
||||||
|
void setOrientation(glm::quat orientation) { _orientation = orientation; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _domain;
|
||||||
|
glm::vec3 _location;
|
||||||
|
glm::quat _orientation;;
|
||||||
|
};
|
||||||
|
|
||||||
class Snapshot {
|
class Snapshot {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void saveSnapshot(QGLWidget* widget, QString username, glm::vec3 location);
|
static void saveSnapshot(QGLWidget* widget, Profile* profile, Avatar* avatar);
|
||||||
|
static SnapshotMetaData* parseSnapshotData(QString snapshotPath);
|
||||||
private:
|
|
||||||
QString _username;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__Snapshot__) */
|
#endif /* defined(__hifi__Snapshot__) */
|
||||||
|
|
|
@ -807,7 +807,8 @@ void NodeList::loadData(QSettings *settings) {
|
||||||
} else {
|
} else {
|
||||||
_domainHostname = DEFAULT_DOMAIN_HOSTNAME;
|
_domainHostname = DEFAULT_DOMAIN_HOSTNAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit domainChanged(_domainHostname);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue