Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/commandwidget.cpp
Show All 33 Lines | 25 | { | |||
---|---|---|---|---|---|
34 | lineCommand = new QLineEdit(this); | 34 | lineCommand = new QLineEdit(this); | ||
35 | lineCommand->setPlaceholderText(tr("Send Command")); | 35 | lineCommand->setPlaceholderText(tr("Send Command")); | ||
36 | 36 | | |||
37 | //we have a few buttons to make here. Lets name this newButton so its easier to reuse | 37 | //we have a few buttons to make here. Lets name this newButton so its easier to reuse | ||
38 | auto newButton = new QPushButton(tr("Send"), this); | 38 | auto newButton = new QPushButton(tr("Send"), this); | ||
39 | connect(newButton, &QPushButton::clicked, this, [this] { | 39 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
40 | if (!lineCommand->text().isEmpty()) | 40 | if (!lineCommand->text().isEmpty()) | ||
41 | { | 41 | { | ||
42 | if (lineCommand->text().startsWith(QStringLiteral("g"))) { | ||||
43 | lineCommand->setText(lineCommand->text().replace(0, 1, QStringLiteral("G"))); | ||||
44 | } else if (lineCommand->text().startsWith(QStringLiteral("m"))) { | ||||
45 | lineCommand->setText(lineCommand->text().replace(0, 1, QStringLiteral("M"))); | ||||
46 | } | ||||
42 | emit commandPressed(lineCommand->text()); | 47 | emit commandPressed(lineCommand->text()); | ||
43 | lineCommand->clear(); | 48 | lineCommand->clear(); | ||
44 | } | 49 | } | ||
45 | }); | 50 | }); | ||
46 | //When you have created a Row put the items into layout. | 51 | //When you have created a Row put the items into layout. | ||
47 | auto hBoxLayout = new QHBoxLayout; | 52 | auto hBoxLayout = new QHBoxLayout; | ||
48 | hBoxLayout->addWidget(lineCommand); | 53 | hBoxLayout->addWidget(lineCommand); | ||
49 | hBoxLayout->addWidget(newButton); | 54 | hBoxLayout->addWidget(newButton); | ||
Show All 27 Lines |