diff --git a/interface/interface_en.ts b/interface/interface_en.ts index 34e3614716..f8de770fca 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -14,12 +14,12 @@ - + Open Script - + JavaScript Files (*.js) @@ -113,18 +113,18 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file @@ -158,4 +158,25 @@ + + SnapshotShareDialog + + + + Share with community + + + + + + Notes about this image + + + + + + Share + + + diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9563cbf3b4..e819422d46 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3671,5 +3671,10 @@ void Application::takeSnapshot() { player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath())); player->play(); - Snapshot::saveSnapshot(_glWidget, _myAvatar); + QString fileName = Snapshot::saveSnapshot(_glWidget, _myAvatar); + + if (!_snapshotShareDialog) { + _snapshotShareDialog = new SnapshotShareDialog(fileName, _glWidget); + } + _snapshotShareDialog->exec(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 28060113a9..bc401c7de5 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -66,6 +66,7 @@ #include "ui/BandwidthDialog.h" #include "ui/OctreeStatsDialog.h" #include "ui/RearMirrorTools.h" +#include "ui/SnapshotShareDialog.h" #include "ui/LodToolsDialog.h" #include "ui/LogDialog.h" #include "ui/UpdateDialog.h" @@ -473,6 +474,7 @@ private: std::vector _voxelFades; ControllerScriptingInterface _controllerScriptingInterface; QPointer _logDialog; + QPointer _snapshotShareDialog; FileLogger* _logger; diff --git a/interface/src/ui/Snapshot.cpp b/interface/src/ui/Snapshot.cpp index 998aef82e4..90a226c594 100644 --- a/interface/src/ui/Snapshot.cpp +++ b/interface/src/ui/Snapshot.cpp @@ -11,7 +11,6 @@ #include #include -#include #include "Snapshot.h" @@ -61,7 +60,7 @@ SnapshotMetaData* Snapshot::parseSnapshotData(QString snapshotPath) { return data; } -void Snapshot::saveSnapshot(QGLWidget* widget, Avatar* avatar) { +QString Snapshot::saveSnapshot(QGLWidget* widget, Avatar* avatar) { QImage shot = widget->grabFrameBuffer(); glm::vec3 location = avatar->getPosition(); @@ -93,7 +92,7 @@ void Snapshot::saveSnapshot(QGLWidget* widget, Avatar* avatar) { fileName.append(QString(FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT), formattedLocation))); shot.save(fileName, 0, 100); - + return fileName; } diff --git a/interface/src/ui/Snapshot.h b/interface/src/ui/Snapshot.h index 1b78e8328e..83cfe5bc85 100644 --- a/interface/src/ui/Snapshot.h +++ b/interface/src/ui/Snapshot.h @@ -38,7 +38,7 @@ private: class Snapshot { public: - static void saveSnapshot(QGLWidget* widget, Avatar* avatar); + static QString saveSnapshot(QGLWidget* widget, Avatar* avatar); static SnapshotMetaData* parseSnapshotData(QString snapshotPath); }; diff --git a/interface/src/ui/SnapshotShareDialog.cpp b/interface/src/ui/SnapshotShareDialog.cpp index 76556e0222..2af564ff0b 100644 --- a/interface/src/ui/SnapshotShareDialog.cpp +++ b/interface/src/ui/SnapshotShareDialog.cpp @@ -1,13 +1,30 @@ // -// snapshotShareDialog.cpp +// SnapshotShareDialog.cpp // hifi // // Created by Stojce Slavkovski on 2/16/14. // // -#include "snapshotShareDialog.h" +#include "SnapshotShareDialog.h" -#include "ui_shareSnapshot.h" +SnapshotShareDialog::SnapshotShareDialog(QString fileName, QWidget* parent) : QDialog(parent), _fileName(fileName) { + setAttribute(Qt::WA_DeleteOnClose); + ui.setupUi(this); + + QPixmap snaphsotPixmap(fileName); + float snapshotRatio = static_cast(snaphsotPixmap.size().width()) / snaphsotPixmap.size().height(); + float labelRatio = static_cast(ui.snapshotWidget->size().width()) / ui.snapshotWidget->size().height(); + + // set the same aspect ratio of label as of snapshot + if (snapshotRatio > labelRatio) { + ui.snapshotWidget->setFixedHeight(ui.snapshotWidget->size().width() / snapshotRatio); + } else { + ui.snapshotWidget->setFixedWidth(ui.snapshotWidget->size().height() * snapshotRatio); + } + + ui.snapshotWidget->setPixmap(snaphsotPixmap); + ui.snapshotWidget->adjustSize(); +} diff --git a/interface/src/ui/SnapshotShareDialog.h b/interface/src/ui/SnapshotShareDialog.h index 77e92216fd..077acd182b 100644 --- a/interface/src/ui/SnapshotShareDialog.h +++ b/interface/src/ui/SnapshotShareDialog.h @@ -1,5 +1,5 @@ // -// snapshotShareDialog.h +// SnapshotShareDialog.h // hifi // // Created by Stojce Slavkovski on 2/16/14. @@ -9,6 +9,17 @@ #ifndef __hifi__snapshotShareDialog__ #define __hifi__snapshotShareDialog__ -#include +#include "ui_shareSnapshot.h" + +class SnapshotShareDialog : public QDialog { + Q_OBJECT + +public: + SnapshotShareDialog(QString fileName, QWidget* parent = 0); + +private: + QString _fileName; + Ui_SnapshotShareDialog ui; +}; #endif /* defined(__hifi__snapshotShareDialog__) */ diff --git a/interface/ui/shareSnapshot.ui b/interface/ui/shareSnapshot.ui index 94c1b4220e..039e611115 100644 --- a/interface/ui/shareSnapshot.ui +++ b/interface/ui/shareSnapshot.ui @@ -1,7 +1,7 @@ - Dialog - + SnapshotShareDialog + Qt::NonModal @@ -9,10 +9,28 @@ 0 0 - 808 - 577 + 789 + 645 + + + 0 + 0 + + + + + 789 + 645 + + + + + 789 + 645 + + PointingHandCursor @@ -22,33 +40,149 @@ background-color: rgb(255, 255, 255); + + true + -1 -1 - 681 - 511 + 792 + 645 - + - + 0 0 - - background-color: #000; + + + 790 + 510 + + + background-color: #333; + + + QFrame::StyledPanel + + + QFrame::Raised + + + 0 + + + + + -1 + 1 + 791 + 512 + + + + + 0 + + + + + + 0 + 0 + + + + + 790 + 510 + + + + background-color: #ccc; + + + 0 + + + true + + + Qt::AlignCenter + + + 0 + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + - + 0 0 @@ -56,10 +190,25 @@ Notes about this image + + 0 + + + 20 + + + 0 + + + 20 + + + 20 + @@ -70,6 +219,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + +