From 691b253a1b81fd2c9614caf66c753e4f695663d2 Mon Sep 17 00:00:00 2001 From: hooper114 Date: Tue, 19 May 2009 14:05:26 +0000 Subject: [PATCH] Add save to file and other options --- frontend_qt4/mainWindow.ui | 151 +++++++++++++++++++++++++++++++----- frontend_qt4/mainwindow.cpp | 75 +++++++++++++++++- frontend_qt4/mainwindow.h | 21 ++++- 3 files changed, 225 insertions(+), 22 deletions(-) diff --git a/frontend_qt4/mainWindow.ui b/frontend_qt4/mainWindow.ui index 624946c1..4d02c69f 100644 --- a/frontend_qt4/mainWindow.ui +++ b/frontend_qt4/mainWindow.ui @@ -6,9 +6,27 @@ 0 0 619 - 559 + 596 + + + 0 + 0 + + + + + 619 + 596 + + + + + 619 + 596 + + Zint Barcode Studio @@ -57,6 +75,12 @@ 217 + + + 0 + 0 + + 0 @@ -2317,7 +2341,7 @@ p, li { white-space: pre-wrap; } 10 6 572 - 102 + 140 @@ -2326,9 +2350,9 @@ p, li { white-space: pre-wrap; } - 14 - 19 - 91 + 10 + 18 + 40 21 @@ -2358,9 +2382,9 @@ p, li { white-space: pre-wrap; } - -3 - 43 - 109 + 9 + 39 + 73 29 @@ -2374,9 +2398,9 @@ p, li { white-space: pre-wrap; } - 114 + 118 46 - 124 + 120 21 @@ -2434,9 +2458,9 @@ p, li { white-space: pre-wrap; } - 273 - 51 - 145 + 357 + 92 + 141 26 @@ -2447,9 +2471,9 @@ p, li { white-space: pre-wrap; } - 427 - 51 - 133 + 357 + 57 + 142 26 @@ -2460,8 +2484,8 @@ p, li { white-space: pre-wrap; } - 117 - 73 + 119 + 72 120 22 @@ -2470,8 +2494,8 @@ p, li { white-space: pre-wrap; } - 21 - 73 + 11 + 74 78 16 @@ -2480,6 +2504,38 @@ p, li { white-space: pre-wrap; } Whitespace: + + + + 12 + 103 + 85 + 16 + + + + Printing Scale: + + + + + + 119 + 102 + 119 + 22 + + + + X + + + 0.500000000000000 + + + 1.000000000000000 + + @@ -2517,6 +2573,61 @@ p, li { white-space: pre-wrap; } + + + + 10 + 560 + 75 + 26 + + + + About + + + + + false + + + + 450 + 560 + 75 + 26 + + + + Copy + + + + + + 370 + 560 + 75 + 26 + + + + Save + + + + + + 530 + 560 + 75 + 26 + + + + E&xit + + bstyle diff --git a/frontend_qt4/mainwindow.cpp b/frontend_qt4/mainwindow.cpp index 9e64e2d5..5b7bef48 100644 --- a/frontend_qt4/mainwindow.cpp +++ b/frontend_qt4/mainwindow.cpp @@ -19,13 +19,13 @@ #include #include - #include "mainwindow.h" #include 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;ienumerator(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("

Zint Barcode Studio 0.2

" + "

A simple barcode generator" + "

Requires libzint 2.1.3 or greater." + "

Visit the Zint Project Homepage for more information." + "

Copyright © 2009 Robin Stuart & Bogdan Vatra.
" + "QR Code support by Kentaro Fukuchi.
" + "Released under the GNU General Public License ver. 3" + "

\"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; diff --git a/frontend_qt4/mainwindow.h b/frontend_qt4/mainwindow.h index 63d30b18..ca078640 100644 --- a/frontend_qt4/mainwindow.h +++ b/frontend_qt4/mainwindow.h @@ -19,10 +19,16 @@ #include #include + #include #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