New layout behaviour

This commit is contained in:
stojce 2014-03-25 21:56:20 +01:00
parent 5e350df128
commit e5a66ddb90
3 changed files with 214 additions and 197 deletions

View file

@ -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="156"/>
<source>Share with community</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/shareSnapshot.ui" line="133"/>
<location filename="../build/interface/ui_shareSnapshot.h" line="157"/>
<source>Notes about this image</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/shareSnapshot.ui" line="219"/>
<location filename="../build/interface/ui_shareSnapshot.h" line="158"/>
<source>Share</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View file

@ -6,6 +6,9 @@
//
//
const int NARROW_SNAPSHOT_DIALOG_SIZE = 500;
const int WIDE_SNAPSHOT_DIALOG_WIDTH = 650;
#include "SnapshotShareDialog.h"
SnapshotShareDialog::SnapshotShareDialog(QString fileName, QWidget* parent) : QDialog(parent), _fileName(fileName) {
@ -16,11 +19,24 @@ SnapshotShareDialog::SnapshotShareDialog(QString fileName, QWidget* parent) : QD
QPixmap snaphsotPixmap(fileName);
float snapshotRatio = static_cast<float>(snaphsotPixmap.size().width()) / snaphsotPixmap.size().height();
// narrow snapshot
if (snapshotRatio > 1) {
setFixedWidth(WIDE_SNAPSHOT_DIALOG_WIDTH);
ui.snapshotWidget->setFixedWidth(WIDE_SNAPSHOT_DIALOG_WIDTH);
}
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) {
int oldHeight = ui.snapshotWidget->size().height();
ui.snapshotWidget->setFixedHeight(ui.snapshotWidget->size().width() / snapshotRatio);
// if height is less then original, resize the window as well
if (ui.snapshotWidget->size().height() < NARROW_SNAPSHOT_DIALOG_SIZE) {
setFixedHeight(size().height() - (oldHeight - ui.snapshotWidget->size().height()));
}
} else {
ui.snapshotWidget->setFixedWidth(ui.snapshotWidget->size().height() * snapshotRatio);
}

View file

@ -9,26 +9,26 @@
<rect>
<x>0</x>
<y>0</y>
<width>789</width>
<height>645</height>
<width>502</width>
<height>625</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>789</width>
<height>645</height>
<width>500</width>
<height>625</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>789</width>
<height>645</height>
<width>502</width>
<height>625</height>
</size>
</property>
<property name="cursor">
@ -43,82 +43,45 @@
<property name="modal">
<bool>true</bool>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>-1</x>
<y>-1</y>
<width>792</width>
<height>645</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<property name="minimumSize">
<size>
<width>790</width>
<height>510</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>790</width>
<height>510</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: #000</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</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>792</width>
<height>512</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<item alignment="Qt::AlignHCenter|Qt::AlignTop">
<widget class="QLabel" name="snapshotWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>790</width>
<height>510</height>
<width>500</width>
<height>500</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>790</width>
<height>510</height>
<width>30</width>
<height>2000</height>
</size>
</property>
<property name="styleSheet">
@ -138,14 +101,10 @@
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -164,19 +123,23 @@
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #666;</string>
<string notr="true">color: #666;
padding-left:20px;</string>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string>Notes about this image</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>20</number>
<number>0</number>
</property>
</widget>
</item>
@ -185,6 +148,9 @@
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>20</number>
</property>
@ -199,11 +165,24 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
<property name="font">
<font>
<family>Helvetica</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
<item>
@ -244,7 +223,8 @@
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>