mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add save to file and other options
This commit is contained in:
parent
c92f8f0531
commit
691b253a1b
@ -6,9 +6,27 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>619</width>
|
||||
<height>559</height>
|
||||
<height>596</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>619</width>
|
||||
<height>596</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize" >
|
||||
<size>
|
||||
<width>619</width>
|
||||
<height>596</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Zint Barcode Studio</string>
|
||||
</property>
|
||||
@ -57,6 +75,12 @@
|
||||
<height>217</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -2317,7 +2341,7 @@ p, li { white-space: pre-wrap; }
|
||||
<x>10</x>
|
||||
<y>6</y>
|
||||
<width>572</width>
|
||||
<height>102</height>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title" >
|
||||
@ -2326,9 +2350,9 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>14</x>
|
||||
<y>19</y>
|
||||
<width>91</width>
|
||||
<x>10</x>
|
||||
<y>18</y>
|
||||
<width>40</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2358,9 +2382,9 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QLabel" name="label_8" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>-3</x>
|
||||
<y>43</y>
|
||||
<width>109</width>
|
||||
<x>9</x>
|
||||
<y>39</y>
|
||||
<width>73</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2374,9 +2398,9 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QSpinBox" name="bwidth" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>114</x>
|
||||
<x>118</x>
|
||||
<y>46</y>
|
||||
<width>124</width>
|
||||
<width>120</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2434,9 +2458,9 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QPushButton" name="fgcolor" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>273</x>
|
||||
<y>51</y>
|
||||
<width>145</width>
|
||||
<x>357</x>
|
||||
<y>92</y>
|
||||
<width>141</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2447,9 +2471,9 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QPushButton" name="bgcolor" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>427</x>
|
||||
<y>51</y>
|
||||
<width>133</width>
|
||||
<x>357</x>
|
||||
<y>57</y>
|
||||
<width>142</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -2460,8 +2484,8 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QSpinBox" name="spnWhitespace" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>117</x>
|
||||
<y>73</y>
|
||||
<x>119</x>
|
||||
<y>72</y>
|
||||
<width>120</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
@ -2470,8 +2494,8 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QLabel" name="lblWhitespace" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>21</x>
|
||||
<y>73</y>
|
||||
<x>11</x>
|
||||
<y>74</y>
|
||||
<width>78</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@ -2480,6 +2504,38 @@ p, li { white-space: pre-wrap; }
|
||||
<string>Whitespace:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblScale" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>103</y>
|
||||
<width>85</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Printing Scale:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="spnScale" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>119</x>
|
||||
<y>102</y>
|
||||
<width>119</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="suffix" >
|
||||
<string> X</string>
|
||||
</property>
|
||||
<property name="singleStep" >
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -2517,6 +2573,61 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnAbout" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>560</y>
|
||||
<width>75</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>About</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnCopy" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>450</x>
|
||||
<y>560</y>
|
||||
<width>75</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnSave" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>560</y>
|
||||
<width>75</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnExit" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>530</x>
|
||||
<y>560</y>
|
||||
<width>75</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>E&xit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>bstyle</tabstop>
|
||||
|
@ -19,13 +19,13 @@
|
||||
#include <QImage>
|
||||
#include <QColorDialog>
|
||||
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <stdio.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
: QWidget(parent, fl)
|
||||
{
|
||||
|
||||
char bstyle_text[][50] = {
|
||||
"Australia Post Standard Customer",
|
||||
"Australia Post Reply-Paid",
|
||||
@ -88,8 +88,13 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
"UPC-E",
|
||||
"USPS One Code"
|
||||
};
|
||||
|
||||
/* createActions();
|
||||
createMenus(); */
|
||||
|
||||
setupUi(this);
|
||||
view->setScene(new QGraphicsScene);
|
||||
|
||||
m_fgcolor=qRgb(0,0,0);
|
||||
m_bgcolor=qRgb(0xff,0xff,0xff);
|
||||
for (int i=0;i<metaObject()->enumerator(0).keyCount();i++) {
|
||||
@ -166,11 +171,68 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||
connect(txtMaxiPrimary, SIGNAL(textChanged( const QString& )), SLOT(update_preview()));
|
||||
connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
|
||||
connect(cmbChannel, SIGNAL(currentIndexChanged( int )), SLOT(update_preview()));
|
||||
connect(btnAbout, SIGNAL(clicked( bool )), SLOT(about()));
|
||||
connect(btnSave, SIGNAL(clicked( bool )), SLOT(save()));
|
||||
connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale()));
|
||||
connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now()));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
/*
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
saveAct = new QAction(tr("&Save"), this);
|
||||
saveAct->setShortcut(tr("Ctrl+S"));
|
||||
saveAct->setStatusTip(tr("Save the document to disk"));
|
||||
connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
|
||||
aboutQtAct = new QAction(tr("About &Qt"), this);
|
||||
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
||||
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||
}
|
||||
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(saveAct);
|
||||
fileMenu->addAction(exitAction);
|
||||
helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(aboutQtAct);
|
||||
} */
|
||||
|
||||
bool MainWindow::save()
|
||||
{
|
||||
bool status;
|
||||
|
||||
/* Does nothing yet! */
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save Barcode Image"), ".",
|
||||
tr("Barcode Images (*.png *.eps *.svg)"));
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
|
||||
status = m_bc.bc.save_to_file(fileName);
|
||||
if(status == false) {
|
||||
QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message());
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About Zint"),
|
||||
tr("<h2>Zint Barcode Studio 0.2</h2>"
|
||||
"<p>A simple barcode generator"
|
||||
"<p>Requires libzint 2.1.3 or greater."
|
||||
"<p>Visit the <a href=\"http://www.zint.org.uk\">Zint Project Homepage</a> for more information."
|
||||
"<p>Copyright © 2009 Robin Stuart & Bogdan Vatra.<br>"
|
||||
"QR Code support by Kentaro Fukuchi.<br>"
|
||||
"Released under the GNU General Public License ver. 3"
|
||||
"<p>\"QR Code\" is a Registered Trademark of Denso Corp."
|
||||
));
|
||||
}
|
||||
|
||||
void MainWindow::on_fgcolor_clicked()
|
||||
{
|
||||
@ -184,6 +246,17 @@ void MainWindow::on_bgcolor_clicked()
|
||||
update_preview();
|
||||
}
|
||||
|
||||
void MainWindow::change_print_scale()
|
||||
{
|
||||
/* This value is only used when printing (saving) to file */
|
||||
m_bc.bc.setScale((float)spnScale->value());
|
||||
}
|
||||
|
||||
void MainWindow::quit_now()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void MainWindow::change_options()
|
||||
{
|
||||
bool options;
|
||||
|
@ -19,10 +19,16 @@
|
||||
|
||||
#include <QtGui>
|
||||
#include <QGraphicsItem>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "ui_mainWindow.h"
|
||||
#include "barcodeitem.h"
|
||||
|
||||
class QAction;
|
||||
class QActionGroup;
|
||||
class QLabel;
|
||||
class QMenu;
|
||||
|
||||
class MainWindow : public QWidget, private Ui::mainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -113,11 +119,24 @@ public slots:
|
||||
void mqr_size();
|
||||
void mqr_errorcorrect();
|
||||
void maxi_primary();
|
||||
void change_print_scale();
|
||||
|
||||
private slots:
|
||||
bool save();
|
||||
void about();
|
||||
void quit_now();
|
||||
/* void about(); */
|
||||
|
||||
private:
|
||||
/* void createActions();
|
||||
void createMenus(); */
|
||||
|
||||
QColor m_fgcolor,m_bgcolor;
|
||||
BarcodeItem m_bc;
|
||||
|
||||
/* QMenu *fileMenu;
|
||||
QMenu *helpMenu;
|
||||
QAction *saveAct;
|
||||
QAction *aboutQtAct; */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user