Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/movementwidget.cpp
Show All 21 Lines | |||||
22 | #include "axiscontrol.h" | 22 | #include "axiscontrol.h" | ||
23 | #include "movementwidget.h" | 23 | #include "movementwidget.h" | ||
24 | 24 | | |||
25 | MovementWidget::MovementWidget(bool showHomeAndDisableWidgets, QWidget *parent) : | 25 | MovementWidget::MovementWidget(bool showHomeAndDisableWidgets, QWidget *parent) : | ||
26 | QWidget(parent) | 26 | QWidget(parent) | ||
27 | { | 27 | { | ||
28 | auto mainLayout = new QVBoxLayout; | 28 | auto mainLayout = new QVBoxLayout; | ||
29 | auto hBoxLayout = new QHBoxLayout; | 29 | auto hBoxLayout = new QHBoxLayout; | ||
30 | auto newButton = new QPushButton; | 30 | auto newButton = new QPushButton(this); | ||
31 | 31 | | |||
32 | if (showHomeAndDisableWidgets) { | 32 | if (showHomeAndDisableWidgets) { | ||
33 | newButton = new QPushButton(tr("Home All")); | 33 | newButton = new QPushButton(tr("Home All"), this); | ||
34 | hBoxLayout->addWidget(newButton); | 34 | hBoxLayout->addWidget(newButton); | ||
35 | connect(newButton, &QPushButton::clicked, this, [this] { | 35 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
36 | emit homeAllPressed(); | 36 | emit homeAllPressed(); | ||
37 | }); | 37 | }); | ||
38 | 38 | | |||
39 | newButton = new QPushButton(tr("Home X")); | 39 | newButton = new QPushButton(tr("Home X"), this); | ||
40 | hBoxLayout->addWidget(newButton); | 40 | hBoxLayout->addWidget(newButton); | ||
41 | connect(newButton, &QPushButton::clicked, this, [this] { | 41 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
42 | emit homeXPressed(); | 42 | emit homeXPressed(); | ||
43 | }); | 43 | }); | ||
44 | 44 | | |||
45 | newButton = new QPushButton(tr("Home Y")); | 45 | newButton = new QPushButton(tr("Home Y"), this); | ||
46 | hBoxLayout->addWidget(newButton); | 46 | hBoxLayout->addWidget(newButton); | ||
47 | connect(newButton, &QPushButton::clicked, this, [this] { | 47 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
48 | emit homeYPressed(); | 48 | emit homeYPressed(); | ||
49 | }); | 49 | }); | ||
50 | 50 | | |||
51 | newButton = new QPushButton(tr("Home Z")); | 51 | newButton = new QPushButton(tr("Home Z"), this); | ||
52 | hBoxLayout->addWidget(newButton); | 52 | hBoxLayout->addWidget(newButton); | ||
53 | connect(newButton, &QPushButton::clicked, this, [this] { | 53 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
54 | emit homeZPressed(); | 54 | emit homeZPressed(); | ||
55 | }); | 55 | }); | ||
56 | mainLayout->addLayout(hBoxLayout); | 56 | mainLayout->addLayout(hBoxLayout); | ||
57 | 57 | | |||
58 | newButton = new QPushButton(tr("Disable Motors")); | 58 | newButton = new QPushButton(tr("Disable Motors"), this); | ||
59 | mainLayout->addWidget(newButton); | 59 | mainLayout->addWidget(newButton); | ||
60 | connect(newButton, &QPushButton::clicked, this, [this] { | 60 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
61 | emit disableMotorsPressed(); | 61 | emit disableMotorsPressed(); | ||
62 | }); | 62 | }); | ||
63 | 63 | | |||
64 | } | 64 | } | ||
65 | comboMoveAxis = new QComboBox; | 65 | comboMoveAxis = new QComboBox(this); | ||
66 | comboMoveAxis->addItem(tr("Move X Axis to")); | 66 | comboMoveAxis->addItem(tr("Move X Axis to")); | ||
67 | comboMoveAxis->addItem(tr("Move Y Axis to")); | 67 | comboMoveAxis->addItem(tr("Move Y Axis to")); | ||
68 | comboMoveAxis->addItem(tr("Move Z Axis to")); | 68 | comboMoveAxis->addItem(tr("Move Z Axis to")); | ||
69 | 69 | | |||
70 | sbMoveAxis = new QDoubleSpinBox; | 70 | sbMoveAxis = new QDoubleSpinBox(this); | ||
71 | sbMoveAxis->setRange(0, 200); | 71 | sbMoveAxis->setRange(0, 200); | ||
72 | 72 | | |||
73 | newButton = new QPushButton(tr("Go")); | 73 | newButton = new QPushButton(tr("Go"), this); | ||
74 | connect(newButton, &QPushButton::clicked, this, [this] { | 74 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
75 | if (comboMoveAxis->currentIndex() == 0) | 75 | if (comboMoveAxis->currentIndex() == 0) | ||
76 | { | 76 | { | ||
77 | emit absoluteMove(QLatin1Char('X'), sbMoveAxis->value()); | 77 | emit absoluteMove(QLatin1Char('X'), sbMoveAxis->value()); | ||
78 | } else if (comboMoveAxis->currentIndex() == 1) | 78 | } else if (comboMoveAxis->currentIndex() == 1) | ||
79 | { | 79 | { | ||
80 | emit absoluteMove(QLatin1Char('Y'), sbMoveAxis->value()); | 80 | emit absoluteMove(QLatin1Char('Y'), sbMoveAxis->value()); | ||
81 | } else if (comboMoveAxis->currentIndex() == 2) | 81 | } else if (comboMoveAxis->currentIndex() == 2) | ||
82 | { | 82 | { | ||
83 | emit absoluteMove(QLatin1Char('Z'), sbMoveAxis->value()); | 83 | emit absoluteMove(QLatin1Char('Z'), sbMoveAxis->value()); | ||
84 | } | 84 | } | ||
85 | }); | 85 | }); | ||
86 | 86 | | |||
87 | hBoxLayout = new QHBoxLayout; | 87 | hBoxLayout = new QHBoxLayout; | ||
88 | hBoxLayout->addWidget(comboMoveAxis); | 88 | hBoxLayout->addWidget(comboMoveAxis); | ||
89 | hBoxLayout->addWidget(sbMoveAxis); | 89 | hBoxLayout->addWidget(sbMoveAxis); | ||
90 | hBoxLayout->addWidget(newButton); | 90 | hBoxLayout->addWidget(newButton); | ||
91 | mainLayout->addLayout(hBoxLayout); | 91 | mainLayout->addLayout(hBoxLayout); | ||
92 | 92 | | |||
93 | auto axisControl = new AxisControl; | 93 | auto axisControl = new AxisControl(this); | ||
94 | mainLayout->addWidget(axisControl); | 94 | mainLayout->addWidget(axisControl); | ||
95 | connect(axisControl, &AxisControl::clicked, this, &MovementWidget::relativeMove); | 95 | connect(axisControl, &AxisControl::clicked, this, &MovementWidget::relativeMove); | ||
96 | connect(axisControl, &AxisControl::unitsChanged, this, &MovementWidget::unitsChanged); | 96 | connect(axisControl, &AxisControl::unitsChanged, this, &MovementWidget::unitsChanged); | ||
97 | 97 | | |||
98 | setLayout(mainLayout); | 98 | setLayout(mainLayout); | ||
99 | } | 99 | } |