diff --git a/src/mainwindow.h b/src/mainwindow.h --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -63,6 +63,7 @@ bool askToClose(); void atCoreInstanceNameChange(const QString &name); QString getTheme(); + void toggleGCodeActions(); signals: void extruderCountChanged(int count); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -179,13 +179,16 @@ m_lateral.m_stack->setHidden(false); m_lateral.m_stack->setCurrentWidget(w); } + toggleGCodeActions(); }); }; auto *gcodeEditor = new GCodeEditorWidget(this); connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ - guiFactory()->removeClient(m_currEditorView); - guiFactory()->addClient(view); + if(m_lateral.m_stack->currentWidget() == m_lateral.m_map["gcode"].second) { + guiFactory()->removeClient(m_currEditorView); + guiFactory()->addClient(view); + } m_currEditorView = view; }); setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(QString(":/%1/3d").arg(m_theme))), new Viewer3D(this)); @@ -281,3 +284,14 @@ } return rtn; } + +void MainWindow::toggleGCodeActions() +{ + if(m_lateral.m_stack->currentWidget() == m_lateral.m_map["gcode"].second && m_lateral.m_stack->isVisible()) { + if(m_currEditorView){ + guiFactory()->addClient(m_currEditorView); + } + } else { + guiFactory()->removeClient(m_currEditorView); + } +}