Changeset View
Changeset View
Standalone View
Standalone View
testclient/widgets/printwidget.cpp
- This file was added.
1 | /* AtCore Test Client | ||||
---|---|---|---|---|---|
2 | Copyright (C) <2018> | ||||
3 | Author: Chris Rizzitello - rizzitello@kde.org | ||||
4 | | ||||
5 | This program is free software: you can redistribute it and/or modify | ||||
6 | it under the terms of the GNU General Public License as published by | ||||
7 | the Free Software Foundation, either version 3 of the License, or | ||||
8 | (at your option) any later version. | ||||
9 | | ||||
10 | This program is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | GNU General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License | ||||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | */ | ||||
18 | #include "printwidget.h" | ||||
19 | #include <QHBoxLayout> | ||||
20 | #include <QLabel> | ||||
21 | #include <QLineEdit> | ||||
22 | #include <QVBoxLayout> | ||||
23 | | ||||
24 | PrintWidget::PrintWidget(QWidget *parent) : | ||||
25 | QWidget(parent) | ||||
26 | { | ||||
27 | auto mainLayout = new QVBoxLayout; | ||||
28 | | ||||
29 | buttonPrint = new QPushButton(tr("Print File")); | ||||
30 | connect(buttonPrint, &QPushButton::clicked, [this] { | ||||
31 | emit(printPressed()); | ||||
32 | }); | ||||
33 | | ||||
34 | auto newButton = new QPushButton(tr("Emergency Stop")); | ||||
35 | connect(newButton, &QPushButton::clicked, [this] { | ||||
36 | emit(emergencyStopPressed()); | ||||
37 | }); | ||||
38 | | ||||
39 | auto hBoxLayout = new QHBoxLayout; | ||||
40 | hBoxLayout->addWidget(buttonPrint); | ||||
41 | hBoxLayout->addWidget(newButton); | ||||
42 | mainLayout->addLayout(hBoxLayout); | ||||
43 | | ||||
44 | auto newLabel = new QLabel(tr("On Pause:")); | ||||
45 | | ||||
46 | linePostPause = new QLineEdit; | ||||
47 | linePostPause->setPlaceholderText(QStringLiteral("G91,G0 Z1,G90,G1 X0 Y195")); | ||||
48 | | ||||
49 | hBoxLayout = new QHBoxLayout; | ||||
50 | hBoxLayout->addWidget(newLabel); | ||||
51 | hBoxLayout->addWidget(linePostPause); | ||||
52 | mainLayout->addLayout(hBoxLayout); | ||||
53 | | ||||
54 | newLabel = new QLabel(tr("Printer Speed")); | ||||
55 | sbPrintSpeed = new QSpinBox; | ||||
56 | sbPrintSpeed->setRange(1, 300); | ||||
57 | sbPrintSpeed->setValue(100); | ||||
58 | sbPrintSpeed->setSuffix(QStringLiteral("%")); | ||||
59 | | ||||
60 | newButton = new QPushButton(tr("Set")); | ||||
61 | connect(newButton, &QPushButton::clicked, [this] { | ||||
62 | emit(printSpeedChanged(sbPrintSpeed->value())); | ||||
63 | }); | ||||
64 | | ||||
65 | hBoxLayout = new QHBoxLayout; | ||||
66 | hBoxLayout->addWidget(newLabel, 35); | ||||
67 | hBoxLayout->addWidget(sbPrintSpeed, 10); | ||||
68 | hBoxLayout->addWidget(newButton, 20); | ||||
69 | mainLayout->addLayout(hBoxLayout); | ||||
70 | | ||||
71 | newLabel = new QLabel(tr("Flow Rate")); | ||||
72 | sbFlowRate = new QSpinBox; | ||||
73 | sbFlowRate->setRange(1, 300); | ||||
74 | sbFlowRate->setValue(100); | ||||
75 | sbFlowRate->setSuffix(QStringLiteral("%")); | ||||
76 | | ||||
77 | newButton = new QPushButton(tr("Set")); | ||||
78 | connect(newButton, &QPushButton::clicked, [this] { | ||||
79 | emit(flowRateChanged(sbFlowRate->value())); | ||||
80 | }); | ||||
81 | hBoxLayout = new QHBoxLayout; | ||||
82 | hBoxLayout->addWidget(newLabel, 35); | ||||
83 | hBoxLayout->addWidget(sbFlowRate, 10); | ||||
84 | hBoxLayout->addWidget(newButton, 20); | ||||
85 | mainLayout->addLayout(hBoxLayout); | ||||
86 | | ||||
87 | setLayout(mainLayout); | ||||
88 | } | ||||
89 | | ||||
90 | QString PrintWidget::postPauseCommand(void) const | ||||
91 | { | ||||
92 | return linePostPause->text(); | ||||
93 | } | ||||
94 | | ||||
95 | void PrintWidget::setPrintText(const QString &text) | ||||
96 | { | ||||
97 | buttonPrint->setText(text); | ||||
98 | } |