aspectRatio

This commit is contained in:
taipanromania 2008-10-11 10:30:35 +00:00
parent 634386b8a4
commit 5994ff5cf7
4 changed files with 76 additions and 40 deletions

View File

@ -36,7 +36,7 @@ QRectF BarcodeItem::boundingRect() const
void BarcodeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) void BarcodeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{ {
bc.render(*painter,boundingRect(),Zint::QZint::IgnoreAspectRatio); bc.render(*painter,boundingRect(),ar);
} }

View File

@ -35,6 +35,7 @@ public:
public: public:
mutable Zint::QZint bc; mutable Zint::QZint bc;
int w,h; int w,h;
Zint::QZint::AspectRatioMode ar;
}; };
#endif #endif

View File

@ -127,9 +127,9 @@
<item row="2" column="4" colspan="4" > <item row="2" column="4" colspan="4" >
<layout class="QHBoxLayout" name="horizontalLayout_12" > <layout class="QHBoxLayout" name="horizontalLayout_12" >
<item> <item>
<widget class="QLabel" name="label_11" > <widget class="QLabel" name="label_7" >
<property name="text" > <property name="text" >
<string>Item Width:</string> <string>Aspect ratio:</string>
</property> </property>
<property name="alignment" > <property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -137,19 +137,22 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="iwidth" > <widget class="QComboBox" name="aspectRatio" >
<property name="minimum" > <item>
<number>10</number> <property name="text" >
</property> <string>Ignore aspect ratio</string>
<property name="maximum" > </property>
<number>1000</number> </item>
</property> <item>
<property name="singleStep" > <property name="text" >
<number>5</number> <string>Keep aspect ratio</string>
</property> </property>
<property name="value" > </item>
<number>400</number> <item>
</property> <property name="text" >
<string>Center (no scalling)</string>
</property>
</item>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -179,11 +182,11 @@
</layout> </layout>
</item> </item>
<item row="3" column="4" colspan="4" > <item row="3" column="4" colspan="4" >
<layout class="QHBoxLayout" name="horizontalLayout_13" > <layout class="QHBoxLayout" name="horizontalLayout_7" >
<item> <item>
<widget class="QLabel" name="label_12" > <widget class="QLabel" name="label_11" >
<property name="text" > <property name="text" >
<string>Item Height:</string> <string>Item Width:</string>
</property> </property>
<property name="alignment" > <property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -191,7 +194,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="iheight" > <widget class="QSpinBox" name="iwidth" >
<property name="minimum" > <property name="minimum" >
<number>10</number> <number>10</number>
</property> </property>
@ -233,11 +236,11 @@
</layout> </layout>
</item> </item>
<item row="4" column="4" colspan="4" > <item row="4" column="4" colspan="4" >
<layout class="QHBoxLayout" name="horizontalLayout_4" > <layout class="QHBoxLayout" name="horizontalLayout_13" >
<item> <item>
<widget class="QLabel" name="label_4" > <widget class="QLabel" name="label_12" >
<property name="text" > <property name="text" >
<string>Primary</string> <string>Item Height:</string>
</property> </property>
<property name="alignment" > <property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -245,7 +248,20 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="primary" /> <widget class="QSpinBox" name="iheight" >
<property name="minimum" >
<number>10</number>
</property>
<property name="maximum" >
<number>1000</number>
</property>
<property name="singleStep" >
<number>5</number>
</property>
<property name="value" >
<number>400</number>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -276,28 +292,20 @@
</item> </item>
</layout> </layout>
</item> </item>
<item rowspan="7" row="5" column="4" colspan="4" > <item row="5" column="4" colspan="4" >
<layout class="QVBoxLayout" name="verticalLayout" > <layout class="QHBoxLayout" name="horizontalLayout_4" >
<item> <item>
<widget class="QLabel" name="label_2" > <widget class="QLabel" name="label_4" >
<property name="text" > <property name="text" >
<string>Data</string> <string>Primary</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTextEdit" name="text" > <widget class="QLineEdit" name="primary" />
<property name="html" >
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">123456&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</item> </item>
@ -328,6 +336,31 @@ p, li { white-space: pre-wrap; }
</item> </item>
</layout> </layout>
</item> </item>
<item rowspan="6" row="6" column="4" colspan="4" >
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Data</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="text" >
<property name="html" >
<string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">123456&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0" colspan="4" > <item row="7" column="0" colspan="4" >
<layout class="QHBoxLayout" name="horizontalLayout_10" > <layout class="QHBoxLayout" name="horizontalLayout_10" >
<item> <item>

View File

@ -66,6 +66,7 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
connect(btype, SIGNAL(currentIndexChanged( int )), SLOT(on_generate_clicked())); connect(btype, SIGNAL(currentIndexChanged( int )), SLOT(on_generate_clicked()));
connect(primary, SIGNAL(textChanged( const QString& )), SLOT(on_generate_clicked())); connect(primary, SIGNAL(textChanged( const QString& )), SLOT(on_generate_clicked()));
connect(text, SIGNAL(textChanged()), SLOT(on_generate_clicked())); connect(text, SIGNAL(textChanged()), SLOT(on_generate_clicked()));
connect(aspectRatio, SIGNAL(currentIndexChanged( int )), SLOT(on_generate_clicked()));
} }
@ -90,6 +91,7 @@ void MainWindow::on_generate_clicked()
QString error; QString error;
m_bc.w=iwidth->value(); m_bc.w=iwidth->value();
m_bc.h=iheight->value(); m_bc.h=iheight->value();
m_bc.ar=(Zint::QZint::AspectRatioMode)aspectRatio->currentIndex();
m_bc.bc.setText(text->toPlainText()); m_bc.bc.setText(text->toPlainText());
m_bc.bc.setPrimaryMessage(primary->text()); m_bc.bc.setPrimaryMessage(primary->text());
m_bc.bc.setSymbol(metaObject()->enumerator(0).value(bstyle->currentIndex())); m_bc.bc.setSymbol(metaObject()->enumerator(0).value(bstyle->currentIndex()));