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,189 +43,168 @@
<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>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<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>
</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 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>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item alignment="Qt::AlignHCenter|Qt::AlignTop">
<widget class="QLabel" name="snapshotWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>500</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>2000</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>
<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>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<family>Helvetica</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: #666;</string>
</property>
<property name="text">
<string>Notes about this image</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</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">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Helvetica</family>
</font>
</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">
<string notr="true"> background-color: #333333;
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<family>Helvetica</family>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<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::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<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>
<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-radius: 9px;
border-radius: 9px;
@ -235,16 +214,17 @@
color: #FFFFFF;
width: 120px;
height: 50px;</string>
</property>
<property name="text">
<string>Share</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</property>
<property name="text">
<string>Share</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>