Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/printwidget.cpp
Show All 23 Lines | |||||
24 | PrintWidget::PrintWidget(bool showAllControls, QWidget *parent) : | 24 | PrintWidget::PrintWidget(bool showAllControls, QWidget *parent) : | ||
25 | QWidget(parent) | 25 | QWidget(parent) | ||
26 | { | 26 | { | ||
27 | auto mainLayout = new QVBoxLayout; | 27 | auto mainLayout = new QVBoxLayout; | ||
28 | QPushButton *newButton = nullptr; | 28 | QPushButton *newButton = nullptr; | ||
29 | QLabel *newLabel = nullptr; | 29 | QLabel *newLabel = nullptr; | ||
30 | QHBoxLayout *hBoxLayout = nullptr; | 30 | QHBoxLayout *hBoxLayout = nullptr; | ||
31 | if (showAllControls) { | 31 | if (showAllControls) { | ||
32 | buttonPrint = new QPushButton(tr("Print File")); | 32 | buttonPrint = new QPushButton(tr("Print File"), this); | ||
33 | connect(buttonPrint, &QPushButton::clicked, this, [this] { | 33 | connect(buttonPrint, &QPushButton::clicked, this, [this] { | ||
34 | emit printPressed(); | 34 | emit printPressed(); | ||
35 | }); | 35 | }); | ||
36 | 36 | | |||
37 | newButton = new QPushButton(tr("Emergency Stop")); | 37 | newButton = new QPushButton(tr("Emergency Stop"), this); | ||
38 | connect(newButton, &QPushButton::clicked, this, [this] { | 38 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
39 | emit emergencyStopPressed(); | 39 | emit emergencyStopPressed(); | ||
40 | }); | 40 | }); | ||
41 | 41 | | |||
42 | hBoxLayout = new QHBoxLayout; | 42 | hBoxLayout = new QHBoxLayout; | ||
43 | hBoxLayout->addWidget(buttonPrint); | 43 | hBoxLayout->addWidget(buttonPrint); | ||
44 | hBoxLayout->addWidget(newButton); | 44 | hBoxLayout->addWidget(newButton); | ||
45 | mainLayout->addLayout(hBoxLayout); | 45 | mainLayout->addLayout(hBoxLayout); | ||
46 | 46 | | |||
47 | newLabel = new QLabel(tr("On Pause:")); | 47 | newLabel = new QLabel(tr("On Pause:"), this); | ||
48 | 48 | | |||
49 | linePostPause = new QLineEdit; | 49 | linePostPause = new QLineEdit(this); | ||
50 | linePostPause->setPlaceholderText(QStringLiteral("G91,G0 Z1,G90,G1 X0 Y195")); | 50 | linePostPause->setPlaceholderText(QStringLiteral("G91,G0 Z1,G90,G1 X0 Y195")); | ||
51 | 51 | | |||
52 | hBoxLayout = new QHBoxLayout; | 52 | hBoxLayout = new QHBoxLayout; | ||
53 | hBoxLayout->addWidget(newLabel); | 53 | hBoxLayout->addWidget(newLabel); | ||
54 | hBoxLayout->addWidget(linePostPause); | 54 | hBoxLayout->addWidget(linePostPause); | ||
55 | mainLayout->addLayout(hBoxLayout); | 55 | mainLayout->addLayout(hBoxLayout); | ||
56 | } | 56 | } | ||
57 | 57 | | |||
58 | newLabel = new QLabel(tr("Printer Speed")); | 58 | newLabel = new QLabel(tr("Printer Speed"), this); | ||
59 | sbPrintSpeed = new QSpinBox; | 59 | sbPrintSpeed = new QSpinBox(this); | ||
60 | sbPrintSpeed->setRange(1, 300); | 60 | sbPrintSpeed->setRange(1, 300); | ||
61 | sbPrintSpeed->setValue(100); | 61 | sbPrintSpeed->setValue(100); | ||
62 | sbPrintSpeed->setSuffix(QStringLiteral("%")); | 62 | sbPrintSpeed->setSuffix(QStringLiteral("%")); | ||
63 | 63 | | |||
64 | newButton = new QPushButton(tr("Set")); | 64 | newButton = new QPushButton(tr("Set"), this); | ||
65 | connect(newButton, &QPushButton::clicked, this, [this] { | 65 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
66 | emit printSpeedChanged(sbPrintSpeed->value()); | 66 | emit printSpeedChanged(sbPrintSpeed->value()); | ||
67 | }); | 67 | }); | ||
68 | 68 | | |||
69 | hBoxLayout = new QHBoxLayout; | 69 | hBoxLayout = new QHBoxLayout; | ||
70 | hBoxLayout->addWidget(newLabel, 60); | 70 | hBoxLayout->addWidget(newLabel, 60); | ||
71 | hBoxLayout->addWidget(sbPrintSpeed, 20); | 71 | hBoxLayout->addWidget(sbPrintSpeed, 20); | ||
72 | hBoxLayout->addWidget(newButton, 20); | 72 | hBoxLayout->addWidget(newButton, 20); | ||
73 | mainLayout->addLayout(hBoxLayout); | 73 | mainLayout->addLayout(hBoxLayout); | ||
74 | 74 | | |||
75 | newLabel = new QLabel(tr("Flow Rate")); | 75 | newLabel = new QLabel(tr("Flow Rate"), this); | ||
76 | sbFlowRate = new QSpinBox; | 76 | sbFlowRate = new QSpinBox(this); | ||
77 | sbFlowRate->setRange(1, 300); | 77 | sbFlowRate->setRange(1, 300); | ||
78 | sbFlowRate->setValue(100); | 78 | sbFlowRate->setValue(100); | ||
79 | sbFlowRate->setSuffix(QStringLiteral("%")); | 79 | sbFlowRate->setSuffix(QStringLiteral("%")); | ||
80 | 80 | | |||
81 | newButton = new QPushButton(tr("Set")); | 81 | newButton = new QPushButton(tr("Set"), this); | ||
82 | connect(newButton, &QPushButton::clicked, this, [this] { | 82 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
83 | emit flowRateChanged(sbFlowRate->value()); | 83 | emit flowRateChanged(sbFlowRate->value()); | ||
84 | }); | 84 | }); | ||
85 | hBoxLayout = new QHBoxLayout; | 85 | hBoxLayout = new QHBoxLayout; | ||
86 | hBoxLayout->addWidget(newLabel, 60); | 86 | hBoxLayout->addWidget(newLabel, 60); | ||
87 | hBoxLayout->addWidget(sbFlowRate, 20); | 87 | hBoxLayout->addWidget(sbFlowRate, 20); | ||
88 | hBoxLayout->addWidget(newButton, 20); | 88 | hBoxLayout->addWidget(newButton, 20); | ||
89 | mainLayout->addLayout(hBoxLayout); | 89 | mainLayout->addLayout(hBoxLayout); | ||
90 | 90 | | |||
91 | comboFanSelect = new QComboBox; | 91 | comboFanSelect = new QComboBox(this); | ||
92 | sbFanSpeed = new QSpinBox; | 92 | sbFanSpeed = new QSpinBox(this); | ||
93 | sbFanSpeed->setRange(0, 100); | 93 | sbFanSpeed->setRange(0, 100); | ||
94 | sbFanSpeed->setSuffix(QStringLiteral("%")); | 94 | sbFanSpeed->setSuffix(QStringLiteral("%")); | ||
95 | 95 | | |||
96 | newButton = new QPushButton(tr("Set")); | 96 | newButton = new QPushButton(tr("Set"), this); | ||
97 | connect(newButton, &QPushButton::clicked, this, [this] { | 97 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
98 | //Fan speed has a range of 0-255. | 98 | //Fan speed has a range of 0-255. | ||
99 | int speed = sbFanSpeed->value() * 255 / 100; | 99 | int speed = sbFanSpeed->value() * 255 / 100; | ||
100 | emit fanSpeedChanged(speed, comboFanSelect->currentIndex()); | 100 | emit fanSpeedChanged(speed, comboFanSelect->currentIndex()); | ||
101 | }); | 101 | }); | ||
102 | 102 | | |||
103 | hBoxLayout = new QHBoxLayout; | 103 | hBoxLayout = new QHBoxLayout; | ||
104 | hBoxLayout->addWidget(comboFanSelect, 60); | 104 | hBoxLayout->addWidget(comboFanSelect, 60); | ||
105 | hBoxLayout->addWidget(sbFanSpeed, 20); | 105 | hBoxLayout->addWidget(sbFanSpeed, 20); | ||
106 | hBoxLayout->addWidget(newButton, 20); | 106 | hBoxLayout->addWidget(newButton, 20); | ||
107 | mainLayout->addLayout(hBoxLayout); | 107 | mainLayout->addLayout(hBoxLayout); | ||
108 | 108 | | |||
109 | setLayout(mainLayout); | 109 | setLayout(mainLayout); | ||
110 | } | 110 | } | ||
111 | 111 | | |||
112 | QString PrintWidget::postPauseCommand(void) const | 112 | QString PrintWidget::postPauseCommand() const | ||
113 | { | 113 | { | ||
114 | return linePostPause->text(); | 114 | return linePostPause->text(); | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | void PrintWidget::setPrintText(const QString &text) | 117 | void PrintWidget::setPrintText(const QString &text) | ||
118 | { | 118 | { | ||
119 | buttonPrint->setText(text); | 119 | buttonPrint->setText(text); | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | void PrintWidget::updateFanCount(const int count) | 122 | void PrintWidget::updateFanCount(const int count) | ||
123 | { | 123 | { | ||
124 | comboFanSelect->clear(); | 124 | comboFanSelect->clear(); | ||
125 | for (int i = 0; i < count; i++) { | 125 | for (int i = 0; i < count; i++) { | ||
126 | comboFanSelect->insertItem(i, tr("Fan %1 speed").arg(i)); | 126 | comboFanSelect->insertItem(i, tr("Fan %1 speed").arg(i)); | ||
127 | } | 127 | } | ||
128 | } | 128 | } |