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> <translation type="unfinished"></translation>
</message> </message>
</context> </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> </TS>

View file

@ -6,6 +6,9 @@
// //
// //
const int NARROW_SNAPSHOT_DIALOG_SIZE = 500;
const int WIDE_SNAPSHOT_DIALOG_WIDTH = 650;
#include "SnapshotShareDialog.h" #include "SnapshotShareDialog.h"
SnapshotShareDialog::SnapshotShareDialog(QString fileName, QWidget* parent) : QDialog(parent), _fileName(fileName) { SnapshotShareDialog::SnapshotShareDialog(QString fileName, QWidget* parent) : QDialog(parent), _fileName(fileName) {
@ -16,11 +19,24 @@ SnapshotShareDialog::SnapshotShareDialog(QString fileName, QWidget* parent) : QD
QPixmap snaphsotPixmap(fileName); QPixmap snaphsotPixmap(fileName);
float snapshotRatio = static_cast<float>(snaphsotPixmap.size().width()) / snaphsotPixmap.size().height(); 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(); float labelRatio = static_cast<float>(ui.snapshotWidget->size().width()) / ui.snapshotWidget->size().height();
// set the same aspect ratio of label as of snapshot // set the same aspect ratio of label as of snapshot
if (snapshotRatio > labelRatio) { if (snapshotRatio > labelRatio) {
int oldHeight = ui.snapshotWidget->size().height();
ui.snapshotWidget->setFixedHeight(ui.snapshotWidget->size().width() / snapshotRatio); 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 { } else {
ui.snapshotWidget->setFixedWidth(ui.snapshotWidget->size().height() * snapshotRatio); ui.snapshotWidget->setFixedWidth(ui.snapshotWidget->size().height() * snapshotRatio);
} }

View file

@ -9,26 +9,26 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>789</width> <width>502</width>
<height>645</height> <height>625</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="MinimumExpanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>789</width> <width>500</width>
<height>645</height> <height>625</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>789</width> <width>502</width>
<height>645</height> <height>625</height>
</size> </size>
</property> </property>
<property name="cursor"> <property name="cursor">
@ -43,189 +43,168 @@
<property name="modal"> <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<widget class="QWidget" name="verticalLayoutWidget"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="geometry"> <property name="spacing">
<rect> <number>0</number>
<x>-1</x>
<y>-1</y>
<width>792</width>
<height>645</height>
</rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="leftMargin">
<property name="spacing"> <number>0</number>
<number>0</number> </property>
</property> <property name="topMargin">
<item> <number>0</number>
<widget class="QFrame" name="frame"> </property>
<property name="sizePolicy"> <property name="rightMargin">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <number>0</number>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="bottomMargin">
</sizepolicy> <number>0</number>
</property> </property>
<property name="minimumSize"> <item>
<size> <layout class="QVBoxLayout" name="verticalLayout">
<width>790</width> <property name="sizeConstraint">
<height>510</height> <enum>QLayout::SetMinAndMaxSize</enum>
</size> </property>
</property> <item alignment="Qt::AlignHCenter|Qt::AlignTop">
<property name="maximumSize"> <widget class="QLabel" name="snapshotWidget">
<size> <property name="sizePolicy">
<width>790</width> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<height>510</height> <horstretch>0</horstretch>
</size> <verstretch>0</verstretch>
</property> </sizepolicy>
<property name="styleSheet"> </property>
<string notr="true">background-color: #000</string> <property name="minimumSize">
</property> <size>
<property name="frameShape"> <width>500</width>
<enum>QFrame::NoFrame</enum> <height>500</height>
</property> </size>
<property name="frameShadow"> </property>
<enum>QFrame::Plain</enum> <property name="maximumSize">
</property> <size>
<property name="lineWidth"> <width>30</width>
<number>0</number> <height>2000</height>
</property> </size>
<widget class="QWidget" name="gridLayoutWidget"> </property>
<property name="geometry"> <property name="styleSheet">
<rect> <string notr="true">background-color: #ccc;</string>
<x>-1</x> </property>
<y>1</y> <property name="lineWidth">
<width>792</width> <number>0</number>
<height>512</height> </property>
</rect> <property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="indent">
<number>0</number>
</property> </property>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<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="maximumSize">
<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>
</layout>
</widget> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QLabel" name="label">
<widget class="QLabel" name="label"> <property name="sizePolicy">
<property name="sizePolicy"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch>
<horstretch>0</horstretch> <verstretch>0</verstretch>
<verstretch>0</verstretch> </sizepolicy>
</sizepolicy> </property>
</property> <property name="minimumSize">
<property name="minimumSize"> <size>
<size> <width>0</width>
<width>0</width> <height>30</height>
<height>30</height> </size>
</size> </property>
</property> <property name="font">
<property name="font"> <font>
<font> <family>Helvetica</family>
<family>Helvetica</family> <weight>75</weight>
<weight>75</weight> <bold>true</bold>
<bold>true</bold> </font>
</font> </property>
</property> <property name="styleSheet">
<property name="styleSheet"> <string notr="true">color: #666;
<string notr="true">color: #666;</string> padding-left:20px;</string>
</property> </property>
<property name="text"> <property name="lineWidth">
<string>Notes about this image</string> <number>0</number>
</property> </property>
<property name="alignment"> <property name="text">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <string>Notes about this image</string>
</property> </property>
<property name="margin"> <property name="alignment">
<number>0</number> <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property> </property>
<property name="indent"> <property name="margin">
<number>20</number> <number>0</number>
</property> </property>
</widget> <property name="indent">
</item> <number>0</number>
<item> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> </widget>
<property name="spacing"> </item>
<number>0</number> <item>
</property> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <property name="spacing">
<number>20</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="sizeConstraint">
<number>20</number> <enum>QLayout::SetFixedSize</enum>
</property> </property>
<item> <property name="leftMargin">
<widget class="QTextEdit" name="textEdit"> <number>20</number>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <property name="rightMargin">
<horstretch>0</horstretch> <number>20</number>
<verstretch>0</verstretch> </property>
</sizepolicy> <item>
</property> <widget class="QTextEdit" name="textEdit">
<property name="font"> <property name="sizePolicy">
<font> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<family>Helvetica</family> <horstretch>0</horstretch>
</font> <verstretch>0</verstretch>
</property> </sizepolicy>
</widget> </property>
</item> <property name="maximumSize">
<item> <size>
<spacer name="horizontalSpacer"> <width>16777215</width>
<property name="orientation"> <height>60</height>
<enum>Qt::Horizontal</enum> </size>
</property> </property>
<property name="sizeType"> <property name="font">
<enum>QSizePolicy::Fixed</enum> <font>
</property> <family>Helvetica</family>
<property name="sizeHint" stdset="0"> <pointsize>14</pointsize>
<size> </font>
<width>20</width> </property>
<height>20</height> <property name="frameShape">
</size> <enum>QFrame::Box</enum>
</property> </property>
</spacer> <property name="frameShadow">
</item> <enum>QFrame::Plain</enum>
<item> </property>
<widget class="QPushButton" name="shareButton"> </widget>
<property name="styleSheet"> </item>
<string notr="true"> background-color: #333333; <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">
<string notr="true"> background-color: #333333;
border-width: 0; border-width: 0;
border-radius: 9px; border-radius: 9px;
border-radius: 9px; border-radius: 9px;
@ -235,16 +214,17 @@
color: #FFFFFF; color: #FFFFFF;
width: 120px; width: 120px;
height: 50px;</string> height: 50px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>Share</string> <string>Share</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</widget> </item>
</layout>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>