Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/statuswidget.cpp
Show All 23 Lines | |||||
24 | #include "statuswidget.h" | 24 | #include "statuswidget.h" | ||
25 | 25 | | |||
26 | StatusWidget::StatusWidget(bool showStop, QWidget *parent) : | 26 | StatusWidget::StatusWidget(bool showStop, QWidget *parent) : | ||
27 | QWidget(parent) | 27 | QWidget(parent) | ||
28 | { | 28 | { | ||
29 | //first create the item for the print Progress. | 29 | //first create the item for the print Progress. | ||
30 | auto hBoxLayout = new QHBoxLayout; | 30 | auto hBoxLayout = new QHBoxLayout; | ||
31 | 31 | | |||
32 | printingProgress = new QProgressBar; | 32 | printingProgress = new QProgressBar(this); | ||
33 | printingProgress->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); | 33 | printingProgress->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); | ||
34 | hBoxLayout->addWidget(printingProgress); | 34 | hBoxLayout->addWidget(printingProgress); | ||
35 | 35 | | |||
36 | if (showStop) { | 36 | if (showStop) { | ||
37 | auto newButton = new QPushButton(style()->standardIcon(QStyle::SP_BrowserStop), QString()); | 37 | auto newButton = new QPushButton(style()->standardIcon(QStyle::SP_BrowserStop), QString(), this); | ||
38 | connect(newButton, &QPushButton::clicked, this, [this] { | 38 | connect(newButton, &QPushButton::clicked, this, [this] { | ||
39 | emit stopPressed(); | 39 | emit stopPressed(); | ||
40 | }); | 40 | }); | ||
41 | hBoxLayout->addWidget(newButton); | 41 | hBoxLayout->addWidget(newButton); | ||
42 | } | 42 | } | ||
43 | 43 | | |||
44 | lblTime = new QLabel(QStringLiteral("00:00:00")); | 44 | lblTime = new QLabel(QStringLiteral("00:00:00"), this); | ||
45 | lblTime->setAlignment(Qt::AlignHCenter); | 45 | lblTime->setAlignment(Qt::AlignHCenter); | ||
46 | auto newLabel = new QLabel(QStringLiteral(" / ")); | 46 | auto newLabel = new QLabel(QStringLiteral(" / "), this); | ||
47 | lblTimeLeft = new QLabel(QStringLiteral("??:??:??")); | 47 | lblTimeLeft = new QLabel(QStringLiteral("??:??:??"), this); | ||
48 | lblTimeLeft->setAlignment(Qt::AlignHCenter); | 48 | lblTimeLeft->setAlignment(Qt::AlignHCenter); | ||
49 | 49 | | |||
50 | hBoxLayout->addWidget(lblTime); | 50 | hBoxLayout->addWidget(lblTime); | ||
51 | hBoxLayout->addWidget(newLabel); | 51 | hBoxLayout->addWidget(newLabel); | ||
52 | hBoxLayout->addWidget(lblTimeLeft); | 52 | hBoxLayout->addWidget(lblTimeLeft); | ||
53 | printProgressWidget = new QWidget(); | 53 | printProgressWidget = new QWidget(this); | ||
54 | printProgressWidget->setLayout(hBoxLayout); | 54 | printProgressWidget->setLayout(hBoxLayout); | ||
55 | 55 | | |||
56 | //Then Create the full bar. | 56 | //Then Create the full bar. | ||
57 | newLabel = new QLabel(tr("AtCore State:")); | 57 | newLabel = new QLabel(tr("AtCore State:"), this); | ||
58 | lblState = new QLabel(tr("Not Connected")); | 58 | lblState = new QLabel(tr("Not Connected"), this); | ||
59 | lblSd = new QLabel(); | 59 | lblSd = new QLabel(this); | ||
60 | 60 | | |||
61 | spacer = new QSpacerItem(10, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); | 61 | spacer = new QSpacerItem(10, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); | ||
62 | 62 | | |||
63 | hBoxLayout = new QHBoxLayout; | 63 | hBoxLayout = new QHBoxLayout; | ||
64 | hBoxLayout->addWidget(newLabel); | 64 | hBoxLayout->addWidget(newLabel); | ||
65 | hBoxLayout->addWidget(lblState); | 65 | hBoxLayout->addWidget(lblState); | ||
66 | hBoxLayout->addSpacerItem(new QSpacerItem(5, 20, QSizePolicy::Fixed)); | 66 | hBoxLayout->addSpacerItem(new QSpacerItem(5, 20, QSizePolicy::Fixed)); | ||
67 | hBoxLayout->addWidget(lblSd); | 67 | hBoxLayout->addWidget(lblSd); | ||
68 | hBoxLayout->addSpacerItem(spacer); | 68 | hBoxLayout->addSpacerItem(spacer); | ||
69 | hBoxLayout->addWidget(printProgressWidget); | 69 | hBoxLayout->addWidget(printProgressWidget); | ||
70 | 70 | | |||
71 | setLayout(hBoxLayout); | 71 | setLayout(hBoxLayout); | ||
72 | 72 | | |||
73 | printTime = new QTime(); | 73 | printTime = new QTime(); | ||
74 | printTimer = new QTimer(); | 74 | printTimer = new QTimer(this); | ||
75 | printTimer->setInterval(1000); | 75 | printTimer->setInterval(1000); | ||
76 | printTimer->setSingleShot(false); | 76 | printTimer->setSingleShot(false); | ||
77 | connect(printTimer, &QTimer::timeout, this, &StatusWidget::updatePrintTime); | 77 | connect(printTimer, &QTimer::timeout, this, &StatusWidget::updatePrintTime); | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | void StatusWidget::setSD(bool hasSd) | 80 | void StatusWidget::setSD(bool hasSd) | ||
81 | { | 81 | { | ||
82 | QString labelText = hasSd ? tr("SD") : QString(); | 82 | QString labelText = hasSd ? tr("SD") : QString(); | ||
Show All 36 Lines |