Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/atcoreinstancewidget.cpp
Show All 27 Lines | 26 | AtCoreInstanceWidget::AtCoreInstanceWidget(QWidget *parent): | |||
---|---|---|---|---|---|
28 | , m_fileCount(0) | 28 | , m_fileCount(0) | ||
29 | , m_printAction(nullptr) | 29 | , m_printAction(nullptr) | ||
30 | , m_stopAction(nullptr) | 30 | , m_stopAction(nullptr) | ||
31 | , m_toolBar(nullptr) | 31 | , m_toolBar(nullptr) | ||
32 | , m_bedSize(200, 200) | 32 | , m_bedSize(200, 200) | ||
33 | { | 33 | { | ||
34 | m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light") ; | 34 | m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light") ; | ||
35 | m_iconSize = QSize(fontMetrics().lineSpacing(), fontMetrics().lineSpacing()); | 35 | m_iconSize = QSize(fontMetrics().lineSpacing(), fontMetrics().lineSpacing()); | ||
36 | QHBoxLayout *HLayout = new QHBoxLayout; | 36 | auto HLayout = new QHBoxLayout; | ||
37 | m_bedExtWidget = new BedExtruderWidget; | 37 | m_bedExtWidget = new BedExtruderWidget; | ||
38 | HLayout->addWidget(m_bedExtWidget); | 38 | HLayout->addWidget(m_bedExtWidget); | ||
39 | 39 | | |||
40 | m_movementWidget = new MovementWidget(false); | 40 | m_movementWidget = new MovementWidget(false); | ||
41 | m_movementWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | 41 | m_movementWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); | ||
42 | HLayout->addWidget(m_movementWidget); | 42 | HLayout->addWidget(m_movementWidget); | ||
43 | 43 | | |||
44 | QVBoxLayout *VLayout = new QVBoxLayout; | 44 | auto VLayout = new QVBoxLayout; | ||
45 | VLayout->addLayout(HLayout); | 45 | VLayout->addLayout(HLayout); | ||
46 | 46 | | |||
47 | m_plotWidget = new PlotWidget(); | 47 | m_plotWidget = new PlotWidget(); | ||
48 | VLayout->addWidget(m_plotWidget, 80); | 48 | VLayout->addWidget(m_plotWidget, 80); | ||
49 | 49 | | |||
50 | QWidget *controlTab = new QWidget(); | 50 | QWidget *controlTab = new QWidget(); | ||
51 | controlTab->setLayout(VLayout); | 51 | controlTab->setLayout(VLayout); | ||
52 | 52 | | |||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 130 | connect(m_printAction, &QAction::triggered, this, [this] { | |||
142 | } else if (m_core.state() == AtCore::PAUSE) | 142 | } else if (m_core.state() == AtCore::PAUSE) | ||
143 | { | 143 | { | ||
144 | m_logWidget->appendLog(i18n("Resume Print")); | 144 | m_logWidget->appendLog(i18n("Resume Print")); | ||
145 | m_core.resume(); | 145 | m_core.resume(); | ||
146 | } | 146 | } | ||
147 | }); | 147 | }); | ||
148 | m_toolBar->addAction(m_printAction); | 148 | m_toolBar->addAction(m_printAction); | ||
149 | 149 | | |||
150 | m_stopAction = new QAction(QIcon::fromTheme("media-playback-stop", QIcon(QString(":/%1/stop").arg(m_theme))), i18n("Stop")); | 150 | m_stopAction = new QAction(QIcon::fromTheme("media-playback-stop", QIcon(QString(":/%1/stop").arg(m_theme))), i18n("Stop")); | ||
patrickelectric: QStringLiteral | |||||
151 | connect(m_stopAction, &QAction::triggered, this, &AtCoreInstanceWidget::stopPrint); | 151 | connect(m_stopAction, &QAction::triggered, this, &AtCoreInstanceWidget::stopPrint); | ||
152 | connect(m_stopAction, &QAction::triggered, this, [this] { | 152 | connect(m_stopAction, &QAction::triggered, this, [this] { | ||
153 | m_printAction->setText(i18n("Print")); | 153 | m_printAction->setText(i18n("Print")); | ||
154 | m_printAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(QString(":/%1/start").arg(m_theme)))); | 154 | m_printAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(QString(":/%1/start").arg(m_theme)))); | ||
155 | }); | 155 | }); | ||
156 | m_toolBar->addAction(m_stopAction); | 156 | m_toolBar->addAction(m_stopAction); | ||
157 | 157 | | |||
158 | auto disableMotorsAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop), i18n("Disable Motors")); | 158 | auto disableMotorsAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop), i18n("Disable Motors")); | ||
159 | connect(disableMotorsAction, &QAction::triggered, this, &AtCoreInstanceWidget::disableMotors); | 159 | connect(disableMotorsAction, &QAction::triggered, this, &AtCoreInstanceWidget::disableMotors); | ||
160 | m_toolBar->addAction(disableMotorsAction); | 160 | m_toolBar->addAction(disableMotorsAction); | ||
161 | 161 | | |||
162 | togglePrintButtons(m_fileCount); | 162 | togglePrintButtons(m_fileCount); | ||
163 | } | 163 | } | ||
164 | 164 | | |||
165 | void AtCoreInstanceWidget::buildConnectionToolbar() | 165 | void AtCoreInstanceWidget::buildConnectionToolbar() | ||
166 | { | 166 | { | ||
167 | m_connectToolBar = new QToolBar(); | 167 | m_connectToolBar = new QToolBar(); | ||
168 | m_comboPort = new QComboBox; | 168 | m_comboPort = new QComboBox; | ||
169 | m_comboPort->setEditable(true); | 169 | m_comboPort->setEditable(true); | ||
170 | QLabel *deviceLabel = new QLabel(i18n("Device")); | 170 | QLabel *deviceLabel = new QLabel(i18n("Device")); | ||
171 | QHBoxLayout *deviceLayout = new QHBoxLayout; | 171 | auto deviceLayout = new QHBoxLayout; | ||
172 | deviceLayout->addWidget(deviceLabel); | 172 | deviceLayout->addWidget(deviceLabel); | ||
173 | deviceLayout->addWidget(m_comboPort, 100); | 173 | deviceLayout->addWidget(m_comboPort, 100); | ||
174 | 174 | | |||
175 | m_comboProfile = new QComboBox; | 175 | m_comboProfile = new QComboBox; | ||
176 | m_comboProfile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | 176 | m_comboProfile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | ||
177 | QHBoxLayout *profileLayout = new QHBoxLayout; | 177 | auto profileLayout = new QHBoxLayout; | ||
178 | QLabel *profileLabel = new QLabel(i18n("Profile")); | 178 | QLabel *profileLabel = new QLabel(i18n("Profile")); | ||
179 | profileLayout->addWidget(profileLabel); | 179 | profileLayout->addWidget(profileLabel); | ||
180 | profileLayout->addWidget(m_comboProfile, 100); | 180 | profileLayout->addWidget(m_comboProfile, 100); | ||
181 | 181 | | |||
182 | QHBoxLayout *connectLayout = new QHBoxLayout; | 182 | auto connectLayout = new QHBoxLayout; | ||
183 | connectLayout->addLayout(deviceLayout, 50); | 183 | connectLayout->addLayout(deviceLayout, 50); | ||
184 | connectLayout->addLayout(profileLayout, 50); | 184 | connectLayout->addLayout(profileLayout, 50); | ||
185 | 185 | | |||
186 | m_connectWidget = new QWidget(); | 186 | m_connectWidget = new QWidget(); | ||
187 | m_connectWidget->setLayout(connectLayout); | 187 | m_connectWidget->setLayout(connectLayout); | ||
188 | m_connectToolBar->addWidget(m_connectWidget); | 188 | m_connectToolBar->addWidget(m_connectWidget); | ||
189 | 189 | | |||
190 | m_connectButton = new QPushButton(QIcon::fromTheme("network-connect", QIcon(QString(":/%1/connect").arg(m_theme))), i18n("Connect")); | 190 | m_connectButton = new QPushButton(QIcon::fromTheme("network-connect", QIcon(QString(":/%1/connect").arg(m_theme))), i18n("Connect")); | ||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | |||||
331 | { | 331 | { | ||
332 | if (fileName.isEmpty()) { | 332 | if (fileName.isEmpty()) { | ||
333 | QMessageBox::critical( | 333 | QMessageBox::critical( | ||
334 | this | 334 | this | ||
335 | , i18n("Filename Empty") | 335 | , i18n("Filename Empty") | ||
336 | , i18n("No filename sent from calling method, please check and try again.") | 336 | , i18n("No filename sent from calling method, please check and try again.") | ||
337 | ); | 337 | ); | ||
338 | return; | 338 | return; | ||
339 | } else if (!QFileInfo(fileName.toLocalFile()).isReadable()) { | 339 | } | ||
340 | if (!QFileInfo(fileName.toLocalFile()).isReadable()) { | ||||
340 | QMessageBox::critical( | 341 | QMessageBox::critical( | ||
341 | this | 342 | this | ||
342 | , i18n("File not found") | 343 | , i18n("File not found") | ||
343 | , i18n("%1 \nIs not readable, please check and try again.", fileName.toLocalFile()) | 344 | , i18n("%1 \nIs not readable, please check and try again.", fileName.toLocalFile()) | ||
344 | ); | 345 | ); | ||
345 | return; | 346 | return; | ||
346 | } | 347 | } | ||
347 | if (m_core.state() == AtCore::IDLE) { | 348 | if (m_core.state() == AtCore::IDLE) { | ||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Line(s) | 479 | case 0x04: // enclosure | |||
480 | break; | 481 | break; | ||
481 | 482 | | |||
482 | case 0x05: // enclosure target | 483 | case 0x05: // enclosure target | ||
483 | msg = QString::fromLatin1("Enclosure Target Temperature "); | 484 | msg = QString::fromLatin1("Enclosure Target Temperature "); | ||
484 | break; | 485 | break; | ||
485 | } | 486 | } | ||
486 | 487 | | |||
487 | msg.append(QString::fromLatin1("[%1] : %2")); | 488 | msg.append(QString::fromLatin1("[%1] : %2")); | ||
488 | msg = msg.arg(QString::number(number)) | 489 | msg = msg.arg(QString::number(number) | ||
489 | .arg(QString::number(double(temp), 'f', 2)); | 490 | , QString::number(double(temp), 'f', 2)); | ||
490 | m_logWidget->appendLog(msg); | 491 | m_logWidget->appendLog(msg); | ||
491 | } | 492 | } | ||
492 | 493 | | |||
493 | void AtCoreInstanceWidget::enableControls(bool b) | 494 | void AtCoreInstanceWidget::enableControls(bool b) | ||
494 | { | 495 | { | ||
495 | if (b) { | 496 | if (b) { | ||
496 | layout()->removeWidget(m_logWidget); | 497 | layout()->removeWidget(m_logWidget); | ||
497 | layout()->removeWidget(m_statusWidget); | 498 | layout()->removeWidget(m_statusWidget); | ||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |
QStringLiteral