Expand GUI for sequencing and input from file

This commit is contained in:
hooper114 2009-09-17 08:01:49 +00:00
parent 467433f0d0
commit 0bce27959f
11 changed files with 1375 additions and 642 deletions

View File

@ -4,10 +4,10 @@ project(zint-qt)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt4") include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt4")
set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp) set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp)
QT4_WRAP_CPP(zint-qt_SRCS mainwindow.h) QT4_WRAP_CPP(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h)
QT4_WRAP_UI(zint-qt_SRCS mainWindow.ui ) QT4_WRAP_UI(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui)
# grpAztec.ui grpC39.ui grpDM.ui grpMSICheck.ui # grpAztec.ui grpC39.ui grpDM.ui grpMSICheck.ui
# grpC128.ui grpChannel.ui grpMicroPDF.ui grpPDF417.ui # grpC128.ui grpChannel.ui grpMicroPDF.ui grpPDF417.ui
# grpC16k.ui grpCodablock.ui grpMQR.ui grpQR.ui # grpC16k.ui grpCodablock.ui grpMQR.ui grpQR.ui

View File

@ -0,0 +1,79 @@
#include <QDebug>
#include <QFileDialog>
#include <QUiLoader>
#include <QStringList>
#include "datawindow.h"
#include <stdio.h>
DataWindow::DataWindow()
{
setupUi(this);
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
}
DataWindow::DataWindow(QString input)
{
setupUi(this);
txtDataInput->setPlainText(input);
txtDataInput->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor);
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL( clicked( bool )), SLOT(clear_data()));
connect(btnOK, SIGNAL( clicked( bool )), SLOT(okay()));
connect(btnFromFile, SIGNAL( clicked( bool )), SLOT(from_file()));
}
DataWindow::~DataWindow()
{
}
void DataWindow::quit_now()
{
Valid = 0;
close();
}
void DataWindow::clear_data()
{
txtDataInput->clear();
}
void DataWindow::okay()
{
Valid = 1;
DataOutput = txtDataInput->toPlainText();
close();
}
void DataWindow::from_file()
{
QString fileName;
QFileDialog fdialog;
QFile file;
char *streamdata;
int streamlen;
QString utfstream;
fdialog.setFileMode(QFileDialog::ExistingFile);
if(fdialog.exec()) {
fileName = fdialog.selectedFiles().at(0);
} else {
return;
}
file.setFileName(fileName);
if(!file.open(QIODevice::ReadOnly)) {
return;
}
QDataStream input(&file);
streamlen = input.readRawData(streamdata, 7095);
utfstream = streamdata; /* FIXME: Does not take account of encoding scheme of input data */
txtDataInput->setPlainText(utfstream);
file.close();
}

24
frontend_qt4/datawindow.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef DATAWINDOW_H
#define DATAWINDOW_H
#include "ui_extData.h"
class DataWindow : public QDialog, private Ui::DataDialog
{
Q_OBJECT
public:
DataWindow();
DataWindow(QString input);
~DataWindow();
int Valid;
QString DataOutput;
private slots:
void quit_now();
void clear_data();
void okay();
void from_file();
};
#endif

98
frontend_qt4/extData.ui Normal file
View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DataDialog</class>
<widget class="QDialog" name="DataDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Input Data</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QPlainTextEdit" name="txtDataInput">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>381</width>
<height>221</height>
</rect>
</property>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>381</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btnFromFile">
<property name="text">
<string>From File...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnReset">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnOK">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>56</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Data</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

173
frontend_qt4/extExport.ui Normal file
View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ExportDialog</class>
<widget class="QDialog" name="ExportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>170</height>
</rect>
</property>
<property name="windowTitle">
<string>Export Barcodes</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>431</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLineEdit" name="linDestPath">
<property name="geometry">
<rect>
<x>140</x>
<y>10</y>
<width>261</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="linPrefix">
<property name="geometry">
<rect>
<x>140</x>
<y>40</y>
<width>301</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="cmbFileName">
<property name="geometry">
<rect>
<x>140</x>
<y>70</y>
<width>301</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="cmbFileFormat">
<property name="geometry">
<rect>
<x>140</x>
<y>100</y>
<width>301</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QToolButton" name="btnDestPath">
<property name="geometry">
<rect>
<x>410</x>
<y>10</y>
<width>30</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Destination Path:</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>File Name Prefix:</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>File Name:</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>File Format:</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ExportDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ExportDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

269
frontend_qt4/extSequence.ui Normal file
View File

@ -0,0 +1,269 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SequenceDialog</class>
<widget class="QDialog" name="SequenceDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>530</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Sequence Export</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>261</width>
<height>241</height>
</rect>
</property>
<property name="title">
<string>Create Sequence</string>
</property>
<widget class="QPushButton" name="btnExport">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>140</x>
<y>200</y>
<width>111</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Export...</string>
</property>
</widget>
<widget class="QPushButton" name="btnCreate">
<property name="geometry">
<rect>
<x>140</x>
<y>140</y>
<width>111</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Create</string>
</property>
</widget>
<widget class="QLineEdit" name="linStartVal">
<property name="geometry">
<rect>
<x>140</x>
<y>20</y>
<width>111</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
<widget class="QSpinBox" name="spnIncrement">
<property name="geometry">
<rect>
<x>139</x>
<y>80</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
<widget class="QLineEdit" name="linFormat">
<property name="geometry">
<rect>
<x>140</x>
<y>110</y>
<width>111</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>$$$$$$</string>
</property>
</widget>
<widget class="QLineEdit" name="linEndVal">
<property name="geometry">
<rect>
<x>140</x>
<y>50</y>
<width>111</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>10</string>
</property>
</widget>
<widget class="QPushButton" name="btnImport">
<property name="geometry">
<rect>
<x>140</x>
<y>170</y>
<width>111</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Import...</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>151</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Start Value:</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>171</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>End Value:</string>
</property>
</widget>
<widget class="QLabel" name="lblIncrement">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>171</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Increment By:</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>171</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Format:</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>161</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Sequence:</string>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>10</x>
<y>170</y>
<width>161</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Sequence File:</string>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>10</x>
<y>200</y>
<width>161</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Generate Bar Codes:</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>280</x>
<y>10</y>
<width>241</width>
<height>241</height>
</rect>
</property>
<property name="title">
<string>Sequence Preview</string>
</property>
<widget class="QPlainTextEdit" name="txtPreview">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>221</width>
<height>171</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="btnReset">
<property name="geometry">
<rect>
<x>150</x>
<y>200</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</widget>
<widget class="QPushButton" name="btnClose">
<property name="geometry">
<rect>
<x>440</x>
<y>260</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,8 @@
#include <QFile> #include <QFile>
#include "mainwindow.h" #include "mainwindow.h"
#include "datawindow.h"
#include "sequencewindow.h"
#include <stdio.h> #include <stdio.h>
MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl) MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
@ -126,6 +128,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WFlags fl)
connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale())); connect(spnScale, SIGNAL(valueChanged( double )), SLOT(change_print_scale()));
connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now())); connect(btnExit, SIGNAL(clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL(clicked( bool )), SLOT(reset_view())); connect(btnReset, SIGNAL(clicked( bool )), SLOT(reset_view()));
connect(btnMoreData, SIGNAL(clicked( bool )), SLOT(open_data_dialog()));
connect(btnSequence, SIGNAL(clicked( bool )), SLOT(open_sequence_dialog()));
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -181,6 +185,22 @@ void MainWindow::about()
)); ));
} }
int MainWindow::open_data_dialog()
{
int retval;
DataWindow dlg(txtData->text());
retval = dlg.exec();
if (dlg.Valid == 1)
txtData->setText(dlg.DataOutput);
return retval;
}
int MainWindow::open_sequence_dialog()
{
SequenceWindow dlg;
return dlg.exec();
}
void MainWindow::on_fgcolor_clicked() void MainWindow::on_fgcolor_clicked()
{ {
m_fgcolor=QColorDialog::getColor(m_fgcolor,this); m_fgcolor=QColorDialog::getColor(m_fgcolor,this);

View File

@ -123,6 +123,8 @@ private slots:
void about(); void about();
void quit_now(); void quit_now();
void reset_view(); void reset_view();
int open_data_dialog();
int open_sequence_dialog();
private: private:
/* void createActions(); /* void createActions();

View File

@ -0,0 +1,28 @@
#include <QDebug>
#include <QFile>
#include <QUiLoader>
#include "sequencewindow.h"
#include <stdio.h>
SequenceWindow::SequenceWindow()
{
setupUi(this);
connect(btnClose, SIGNAL( clicked( bool )), SLOT(quit_now()));
connect(btnReset, SIGNAL( clicked( bool )), SLOT(reset_preview()));
}
SequenceWindow::~SequenceWindow()
{
}
void SequenceWindow::quit_now()
{
close();
}
void SequenceWindow::reset_preview()
{
txtPreview->clear();
}

View File

@ -0,0 +1,19 @@
#ifndef SEQUENCEWINDOW_H
#define SEQUENCEWINDOW_H
#include "ui_extSequence.h"
class SequenceWindow : public QDialog, private Ui::SequenceDialog
{
Q_OBJECT
public:
SequenceWindow();
~SequenceWindow();
private slots:
void quit_now();
void reset_preview();
};
#endif