Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show All 30 Lines | |||||
31 | #include "widgets/3dview/viewer3d.h" | 31 | #include "widgets/3dview/viewer3d.h" | ||
32 | #include "widgets/atcoreinstancewidget.h" | 32 | #include "widgets/atcoreinstancewidget.h" | ||
33 | #include "widgets/videomonitorwidget.h" | 33 | #include "widgets/videomonitorwidget.h" | ||
34 | #include "widgets/welcomewidget.h" | 34 | #include "widgets/welcomewidget.h" | ||
35 | 35 | | |||
36 | MainWindow::MainWindow(QWidget *parent) : | 36 | MainWindow::MainWindow(QWidget *parent) : | ||
37 | KXmlGuiWindow(parent) | 37 | KXmlGuiWindow(parent) | ||
38 | , m_currEditorView(nullptr) | 38 | , m_currEditorView(nullptr) | ||
39 | , m_currInstance(0) | ||||
39 | , m_theme(getTheme()) | 40 | , m_theme(getTheme()) | ||
40 | , m_instances(new QTabWidget(this)) | 41 | , m_instances(new QTabWidget(this)) | ||
41 | { | 42 | { | ||
42 | initWidgets(); | 43 | initWidgets(); | ||
43 | setupActions(); | 44 | setupActions(); | ||
44 | setAcceptDrops(true); | 45 | setAcceptDrops(true); | ||
45 | 46 | | |||
46 | connect(m_instances, &QTabWidget::tabCloseRequested, this, [this](int index) { | 47 | connect(m_instances, &QTabWidget::tabCloseRequested, this, [this](int index) { | ||
▲ Show 20 Lines • Show All 136 Lines • ▼ Show 20 Line(s) | 183 | if (result == QMessageBox::Cancel) { | |||
183 | return; | 184 | return; | ||
184 | } else if (result == QMessageBox::Save) { | 185 | } else if (result == QMessageBox::Save) { | ||
185 | m_gcodeEditor->saveFile(file); | 186 | m_gcodeEditor->saveFile(file); | ||
186 | } | 187 | } | ||
187 | } | 188 | } | ||
188 | newInstanceWidget->printFile(file); | 189 | newInstanceWidget->printFile(file); | ||
189 | }); | 190 | }); | ||
190 | 191 | | |||
192 | connect(newInstanceWidget, &AtCoreInstanceWidget::bedSizeChanged, this, [this](const QSize & newSize) { | ||||
193 | if (m_currInstance == m_instances->currentIndex()) { | ||||
194 | updateBedSize(newSize); | ||||
195 | } | ||||
196 | }); | ||||
197 | | ||||
191 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | 198 | connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); | ||
192 | 199 | | |||
193 | if (m_instances->count() > 1) { | 200 | if (m_instances->count() > 1) { | ||
194 | m_instances->setTabsClosable(true); | 201 | m_instances->setTabsClosable(true); | ||
195 | m_instances->setMovable(true); | 202 | m_instances->setMovable(true); | ||
196 | m_instances->setCurrentIndex(m_instances->count() - 1); | 203 | m_instances->setCurrentIndex(m_instances->count() - 1); | ||
197 | } | 204 | } | ||
198 | } | 205 | } | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 208 | { | |||
245 | connect(m_gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, &MainWindow::updateClientFactory); | 252 | connect(m_gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, &MainWindow::updateClientFactory); | ||
246 | connect(m_gcodeEditor, &GCodeEditorWidget::droppedUrls, this, &MainWindow::processDropEvent); | 253 | connect(m_gcodeEditor, &GCodeEditorWidget::droppedUrls, this, &MainWindow::processDropEvent); | ||
247 | connect(m_gcodeEditor, &GCodeEditorWidget::fileClosed, this, [this](const QUrl & file) { | 254 | connect(m_gcodeEditor, &GCodeEditorWidget::fileClosed, this, [this](const QUrl & file) { | ||
248 | m_openFiles.removeAll(file); | 255 | m_openFiles.removeAll(file); | ||
249 | }); | 256 | }); | ||
250 | 257 | | |||
251 | auto *viewer3D = new Viewer3D(this); | 258 | auto *viewer3D = new Viewer3D(this); | ||
252 | connect(viewer3D, &Viewer3D::droppedUrls, this, &MainWindow::processDropEvent); | 259 | connect(viewer3D, &Viewer3D::droppedUrls, this, &MainWindow::processDropEvent); | ||
260 | //Connect for bed size | ||||
261 | connect(m_instances, &QTabWidget::currentChanged, this, [this](int index) { | ||||
262 | m_currInstance = index; | ||||
263 | auto tempWidget = qobject_cast<AtCoreInstanceWidget *>(m_instances->widget(index)); | ||||
264 | updateBedSize(tempWidget->bedSize()); | ||||
265 | }); | ||||
253 | 266 | | |||
254 | connect(m_gcodeEditor, &GCodeEditorWidget::currentFileChanged, this, [viewer3D](const QUrl & url) { | 267 | connect(m_gcodeEditor, &GCodeEditorWidget::currentFileChanged, this, [viewer3D](const QUrl & url) { | ||
255 | viewer3D->drawModel(url.toString()); | 268 | viewer3D->drawModel(url.toString()); | ||
256 | }); | 269 | }); | ||
257 | 270 | | |||
258 | setupButton("welcome", i18n("&Welcome"), QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme))), new WelcomeWidget(this)); | 271 | setupButton("welcome", i18n("&Welcome"), QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme))), new WelcomeWidget(this)); | ||
259 | setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(QString(":/%1/3d").arg(m_theme))), viewer3D); | 272 | setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(QString(":/%1/3d").arg(m_theme))), viewer3D); | ||
260 | setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/edit")), m_gcodeEditor); | 273 | setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/edit")), m_gcodeEditor); | ||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Line(s) | 411 | { | |||
468 | auto label = new QLabel(i18n("Files with Unsaved Changes.")); | 481 | auto label = new QLabel(i18n("Files with Unsaved Changes.")); | ||
469 | layout->addWidget(label); | 482 | layout->addWidget(label); | ||
470 | layout->addWidget(listWidget); | 483 | layout->addWidget(listWidget); | ||
471 | layout->addItem(hLayout); | 484 | layout->addItem(hLayout); | ||
472 | dialog->setLayout(layout); | 485 | dialog->setLayout(layout); | ||
473 | 486 | | |||
474 | return dialog->exec(); | 487 | return dialog->exec(); | ||
475 | } | 488 | } | ||
489 | | ||||
490 | void MainWindow::updateBedSize(const QSize &newSize) | ||||
491 | { | ||||
492 | m_lateral.get<Viewer3D>("3d")->setBedSize(newSize); | ||||
493 | } |