From d50d077508f3607c02b5eb874402727e40924116 Mon Sep 17 00:00:00 2001 From: NeoTheFox Date: Sat, 7 Mar 2015 17:21:54 +0300 Subject: [PATCH] Ui polish and input validation --- eepromwindow.cpp | 41 ++++++++----- eepromwindow.h | 1 - eepromwindow.ui | 3 + settingswindow.ui | 144 +++++++++++++++++++++++----------------------- 4 files changed, 101 insertions(+), 88 deletions(-) diff --git a/eepromwindow.cpp b/eepromwindow.cpp index f840856..bf08766 100644 --- a/eepromwindow.cpp +++ b/eepromwindow.cpp @@ -28,24 +28,34 @@ EEPROMWindow::EEPROMWindow(QStringList eepromLines, QWidget *parent) : QString msg; for(int i = 3; i < tmp.size(); i++) msg+=(tmp.at(i) + " "); - QLayout *line = new QHBoxLayout(); + QLayout *line = new QGridLayout(); QLabel *label = new QLabel(msg, this); QLineEdit *edit = new QLineEdit(currentLine.S,this); - //QCheckBox *changebox = new QCheckBox("Save", this); - //changebox->setObjectName("b"+QString::number(j)); + QFrame* hline = new QFrame(); + hline->setFrameShape(QFrame::HLine); + hline->setFrameShadow(QFrame::Sunken); + line->addWidget(hline); + edit->setObjectName("e"+QString::number(j)); + QIntValidator *intvalidator = new QIntValidator(this); + QRegExpValidator *doublevalidator = new QRegExpValidator( + QRegExp("^\\-?\\d+\\.?\\d+(e\\-?\\d+)?$", + Qt::CaseInsensitive), this); + intvalidator->setLocale(QLocale::English); + doublevalidator->setLocale(QLocale::English); + switch(currentLine.T) // set right validator for the line { case 0: case 1: case 2: - edit->setValidator(new QIntValidator(this)); + edit->setValidator(intvalidator); break; case 3: - //edit->setValidator(new QDoubleValidator(this)); + edit->setValidator(doublevalidator); break; default: break; @@ -82,22 +92,23 @@ void EEPROMWindow::lineChanged(QString s) void EEPROMWindow::on_buttonBox_accepted() { + QStringList gcode; for(int i=0; i < changed.size(); i++) { if(changed.at(i)) { - QString tmp; + QString command; - tmp+=QString("M206"); - tmp+=QString("T"); - tmp+=QString::number(lines.at(i).T); - tmp+=QString("P"); - tmp+=QString::number(lines.at(i).P); - if(lines.at(i).T == 3) tmp+=QString("X"); - else tmp+=QString("S"); - tmp+=lines.at(i).S; + command+=QString("M206"); + command+=QString("T"); + command+=QString::number(lines.at(i).T); + command+=QString("P"); + command+=QString::number(lines.at(i).P); + if(lines.at(i).T == 3) command+=QString("X"); + else command+=QString("S"); + command+=lines.at(i).S; - gcode.append(tmp); + gcode.append(command); } } diff --git a/eepromwindow.h b/eepromwindow.h index 0a48865..8c48792 100644 --- a/eepromwindow.h +++ b/eepromwindow.h @@ -24,7 +24,6 @@ private: Ui::EEPROMWindow *ui; QVector lines; QVector changed; - QStringList gcode; signals: void changesComplete(QStringList changed); diff --git a/eepromwindow.ui b/eepromwindow.ui index 1abae40..a253471 100644 --- a/eepromwindow.ui +++ b/eepromwindow.ui @@ -22,6 +22,9 @@ 0 + + + true diff --git a/settingswindow.ui b/settingswindow.ui index 3880247..1de73c8 100644 --- a/settingswindow.ui +++ b/settingswindow.ui @@ -18,6 +18,78 @@ :/icons/settings.png:/icons/settings.png + + + + + 0 + 0 + + + + Printer + + + + + + 1 + + + 9999 + + + + + + + X + + + + + + + 1 + + + 9999 + + + + + + + Bed size + + + + + + + Firmware + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + true + + + @@ -152,78 +224,6 @@ - - - - - 0 - 0 - - - - Printer - - - - - - 1 - - - 9999 - - - - - - - X - - - - - - - 1 - - - 9999 - - - - - - - Bed size - - - - - - - Firmware - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - true - - -