diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -157,11 +157,10 @@ }; auto *gcodeEditor = new GCodeEditorWidget(this); - connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ - guiFactory()->removeClient(m_currEditorView); - guiFactory()->addClient(view); - m_currEditorView = view; - }); + connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [this](KTextEditor::View* view){ + guiFactory()->addClient(view); + }); + setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(QString(":/%1/3d").arg(m_theme))), new Viewer3D(this)); setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/edit")), gcodeEditor); setupButton("video", i18n("&Video"), QIcon::fromTheme("camera-web", QIcon(":/icon/video")), new VideoMonitorWidget(this)); diff --git a/src/widgets/gcodeeditorwidget.h b/src/widgets/gcodeeditorwidget.h --- a/src/widgets/gcodeeditorwidget.h +++ b/src/widgets/gcodeeditorwidget.h @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2016> Author: Lays Rodrigues - laysrodrigues@gmail.com + Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,6 +31,7 @@ public: explicit GCodeEditorWidget(QWidget *parent = nullptr); + virtual ~GCodeEditorWidget() {} void loadFile(const QUrl &file); KTextEditor::View *gcodeView() const; @@ -42,7 +44,6 @@ KTextEditor::Document* newDoc(); KTextEditor::View* newView(KTextEditor::Document* doc); void closeTab(int index); - void currentIndexChanged(int index); signals: void updateClientFactory(KTextEditor::View* view); diff --git a/src/widgets/gcodeeditorwidget.cpp b/src/widgets/gcodeeditorwidget.cpp --- a/src/widgets/gcodeeditorwidget.cpp +++ b/src/widgets/gcodeeditorwidget.cpp @@ -1,6 +1,7 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2016> Author: Lays Rodrigues - laysrodrigues@gmail.com + Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,10 +31,10 @@ layout->addWidget(m_tabwidget); setLayout(layout); } + void GCodeEditorWidget::setupTabWidget() { connect(m_tabwidget, &QTabWidget::tabCloseRequested, this, &GCodeEditorWidget::closeTab); - connect(m_tabwidget, &QTabWidget::currentChanged, this, &GCodeEditorWidget::currentIndexChanged); m_tabwidget->setTabsClosable(true); m_tabwidget->addTab(newView(newDoc()), i18n("New file")); } @@ -82,8 +83,3 @@ m_tabwidget->addTab(newView(newDoc()), i18n("New file")); } } - -void GCodeEditorWidget::currentIndexChanged(int index){ - if(index != -1) - emit updateClientFactory(qobject_cast(m_tabwidget->currentWidget())); -}