diff --git a/src/mainwindow.h b/src/mainwindow.h --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -21,12 +21,30 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include namespace Ui { class MainWindow; } +struct LateralArea { + // Area with the the lateral buttons that will open the views. + // Kind like the KDevelop stuff but way simpler. + using Btn2Widget = QPair; + using WidgetMap = QMap; + + QWidget *m_toolBar; + QStackedWidget *m_stack; + WidgetMap m_map; +}; + class MainWindow : public KXmlGuiWindow { Q_OBJECT @@ -38,7 +56,9 @@ private: Ui::MainWindow *ui; QList m_openFiles; - KTextEditor::View *m_curr_editor_view; + KTextEditor::View *m_currEditorView; + LateralArea m_lateral; + void setupLateralArea(); void initWidgets(); void setupActions(); void openFile(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,7 +26,13 @@ #include #include #include +#include +#include #include +#include +#include +#include + MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent), ui(new Ui::MainWindow), @@ -44,11 +50,54 @@ void MainWindow::initWidgets() { - connect(ui->gcodeEditorWidget, &GCodeEditorWidget::updateClientFactory, this, [ & ](KTextEditor::View* view){ - guiFactory()->removeClient(m_curr_editor_view); - guiFactory()->addClient(view); - m_curr_editor_view = view; - }); + /* + auto instance = qobject_cast(ui->tabWidget->currentWidget()); + connectSettingsDialog->setFirmwareList(instance->firmwares()); + profilesDialog->setBaudRates(instance->baudRates()); + */ + + setupLateralArea(); +} + +// Move to LateralArea. +void MainWindow::setupLateralArea() +{ + m_lateral.m_toolBar = new QWidget(); + m_lateral.m_stack = new QStackedWidget(); + auto *buttonLayout = new QVBoxLayout(); + + auto setupButton = [this, buttonLayout](const QString& s, QWidget *w) { + QToolButton *btn = nullptr; + btn = new QToolButton(m_lateral.m_toolBar); + btn->setText(s); + btn->setAutoExclusive(true); + btn->setCheckable(true); + m_lateral.m_stack->addWidget(w); + m_lateral.m_map[s] = {btn, w}; + + buttonLayout->addWidget(btn); + connect(btn, &QToolButton::toggled, [this, w](bool checked) { + if (checked) + m_lateral.m_stack->setCurrentWidget(w); + }); + }; + + auto *gcodeEditor = new GCodeEditorWidget(this); + connect(gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, [&](KTextEditor::View* view){ + guiFactory()->removeClient(m_curr_editor_view); + guiFactory()->addClient(view); + m_curr_editor_view = view; + }); + + setupButton(i18n("&3D"), new Viewer3D(this)); + setupButton(i18n("&GCode"), gcodeEditor); + setupButton(i18n("&Video"), new VideoMonitorWidget(this)); + + m_lateral.m_toolBar->setLayout(buttonLayout); + m_lateral.m_toolBar->show(); + m_lateral.m_stack->show(); + + } void MainWindow::setupActions() @@ -92,14 +141,17 @@ { QUrl fileNameFromDialog = QFileDialog::getOpenFileUrl(this, i18n("Open GCode"), QDir::homePath(), i18n("GCode (*.gco *.gcode)")); +/* if (!fileNameFromDialog.isEmpty()) { ui->gcodeEditorWidget->loadFile(fileNameFromDialog); ui->view3DWidget->drawModel(fileNameFromDialog.toString()); m_openFiles.append(fileNameFromDialog); } + */ } void MainWindow::newConnection(const QString& port, const QMap& profile) { + /* const int tabs = ui->tabWidget->count(); if(tabs == 1){ auto instance = qobject_cast(ui->tabWidget->currentWidget()); @@ -112,4 +164,5 @@ auto newInstanceWidget = new AtCoreInstanceWidget(); ui->tabWidget->addTab(newInstanceWidget, profile["name"].toString()); newInstanceWidget->startConnection(port, profile); + */ } diff --git a/src/mainwindow.ui b/src/mainwindow.ui --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -6,134 +6,23 @@ 0 0 - 484 - 446 + 1074 + 627 Atelier - - - - - 0 - - - - - 0 - 0 - 233 - 285 - - - - Page 1 - - - - - Page - - - - - - 0 - 0 - 233 - 285 - - - - Page 2 - - - - - - - - 0 - - - - Tab 1 - - - - - - - - - 6 - 418 - 801 - 46 - - - - - 100 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Printer State: - - - - - - - Not Connected - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 0 - 0 - - - - - - + 0 0 - 484 - 30 + 1074 + 36 @@ -157,33 +46,12 @@ false + + + Teste + + - - - GCodeEditorWidget - QWidget -
widgets/gcodeeditorwidget.h
- 1 -
- - Viewer3D - QWidget -
widgets/3dview/viewer3d.h
- 1 -
- - VideoMonitorWidget - QWidget -
widgets/videomonitorwidget.h
- 1 -
- - AtCoreInstanceWidget - QWidget -
widgets/atcoreinstancewidget.h
- 1 -
-