diff --git a/src/widgets/printwidget.cpp b/src/widgets/printwidget.cpp index 0b2b47a..a39d0e7 100644 --- a/src/widgets/printwidget.cpp +++ b/src/widgets/printwidget.cpp @@ -1,128 +1,128 @@ /* AtCore Test Client Copyright (C) <2018> Author: Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "printwidget.h" #include #include #include #include PrintWidget::PrintWidget(bool showAllControls, QWidget *parent) : QWidget(parent) { auto mainLayout = new QVBoxLayout; QPushButton *newButton = nullptr; QLabel *newLabel = nullptr; QHBoxLayout *hBoxLayout = nullptr; if (showAllControls) { - buttonPrint = new QPushButton(tr("Print File")); + buttonPrint = new QPushButton(tr("Print File"), this); connect(buttonPrint, &QPushButton::clicked, this, [this] { emit printPressed(); }); - newButton = new QPushButton(tr("Emergency Stop")); + newButton = new QPushButton(tr("Emergency Stop"), this); connect(newButton, &QPushButton::clicked, this, [this] { emit emergencyStopPressed(); }); hBoxLayout = new QHBoxLayout; hBoxLayout->addWidget(buttonPrint); hBoxLayout->addWidget(newButton); mainLayout->addLayout(hBoxLayout); - newLabel = new QLabel(tr("On Pause:")); + newLabel = new QLabel(tr("On Pause:"), this); - linePostPause = new QLineEdit; + linePostPause = new QLineEdit(this); linePostPause->setPlaceholderText(QStringLiteral("G91,G0 Z1,G90,G1 X0 Y195")); hBoxLayout = new QHBoxLayout; hBoxLayout->addWidget(newLabel); hBoxLayout->addWidget(linePostPause); mainLayout->addLayout(hBoxLayout); } - newLabel = new QLabel(tr("Printer Speed")); - sbPrintSpeed = new QSpinBox; + newLabel = new QLabel(tr("Printer Speed"), this); + sbPrintSpeed = new QSpinBox(this); sbPrintSpeed->setRange(1, 300); sbPrintSpeed->setValue(100); sbPrintSpeed->setSuffix(QStringLiteral("%")); - newButton = new QPushButton(tr("Set")); + newButton = new QPushButton(tr("Set"), this); connect(newButton, &QPushButton::clicked, this, [this] { emit printSpeedChanged(sbPrintSpeed->value()); }); hBoxLayout = new QHBoxLayout; hBoxLayout->addWidget(newLabel, 60); hBoxLayout->addWidget(sbPrintSpeed, 20); hBoxLayout->addWidget(newButton, 20); mainLayout->addLayout(hBoxLayout); - newLabel = new QLabel(tr("Flow Rate")); - sbFlowRate = new QSpinBox; + newLabel = new QLabel(tr("Flow Rate"), this); + sbFlowRate = new QSpinBox(this); sbFlowRate->setRange(1, 300); sbFlowRate->setValue(100); sbFlowRate->setSuffix(QStringLiteral("%")); - newButton = new QPushButton(tr("Set")); + newButton = new QPushButton(tr("Set"), this); connect(newButton, &QPushButton::clicked, this, [this] { emit flowRateChanged(sbFlowRate->value()); }); hBoxLayout = new QHBoxLayout; hBoxLayout->addWidget(newLabel, 60); hBoxLayout->addWidget(sbFlowRate, 20); hBoxLayout->addWidget(newButton, 20); mainLayout->addLayout(hBoxLayout); - comboFanSelect = new QComboBox; - sbFanSpeed = new QSpinBox; + comboFanSelect = new QComboBox(this); + sbFanSpeed = new QSpinBox(this); sbFanSpeed->setRange(0, 100); sbFanSpeed->setSuffix(QStringLiteral("%")); - newButton = new QPushButton(tr("Set")); + newButton = new QPushButton(tr("Set"), this); connect(newButton, &QPushButton::clicked, this, [this] { //Fan speed has a range of 0-255. int speed = sbFanSpeed->value() * 255 / 100; emit fanSpeedChanged(speed, comboFanSelect->currentIndex()); }); hBoxLayout = new QHBoxLayout; hBoxLayout->addWidget(comboFanSelect, 60); hBoxLayout->addWidget(sbFanSpeed, 20); hBoxLayout->addWidget(newButton, 20); mainLayout->addLayout(hBoxLayout); setLayout(mainLayout); } -QString PrintWidget::postPauseCommand(void) const +QString PrintWidget::postPauseCommand() const { return linePostPause->text(); } void PrintWidget::setPrintText(const QString &text) { buttonPrint->setText(text); } void PrintWidget::updateFanCount(const int count) { comboFanSelect->clear(); for (int i = 0; i < count; i++) { comboFanSelect->insertItem(i, tr("Fan %1 speed").arg(i)); } }