@@ -94,7 +94,7 @@ MainWindow::MainWindow(QWidget *parent) :
9494 args[ AUTOLEVELLERARGS ].insert (" software" , ui->softwareComboBox );
9595 args[ AUTOLEVELLERARGS ].insert (" al-x" , ui->alxDoubleSpinBox );
9696 args[ AUTOLEVELLERARGS ].insert (" al-y" , ui->alyDoubleSpinBox );
97- args[ AUTOLEVELLERARGS ].insert (" al-probefeed" , ui->alprobefeedDoubleSpinBox );
97+ args[ AUTOLEVELLERARGS ].insert (" al-probefeed" , ui->alprobefeedSpinBox );
9898 args[ AUTOLEVELLERARGS ].insert (" al-probeon" , ui->alprobeonLineEdit );
9999 args[ AUTOLEVELLERARGS ].insert (" al-probeoff" , ui->alprobeoffLineEdit );
100100
@@ -171,7 +171,7 @@ void MainWindow::getPostambleFile()
171171 getFilename (ui->postambleLineEdit , " postamble file" );
172172}
173173
174- void MainWindow::getFilename (QLineEdit *saveTo, QString name)
174+ void MainWindow::getFilename (QLineEdit *saveTo, const QString name)
175175{
176176 QString filename;
177177
@@ -191,49 +191,43 @@ void MainWindow::getOutputDirectory()
191191
192192void MainWindow::changeMetricInputUnits (bool metric)
193193{
194- int index;
195- double cfactor;
196- const char *distance[ 2 ] = { " mm " , " in " };
197- const char *speedMin[ 2 ] = { " mm/min " , " in/min " };
198- const char *speedSec[ 2 ] = { " mm/s " , " in/s " };
194+ QDoubleSpinBox *doubleSpinBoxes[] = { ui-> zworkDoubleSpinBox , ui-> zsafeDoubleSpinBox , ui-> offsetDoubleSpinBox ,
195+ ui-> zdrillDoubleSpinBox , ui-> zchangeDoubleSpinBox , ui-> cutterdiameterDoubleSpinBox ,
196+ ui-> zcutDoubleSpinBox , ui-> cutinfeedDoubleSpinBox , ui-> outlinewidthDoubleSpinBox ,
197+ ui-> bridgesDoubleSpinBox , ui-> zbridgesDoubleSpinBox , ui-> alxDoubleSpinBox ,
198+ ui-> alyDoubleSpinBox , ui-> g64DoubleDoubleSpinBox };
199199
200- QDoubleSpinBox *doubleSpinBoxes[] = { ui->zworkDoubleSpinBox , ui->zsafeDoubleSpinBox ,ui->offsetDoubleSpinBox , ui->zdrillDoubleSpinBox ,
201- ui->zchangeDoubleSpinBox , ui->cutterdiameterDoubleSpinBox , ui->zcutDoubleSpinBox ,
202- ui->cutinfeedDoubleSpinBox , ui->outlinewidthDoubleSpinBox , ui->bridgesDoubleSpinBox ,
203- ui->zbridgesDoubleSpinBox , ui->alxDoubleSpinBox , ui->alyDoubleSpinBox ,
204- ui->g64DoubleDoubleSpinBox };
200+ QSpinBox *spinBoxes[] = { ui->millfeedSpinBox , ui->drillfeedSpinBox , ui->cutfeedSpinBox , ui->alprobefeedSpinBox };
205201
206202 const unsigned int doubleSpinBoxesLen = sizeof (doubleSpinBoxes) / sizeof (doubleSpinBoxes[0 ]);
207-
208- if (metric)
209- {
210- index = 0 ;
211- cfactor = 1 /2.54 ;
212- }
213- else
214- {
215- index = 1 ;
216- cfactor = 2.54 ;
217- }
203+ const unsigned int spinBoxesLen = sizeof (spinBoxes) / sizeof (spinBoxes[0 ]);
204+ const double cfactor = metric ? 1 /2.54 : 2.54 ;
205+ const char *distance = metric ? " mm" : " in" ;
206+ const char *speed = metric ? " mm/min" : " in/min" ;
218207
219208 for ( unsigned int i = 0 ; i < doubleSpinBoxesLen; i++ )
220- adjustMetricImperial ( doubleSpinBoxes[i], cfactor, distance[index] );
209+ adjustMetricImperial ( doubleSpinBoxes[i], cfactor, distance );
221210
222- adjustMetricImperial ( ui->millfeedSpinBox , cfactor, speedMin[index] );
223- adjustMetricImperial ( ui->drillfeedSpinBox , cfactor, speedMin[index] );
224- adjustMetricImperial ( ui->cutfeedSpinBox , cfactor, speedMin[index] );
225- adjustMetricImperial ( ui->alprobefeedDoubleSpinBox , cfactor, speedSec[index] );
211+ for ( unsigned int i = 0 ; i < spinBoxesLen; i++ )
212+ adjustMetricImperial ( spinBoxes[i], cfactor, speed );
226213}
227214
228215void MainWindow::adjustMetricImperial (QSpinBox *spinBox, const double cfactor, const QString suffix)
229216{
230- int value = spinBox-> value () ;
231- int maximum = spinBox-> maximum () ;
232- int minimum = spinBox-> minimum () ;
217+ int value;
218+ int maximum;
219+ int minimum;
233220
234- spinBox->setMaximum ( round ( maximum * cfactor ) );
235- spinBox->setMinimum ( round ( minimum * cfactor ) );
236- spinBox->setValue ( round ( value * cfactor ) );
221+ if ( changeMetricImperialValues )
222+ {
223+ value = spinBox->value ();
224+ maximum = spinBox->maximum ();
225+ minimum = spinBox->minimum ();
226+
227+ spinBox->setMaximum ( round ( maximum * cfactor ) );
228+ spinBox->setMinimum ( round ( minimum * cfactor ) );
229+ spinBox->setValue ( round ( value * cfactor ) );
230+ }
237231
238232 spinBox->setSuffix (suffix);
239233}
@@ -455,7 +449,7 @@ void MainWindow::askAndLoadConfFile()
455449 QMessageBox::information (this , " Error" , " The selected file can't be opened" );
456450}
457451
458- bool MainWindow::loadConfFile (QString filename)
452+ bool MainWindow::loadConfFile (const QString filename)
459453{
460454 QFile confFile (this );
461455 QString currentLine;
@@ -508,7 +502,7 @@ void MainWindow::askAndSaveConfFile()
508502 saveConfFile (filename);
509503}
510504
511- void MainWindow::saveConfFile (QString filename)
505+ void MainWindow::saveConfFile (const QString filename)
512506{
513507 QFile confFile (this );
514508 QStringList arguments;
0 commit comments