Layout setup

image ratio fixed
image centre position
This commit is contained in:
stojce 2014-03-23 07:03:20 +01:00
parent 51db3dc3e1
commit e2eb34b6c9
8 changed files with 247 additions and 27 deletions

View file

@ -14,12 +14,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3577"/>
<location filename="src/Application.cpp" line="3580"/>
<source>Open Script</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Application.cpp" line="3578"/>
<location filename="src/Application.cpp" line="3581"/>
<source>JavaScript Files (*.js)</source>
<translation type="unfinished"></translation>
</message>
@ -113,18 +113,18 @@
<context>
<name>Menu</name>
<message>
<location filename="src/Menu.cpp" line="439"/>
<location filename="src/Menu.cpp" line="438"/>
<source>Open .ini config file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="441"/>
<location filename="src/Menu.cpp" line="453"/>
<location filename="src/Menu.cpp" line="440"/>
<location filename="src/Menu.cpp" line="452"/>
<source>Text files (*.ini)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="src/Menu.cpp" line="451"/>
<location filename="src/Menu.cpp" line="450"/>
<source>Save .ini config file</source>
<translation type="unfinished"></translation>
</message>
@ -158,4 +158,25 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SnapshotShareDialog</name>
<message>
<location filename="ui/shareSnapshot.ui" line="38"/>
<location filename="../build/interface/ui_shareSnapshot.h" line="175"/>
<source>Share with community</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/shareSnapshot.ui" line="191"/>
<location filename="../build/interface/ui_shareSnapshot.h" line="176"/>
<source>Notes about this image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/shareSnapshot.ui" line="253"/>
<location filename="../build/interface/ui_shareSnapshot.h" line="177"/>
<source>Share</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

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

View file

@ -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<VoxelFade> _voxelFades;
ControllerScriptingInterface _controllerScriptingInterface;
QPointer<LogDialog> _logDialog;
QPointer<SnapshotShareDialog> _snapshotShareDialog;
FileLogger* _logger;

View file

@ -11,7 +11,6 @@
#include <AccountManager.h>
#include <FileUtils.h>
#include <ui/snapshotShareDialog.cpp>
#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;
}

View file

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

View file

@ -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<float>(snaphsotPixmap.size().width()) / snaphsotPixmap.size().height();
float labelRatio = static_cast<float>(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();
}

View file

@ -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 <iostream>
#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__) */

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<class>SnapshotShareDialog</class>
<widget class="QDialog" name="SnapshotShareDialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
@ -9,10 +9,28 @@
<rect>
<x>0</x>
<y>0</y>
<width>808</width>
<height>577</height>
<width>789</width>
<height>645</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>789</width>
<height>645</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>789</width>
<height>645</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
@ -22,33 +40,149 @@
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>681</width>
<height>511</height>
<width>792</width>
<height>645</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="snapshotWidget">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: #000;</string>
<property name="minimumSize">
<size>
<width>790</width>
<height>510</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: #333;</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>1</y>
<width>791</width>
<height>512</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QLabel" name="snapshotWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>790</width>
<height>510</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: #ccc;</string>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -56,10 +190,25 @@
<property name="text">
<string>Notes about this image</string>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
@ -70,6 +219,22 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="shareButton">
<property name="styleSheet">