Skip to content

Commit 0301fff

Browse files
committed
Simplified arguments structure
1 parent 7e4069d commit 0301fff

File tree

4 files changed

+17
-54
lines changed

4 files changed

+17
-54
lines changed

argaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ bool argAction::setValue(const QString key, const QString value)
152152
return false;
153153
}
154154

155-
QStringList argAction::getAllArgs(bool getCommentedOptions)
155+
QStringList argAction::getAllArgs(const QString prepend, bool getCommentedOptions)
156156
{
157157
QStringList output;
158158
QString value;
@@ -163,10 +163,10 @@ QStringList argAction::getAllArgs(bool getCommentedOptions)
163163
if ( !value.isEmpty() )
164164
{
165165
if( static_cast<QWidget *>(i.value().object)->isEnabled() )
166-
output << i.key() + '=' + value;
166+
output << prepend + i.key() + '=' + value;
167167
else
168168
if(getCommentedOptions)
169-
output << "#@#" + i.key() + '=' + value;
169+
output << prepend + "#@#" + i.key() + '=' + value;
170170
}
171171
}
172172

argaction.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,15 @@ class argAction
6666
};
6767

6868
QMap<QString,argElement> argList;
69-
bool stringMarks;
7069

7170
public:
7271
explicit argAction();
7372
~argAction();
7473

7574
bool setValue(const QString key, const QString value);
76-
QStringList getAllArgs(bool getCommentedOptions);
75+
QStringList getAllArgs(const QString prepend, bool getCommentedOptions);
7776
bool setEnabled(const QString key, const bool enabled);
7877

79-
inline void setStringMarks (bool stringMarks)
80-
{
81-
this->stringMarks = stringMarks;
82-
}
83-
8478
inline void insert( const QString argName, QDoubleSpinBox *doubleSpinBox)
8579
{
8680
argList.insert( argName, (argElement){ .setFunction = &setDoubleSpinBox, .getFunction = &getDoubleSpinBox,

mainwindow.cpp

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ MainWindow::MainWindow(QWidget *parent) :
106106
args[ AUTOLEVELLERARGS ].insert("al-x", ui->alxDoubleSpinBox);
107107
args[ AUTOLEVELLERARGS ].insert("al-y", ui->alyDoubleSpinBox);
108108
args[ AUTOLEVELLERARGS ].insert("al-probefeed", ui->alprobefeedSpinBox);
109-
args[ AUTOLEVELLERARGS ].insert("al-probeon", ui->alprobeonLineEdit);
110-
args[ AUTOLEVELLERARGS ].insert("al-probeoff", ui->alprobeoffLineEdit);
109+
args[ AUTOLEVELLERARGS ].insert("al-probe-on", ui->alprobeonLineEdit);
110+
args[ AUTOLEVELLERARGS ].insert("al-probe-off", ui->alprobeoffLineEdit);
111111

112112
connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
113113
connect(ui->actionAbout_pcb2gcode, SIGNAL(triggered()), this, SLOT(menu_aboutpcb2gcode()));
@@ -281,55 +281,22 @@ void MainWindow::adjustMetricImperial(QDoubleSpinBox *doubleSpinBox, const doubl
281281
QStringList MainWindow::getCmdLineArguments()
282282
{
283283
QStringList arguments;
284-
int i;
285-
int pos;
286284

287-
for( i = FILEARGS; i <= AUTOLEVELLERARGS; i++ )
288-
args[i].setStringMarks(true);
289-
290-
arguments += args[ FILEARGS ].getAllArgs(false);
291-
arguments += args[ COMMONARGS ].getAllArgs(false);
285+
arguments += args[ FILEARGS ].getAllArgs("--", false);
286+
arguments += args[ COMMONARGS ].getAllArgs("--", false);
292287

293288
if( !ui->frontLineEdit->text().isEmpty() || !ui->backLineEdit->text().isEmpty() )
294-
arguments += args[ MILLARGS ].getAllArgs(false);
289+
arguments += args[ MILLARGS ].getAllArgs("--", false);
295290

296291
if( !ui->drillLineEdit->text().isEmpty() )
297-
arguments += args[ DRILLARGS ].getAllArgs(false);
292+
arguments += args[ DRILLARGS ].getAllArgs("--", false);
298293

299294
if( !ui->outlineLineEdit->text().isEmpty() || ui->milldrillCheckBox->isChecked() )
300-
arguments += args[ OUTLINEARGS ].getAllArgs(false);
295+
arguments += args[ OUTLINEARGS ].getAllArgs("--", false);
301296

302297
if ( (ui->alfrontCheckBox->isChecked() || ui->albackCheckBox->isChecked()) &&
303298
(!ui->frontLineEdit->text().isEmpty() || !ui->backLineEdit->text().isEmpty()) )
304-
arguments += args[ AUTOLEVELLERARGS ].getAllArgs(false);
305-
306-
i = 0;
307-
308-
while( i < arguments.size() )
309-
{
310-
if( arguments[i].contains("al-probe-") )
311-
{
312-
pos = arguments[i].indexOf('=');
313-
314-
if( pos > 0 )
315-
{
316-
arguments[i].prepend("--");
317-
arguments[i].insert( pos + 1, '\'');
318-
arguments[i].append('\'');
319-
i++;
320-
}
321-
else
322-
arguments.removeAt(i);
323-
}
324-
else if( !arguments[i].contains("=false") ) //Remove lines with a false boolean option ("--metric=false")
325-
{
326-
arguments[i].remove("=true"); //Remove =true ("--metric=true" --> "--metric")
327-
arguments[i].prepend("--"); //Add the "--"
328-
i++;
329-
}
330-
else
331-
arguments.removeAt(i);
332-
}
299+
arguments += args[ AUTOLEVELLERARGS ].getAllArgs("--", false);
333300

334301
return arguments;
335302
}
@@ -586,8 +553,7 @@ void MainWindow::saveConfFile(const QString filename)
586553

587554
for( int i = COMMONARGS; i <= AUTOLEVELLERARGS; i++ )
588555
{
589-
args[i].setStringMarks(false);
590-
arguments = args[i].getAllArgs(true);
556+
arguments = args[i].getAllArgs("", true);
591557
confFile.write( QString("# " + names[i] + " options\n").toLatin1() );
592558

593559
for( QStringList::const_iterator j = arguments.begin(); j != arguments.constEnd(); j++ )

mainwindow.ui

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<enum>QTabWidget::Rounded</enum>
4646
</property>
4747
<property name="currentIndex">
48-
<number>2</number>
48+
<number>0</number>
4949
</property>
5050
<widget class="QWidget" name="commonTab">
5151
<attribute name="title">
@@ -1133,6 +1133,9 @@
11331133
<property name="toolTip">
11341134
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Insert these commands at the start of the probing sequence. You can use this argument to add a M64/M65 command (LinuxCNC) to automatically enable the probe tool. Use a at sign (@) to insert a newline&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
11351135
</property>
1136+
<property name="placeholderText">
1137+
<string/>
1138+
</property>
11361139
</widget>
11371140
</item>
11381141
<item row="7" column="1">

0 commit comments

Comments
 (0)