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>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>619</width>
|
<width>619</width>
|
||||||
<height>559</height>
|
<height>596</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</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" >
|
<property name="windowTitle" >
|
||||||
<string>Zint Barcode Studio</string>
|
<string>Zint Barcode Studio</string>
|
||||||
</property>
|
</property>
|
||||||
@ -57,6 +75,12 @@
|
|||||||
<height>217</height>
|
<height>217</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy" >
|
||||||
|
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="currentIndex" >
|
<property name="currentIndex" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -2317,7 +2341,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>6</y>
|
<y>6</y>
|
||||||
<width>572</width>
|
<width>572</width>
|
||||||
<height>102</height>
|
<height>140</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
@ -2326,9 +2350,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QLabel" name="label_3" >
|
<widget class="QLabel" name="label_3" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>14</x>
|
<x>10</x>
|
||||||
<y>19</y>
|
<y>18</y>
|
||||||
<width>91</width>
|
<width>40</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -2358,9 +2382,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QLabel" name="label_8" >
|
<widget class="QLabel" name="label_8" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>-3</x>
|
<x>9</x>
|
||||||
<y>43</y>
|
<y>39</y>
|
||||||
<width>109</width>
|
<width>73</width>
|
||||||
<height>29</height>
|
<height>29</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -2374,9 +2398,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QSpinBox" name="bwidth" >
|
<widget class="QSpinBox" name="bwidth" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>114</x>
|
<x>118</x>
|
||||||
<y>46</y>
|
<y>46</y>
|
||||||
<width>124</width>
|
<width>120</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -2434,9 +2458,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QPushButton" name="fgcolor" >
|
<widget class="QPushButton" name="fgcolor" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>273</x>
|
<x>357</x>
|
||||||
<y>51</y>
|
<y>92</y>
|
||||||
<width>145</width>
|
<width>141</width>
|
||||||
<height>26</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -2447,9 +2471,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QPushButton" name="bgcolor" >
|
<widget class="QPushButton" name="bgcolor" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>427</x>
|
<x>357</x>
|
||||||
<y>51</y>
|
<y>57</y>
|
||||||
<width>133</width>
|
<width>142</width>
|
||||||
<height>26</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -2460,8 +2484,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QSpinBox" name="spnWhitespace" >
|
<widget class="QSpinBox" name="spnWhitespace" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>117</x>
|
<x>119</x>
|
||||||
<y>73</y>
|
<y>72</y>
|
||||||
<width>120</width>
|
<width>120</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -2470,8 +2494,8 @@ p, li { white-space: pre-wrap; }
|
|||||||
<widget class="QLabel" name="lblWhitespace" >
|
<widget class="QLabel" name="lblWhitespace" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>21</x>
|
<x>11</x>
|
||||||
<y>73</y>
|
<y>74</y>
|
||||||
<width>78</width>
|
<width>78</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
@ -2480,6 +2504,38 @@ p, li { white-space: pre-wrap; }
|
|||||||
<string>Whitespace:</string>
|
<string>Whitespace:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</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>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
@ -2517,6 +2573,61 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</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>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>bstyle</tabstop>
|
<tabstop>bstyle</tabstop>
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
||||||
: QWidget(parent, fl)
|
: QWidget(parent, fl)
|
||||||
{
|
{
|
||||||
|
|
||||||
char bstyle_text[][50] = {
|
char bstyle_text[][50] = {
|
||||||
"Australia Post Standard Customer",
|
"Australia Post Standard Customer",
|
||||||
"Australia Post Reply-Paid",
|
"Australia Post Reply-Paid",
|
||||||
@ -88,8 +88,13 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
|
|||||||
"UPC-E",
|
"UPC-E",
|
||||||
"USPS One Code"
|
"USPS One Code"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* createActions();
|
||||||
|
createMenus(); */
|
||||||
|
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
view->setScene(new QGraphicsScene);
|
view->setScene(new QGraphicsScene);
|
||||||
|
|
||||||
m_fgcolor=qRgb(0,0,0);
|
m_fgcolor=qRgb(0,0,0);
|
||||||
m_bgcolor=qRgb(0xff,0xff,0xff);
|
m_bgcolor=qRgb(0xff,0xff,0xff);
|
||||||
for (int i=0;i<metaObject()->enumerator(0).keyCount();i++) {
|
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(txtMaxiPrimary, SIGNAL(textChanged( const QString& )), SLOT(update_preview()));
|
||||||
connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
|
connect(spnWhitespace, SIGNAL(valueChanged( int )), SLOT(update_preview()));
|
||||||
connect(cmbChannel, SIGNAL(currentIndexChanged( 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()
|
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()
|
void MainWindow::on_fgcolor_clicked()
|
||||||
{
|
{
|
||||||
@ -184,6 +246,17 @@ void MainWindow::on_bgcolor_clicked()
|
|||||||
update_preview();
|
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()
|
void MainWindow::change_options()
|
||||||
{
|
{
|
||||||
bool options;
|
bool options;
|
||||||
|
@ -19,10 +19,16 @@
|
|||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
#include "ui_mainWindow.h"
|
#include "ui_mainWindow.h"
|
||||||
#include "barcodeitem.h"
|
#include "barcodeitem.h"
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
class QActionGroup;
|
||||||
|
class QLabel;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
class MainWindow : public QWidget, private Ui::mainWindow
|
class MainWindow : public QWidget, private Ui::mainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -113,11 +119,24 @@ public slots:
|
|||||||
void mqr_size();
|
void mqr_size();
|
||||||
void mqr_errorcorrect();
|
void mqr_errorcorrect();
|
||||||
void maxi_primary();
|
void maxi_primary();
|
||||||
|
void change_print_scale();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
bool save();
|
||||||
|
void about();
|
||||||
|
void quit_now();
|
||||||
|
/* void about(); */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/* void createActions();
|
||||||
|
void createMenus(); */
|
||||||
|
|
||||||
QColor m_fgcolor,m_bgcolor;
|
QColor m_fgcolor,m_bgcolor;
|
||||||
BarcodeItem m_bc;
|
BarcodeItem m_bc;
|
||||||
|
/* QMenu *fileMenu;
|
||||||
|
QMenu *helpMenu;
|
||||||
|
QAction *saveAct;
|
||||||
|
QAction *aboutQtAct; */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user