Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/atcoreinstancewidget.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
49 | delete ui; | 49 | delete ui; | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | void AtCoreInstanceWidget::buildToolbar() | 52 | void AtCoreInstanceWidget::buildToolbar() | ||
53 | { | 53 | { | ||
54 | m_toolBar = new QToolBar(); | 54 | m_toolBar = new QToolBar(); | ||
55 | 55 | | |||
56 | auto lb = new QAction; | 56 | auto lb = new QAction; | ||
57 | lb->setIcon(style()->standardIcon(QStyle::SP_DirHomeIcon)); | 57 | lb->setIcon(QIcon::fromTheme("go-home", style()->standardIcon(QStyle::SP_DirHomeIcon))); | ||
58 | lb->setDisabled(true); | 58 | lb->setDisabled(true); | ||
59 | m_toolBar->addAction(lb); | 59 | m_toolBar->addAction(lb); | ||
60 | 60 | | |||
61 | auto homeAll = new QAction("All"); | 61 | auto homeAll = new QAction("All"); | ||
62 | connect(homeAll, &QAction::triggered, [this]{ | 62 | connect(homeAll, &QAction::triggered, [this]{ | ||
63 | m_core.home(); | 63 | m_core.home(); | ||
64 | }); | 64 | }); | ||
65 | m_toolBar->addAction(homeAll); | 65 | m_toolBar->addAction(homeAll); | ||
Show All 29 Lines | |||||
95 | ui->toolBarLayout->addWidget(m_toolBar); | 95 | ui->toolBarLayout->addWidget(m_toolBar); | ||
96 | ui->toolBarLayout->addStretch(); | 96 | ui->toolBarLayout->addStretch(); | ||
97 | } | 97 | } | ||
98 | 98 | | |||
99 | void AtCoreInstanceWidget::buildMainToolbar(){ | 99 | void AtCoreInstanceWidget::buildMainToolbar(){ | ||
100 | m_mainToolBar = new QToolBar(); | 100 | m_mainToolBar = new QToolBar(); | ||
101 | m_mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 101 | m_mainToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
102 | 102 | | |||
103 | m_printAction = new QAction(style()->standardIcon(QStyle::SP_MediaPlay),i18n("Print")); | 103 | m_printAction = new QAction(QIcon::fromTheme("media-playback-start", style()->standardIcon(QStyle::SP_MediaPlay)),i18n("Print")); | ||
104 | connect(m_printAction, &QAction::triggered, [ this ](){ | 104 | connect(m_printAction, &QAction::triggered, [ this ](){ | ||
105 | if(m_core.state() == AtCore::BUSY) { | 105 | if(m_core.state() == AtCore::BUSY) { | ||
106 | pausePrint(); | 106 | pausePrint(); | ||
107 | return; | 107 | return; | ||
108 | } | 108 | } | ||
109 | if (m_core.state() == AtCore::IDLE){ | 109 | if (m_core.state() == AtCore::IDLE){ | ||
110 | print(); | 110 | print(); | ||
111 | } else if (m_core.state() == AtCore::PAUSE) { | 111 | } else if (m_core.state() == AtCore::PAUSE) { | ||
112 | m_core.resume(); | 112 | m_core.resume(); | ||
113 | } | 113 | } | ||
114 | }); | 114 | }); | ||
115 | m_mainToolBar->addAction(m_printAction); | 115 | m_mainToolBar->addAction(m_printAction); | ||
116 | 116 | | |||
117 | auto stopAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop),i18n("Stop")); | 117 | auto stopAction = new QAction(QIcon::fromTheme("media-playback-stop", style()->standardIcon(QStyle::SP_MediaStop)), i18n("Stop")); | ||
118 | connect(stopAction, &QAction::triggered, this, &AtCoreInstanceWidget::stopPrint); | 118 | connect(stopAction, &QAction::triggered, this, &AtCoreInstanceWidget::stopPrint); | ||
119 | connect(stopAction, &QAction::triggered, [this](){ | 119 | connect(stopAction, &QAction::triggered, [this](){ | ||
120 | m_printAction->setText(i18n("Print")); | 120 | m_printAction->setText(i18n("Print")); | ||
121 | m_printAction->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); | 121 | m_printAction->setIcon(QIcon::fromTheme("media-playback-start", style()->standardIcon(QStyle::SP_MediaPlay))); | ||
122 | }); | 122 | }); | ||
123 | m_mainToolBar->addAction(stopAction); | 123 | m_mainToolBar->addAction(stopAction); | ||
124 | 124 | | |||
125 | auto disableMotorsAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop),i18n("Disable Motors")); | 125 | auto disableMotorsAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop),i18n("Disable Motors")); | ||
126 | connect(disableMotorsAction, &QAction::triggered, this, &AtCoreInstanceWidget::disableMotors); | 126 | connect(disableMotorsAction, &QAction::triggered, this, &AtCoreInstanceWidget::disableMotors); | ||
127 | m_mainToolBar->addAction(disableMotorsAction); | 127 | m_mainToolBar->addAction(disableMotorsAction); | ||
128 | 128 | | |||
129 | ui->mainToolBarLayout->addWidget(m_mainToolBar); | 129 | ui->mainToolBarLayout->addWidget(m_mainToolBar); | ||
Show All 19 Lines | 133 | { | |||
149 | QHBoxLayout *connectLayout = new QHBoxLayout; | 149 | QHBoxLayout *connectLayout = new QHBoxLayout; | ||
150 | connectLayout->addLayout(deviceLayout,50); | 150 | connectLayout->addLayout(deviceLayout,50); | ||
151 | connectLayout->addLayout(profileLayout,50); | 151 | connectLayout->addLayout(profileLayout,50); | ||
152 | 152 | | |||
153 | m_connectWidget = new QWidget(); | 153 | m_connectWidget = new QWidget(); | ||
154 | m_connectWidget->setLayout(connectLayout); | 154 | m_connectWidget->setLayout(connectLayout); | ||
155 | m_connectToolBar->addWidget(m_connectWidget); | 155 | m_connectToolBar->addWidget(m_connectWidget); | ||
156 | 156 | | |||
157 | m_connectButton = new QPushButton(i18n("Connect")); | 157 | m_connectButton = new QPushButton(QIcon::fromTheme("network-connect", style()->standardIcon(QStyle::SP_DialogCloseButton)), i18n("Connect")); | ||
158 | m_connectButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); | 158 | m_connectButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); | ||
159 | connect(this, &AtCoreInstanceWidget::disableDisconnect, m_connectButton, &QPushButton::setDisabled); | 159 | connect(this, &AtCoreInstanceWidget::disableDisconnect, m_connectButton, &QPushButton::setDisabled); | ||
160 | connect(m_connectButton, &QPushButton::clicked, this, &AtCoreInstanceWidget::connectButtonClicked); | 160 | connect(m_connectButton, &QPushButton::clicked, this, &AtCoreInstanceWidget::connectButtonClicked); | ||
161 | ui->mainToolBarLayout->addWidget(m_connectToolBar); | 161 | ui->mainToolBarLayout->addWidget(m_connectToolBar); | ||
162 | ui->mainToolBarLayout->addWidget(m_connectButton); | 162 | ui->mainToolBarLayout->addWidget(m_connectButton); | ||
163 | 163 | | |||
164 | } | 164 | } | ||
165 | 165 | | |||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | |||||
305 | 305 | | |||
306 | void AtCoreInstanceWidget::handlePrinterStatusChanged(AtCore::STATES newState) | 306 | void AtCoreInstanceWidget::handlePrinterStatusChanged(AtCore::STATES newState) | ||
307 | { | 307 | { | ||
308 | static QString stateString; | 308 | static QString stateString; | ||
309 | switch (newState) { | 309 | switch (newState) { | ||
310 | case AtCore::CONNECTING: { | 310 | case AtCore::CONNECTING: { | ||
311 | m_core.setSerialTimerInterval(0); | 311 | m_core.setSerialTimerInterval(0); | ||
312 | m_connectButton->setText(i18n("Disconnect")); | 312 | m_connectButton->setText(i18n("Disconnect")); | ||
313 | m_connectButton->setIcon(QIcon::fromTheme("network-disconnect")); | ||||
313 | m_connectToolBar->setHidden(true); | 314 | m_connectToolBar->setHidden(true); | ||
314 | m_mainToolBar->setHidden(false); | 315 | m_mainToolBar->setHidden(false); | ||
315 | stateString = i18n("Connecting..."); | 316 | stateString = i18n("Connecting..."); | ||
316 | connect(&m_core, &AtCore::receivedMessage, this, &AtCoreInstanceWidget::checkReceivedCommand); | 317 | connect(&m_core, &AtCore::receivedMessage, this, &AtCoreInstanceWidget::checkReceivedCommand); | ||
317 | connect(m_core.serial(), &SerialLayer::pushedCommand, this, &AtCoreInstanceWidget::checkPushedCommands); | 318 | connect(m_core.serial(), &SerialLayer::pushedCommand, this, &AtCoreInstanceWidget::checkPushedCommands); | ||
318 | } break; | 319 | } break; | ||
319 | case AtCore::IDLE: { | 320 | case AtCore::IDLE: { | ||
320 | stateString = i18n("Connected to ") + m_core.serial()->portName(); | 321 | stateString = i18n("Connected to ") + m_core.serial()->portName(); | ||
321 | emit extruderCountChanged(m_core.extruderCount()); | 322 | emit extruderCountChanged(m_core.extruderCount()); | ||
322 | ui->logWidget->addLog(i18n("Serial connected")); | 323 | ui->logWidget->addLog(i18n("Serial connected")); | ||
323 | emit disableDisconnect(false); | 324 | emit disableDisconnect(false); | ||
324 | enableControls(true); | 325 | enableControls(true); | ||
325 | } break; | 326 | } break; | ||
326 | case AtCore::DISCONNECTED: { | 327 | case AtCore::DISCONNECTED: { | ||
327 | stateString = i18n("Not Connected"); | 328 | stateString = i18n("Not Connected"); | ||
328 | disconnect(&m_core, &AtCore::receivedMessage, this, &AtCoreInstanceWidget::checkReceivedCommand); | 329 | disconnect(&m_core, &AtCore::receivedMessage, this, &AtCoreInstanceWidget::checkReceivedCommand); | ||
329 | disconnect(m_core.serial(), &SerialLayer::pushedCommand, this, &AtCoreInstanceWidget::checkPushedCommands); | 330 | disconnect(m_core.serial(), &SerialLayer::pushedCommand, this, &AtCoreInstanceWidget::checkPushedCommands); | ||
330 | ui->logWidget->addLog(i18n("Serial disconnected")); | 331 | ui->logWidget->addLog(i18n("Serial disconnected")); | ||
331 | m_core.setSerialTimerInterval(100); | 332 | m_core.setSerialTimerInterval(100); | ||
332 | m_connectButton->setText(i18n("Connect")); | 333 | m_connectButton->setText(i18n("Connect")); | ||
334 | m_connectButton->setIcon(QIcon::fromTheme("network-connect")); | ||||
333 | m_connectToolBar->setHidden(false); | 335 | m_connectToolBar->setHidden(false); | ||
334 | m_mainToolBar->setHidden(true); | 336 | m_mainToolBar->setHidden(true); | ||
335 | enableControls(false); | 337 | enableControls(false); | ||
336 | } break; | 338 | } break; | ||
337 | case AtCore::STARTPRINT: { | 339 | case AtCore::STARTPRINT: { | ||
338 | stateString = i18n("Starting Print"); | 340 | stateString = i18n("Starting Print"); | ||
339 | ui->printProgressWidget->setVisible(true); | 341 | ui->printProgressWidget->setVisible(true); | ||
340 | connect(&m_core, &AtCore::printProgressChanged, ui->printProgressWidget, &PrintProgressWidget::updateProgressBar); | 342 | connect(&m_core, &AtCore::printProgressChanged, ui->printProgressWidget, &PrintProgressWidget::updateProgressBar); | ||
341 | } break; | 343 | } break; | ||
342 | case AtCore::FINISHEDPRINT: { | 344 | case AtCore::FINISHEDPRINT: { | ||
343 | stateString = i18n("Finished Print"); | 345 | stateString = i18n("Finished Print"); | ||
344 | ui->printProgressWidget->setVisible(false); | 346 | ui->printProgressWidget->setVisible(false); | ||
345 | disconnect(&m_core, &AtCore::printProgressChanged, ui->printProgressWidget, &PrintProgressWidget::updateProgressBar); | 347 | disconnect(&m_core, &AtCore::printProgressChanged, ui->printProgressWidget, &PrintProgressWidget::updateProgressBar); | ||
346 | m_printAction->setText(i18n("Print")); | 348 | m_printAction->setText(i18n("Print")); | ||
347 | m_printAction->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); | 349 | m_printAction->setIcon(QIcon::fromTheme("document-edit", style()->standardIcon(QStyle::SP_MediaPlay))); | ||
348 | } break; | 350 | } break; | ||
349 | case AtCore::BUSY: { | 351 | case AtCore::BUSY: { | ||
350 | stateString = i18n("Printing"); | 352 | stateString = i18n("Printing"); | ||
351 | emit disableDisconnect(true); | 353 | emit disableDisconnect(true); | ||
352 | m_printAction->setText(i18n("Pause")); | 354 | m_printAction->setText(i18n("Pause")); | ||
353 | m_printAction->setIcon(style()->standardIcon(QStyle::SP_MediaPause)); | 355 | m_printAction->setIcon(QIcon::fromTheme("media-playback-pause", style()->standardIcon(QStyle::SP_MediaPause))); | ||
354 | } break; | 356 | } break; | ||
355 | case AtCore::PAUSE: { | 357 | case AtCore::PAUSE: { | ||
356 | stateString = i18n("Paused"); | 358 | stateString = i18n("Paused"); | ||
357 | m_printAction->setText(i18n("Resume")); | 359 | m_printAction->setText(i18n("Resume")); | ||
358 | m_printAction->setIcon(style()->standardIcon(QStyle::SP_MediaPlay)); | 360 | m_printAction->setIcon(QIcon::fromTheme("media-playback-start", style()->standardIcon(QStyle::SP_MediaPlay))); | ||
359 | } break; | 361 | } break; | ||
360 | case AtCore::STOP: { | 362 | case AtCore::STOP: { | ||
361 | stateString = i18n("Stoping Print"); | 363 | stateString = i18n("Stoping Print"); | ||
362 | } break; | 364 | } break; | ||
363 | case AtCore::ERRORSTATE: { | 365 | case AtCore::ERRORSTATE: { | ||
364 | stateString = i18n("Error"); | 366 | stateString = i18n("Error"); | ||
365 | } break; | 367 | } break; | ||
366 | default: | 368 | default: | ||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |