From bbfe9ed377dd7272193b87a838f9052b9f1f9e16 Mon Sep 17 00:00:00 2001 From: joshua Date: Fri, 2 Apr 2021 20:52:38 +0200 Subject: [PATCH] Add terminal strip editor widget --- qelectrotech.pro | 9 ++-- .../TerminalStrip/ui/terminalstripeditor.cpp | 32 +++++++++++++ .../TerminalStrip/ui/terminalstripeditor.h | 42 +++++++++++++++++ .../TerminalStrip/ui/terminalstripeditor.ui | 47 +++++++++++++++++++ sources/qetdiagrameditor.cpp | 32 +++++++++---- sources/qetdiagrameditor.h | 1 + 6 files changed, 151 insertions(+), 12 deletions(-) create mode 100644 sources/TerminalStrip/ui/terminalstripeditor.cpp create mode 100644 sources/TerminalStrip/ui/terminalstripeditor.h create mode 100644 sources/TerminalStrip/ui/terminalstripeditor.ui diff --git a/qelectrotech.pro b/qelectrotech.pro index 049939a02..9d848fea3 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -161,7 +161,8 @@ HEADERS += $$files(sources/*.h) $$files(sources/ui/*.h) \ $$files(sources/dataBase/ui/*.h) \ $$files(sources/factory/ui/*.h) \ $$files(sources/print/*.h) \ - $$files(sources/TerminalStrip/*.h) + $$files(sources/TerminalStrip/*.h) \ + $$files(sources/TerminalStrip/ui/*.h) SOURCES += $$files(sources/*.cpp) \ $$files(sources/editor/*.cpp) \ @@ -195,7 +196,8 @@ SOURCES += $$files(sources/*.cpp) \ $$files(sources/dataBase/ui/*.cpp) \ $$files(sources/factory/ui/*.cpp) \ $$files(sources/print/*.cpp) \ - $$files(sources/TerminalStrip/*.cpp) + $$files(sources/TerminalStrip/*.cpp) \ + $$files(sources/TerminalStrip/ui/*.cpp) # Liste des fichiers qui seront incorpores au binaire en tant que ressources Qt RESOURCES += qelectrotech.qrc @@ -221,7 +223,8 @@ FORMS += $$files(sources/richtext/*.ui) \ $$files(sources/qetgraphicsitem/ViewItem/ui/*.ui) \ $$files(sources/dataBase/ui/*.ui) \ $$files(sources/factory/ui/*.ui) \ - $$files(sources/print/*.ui) + $$files(sources/print/*.ui) \ + $$files(sources/TerminalStrip/ui/*.ui) UI_SOURCES_DIR = sources/ui/ UI_HEADERS_DIR = sources/ui/ diff --git a/sources/TerminalStrip/ui/terminalstripeditor.cpp b/sources/TerminalStrip/ui/terminalstripeditor.cpp new file mode 100644 index 000000000..a06c494b7 --- /dev/null +++ b/sources/TerminalStrip/ui/terminalstripeditor.cpp @@ -0,0 +1,32 @@ +/* + Copyright 2006-2021 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#include "terminalstripeditor.h" +#include "ui_terminalstripeditor.h" + +TerminalStripEditor::TerminalStripEditor(QETProject *project, QWidget *parent) : + QDialog(parent), + ui(new Ui::TerminalStripEditor), + m_project(project) +{ + ui->setupUi(this); +} + +TerminalStripEditor::~TerminalStripEditor() +{ + delete ui; +} diff --git a/sources/TerminalStrip/ui/terminalstripeditor.h b/sources/TerminalStrip/ui/terminalstripeditor.h new file mode 100644 index 000000000..1cac27444 --- /dev/null +++ b/sources/TerminalStrip/ui/terminalstripeditor.h @@ -0,0 +1,42 @@ +/* + Copyright 2006-2021 The QElectroTech Team + This file is part of QElectroTech. + + QElectroTech is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + QElectroTech is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QElectroTech. If not, see . +*/ +#ifndef TERMINALSTRIPEDITOR_H +#define TERMINALSTRIPEDITOR_H + +#include + +namespace Ui { + class TerminalStripEditor; +} + +class QETProject; + +class TerminalStripEditor : public QDialog +{ + Q_OBJECT + + public: + explicit TerminalStripEditor(QETProject *project, QWidget *parent = nullptr); + ~TerminalStripEditor() override; + + private: + Ui::TerminalStripEditor *ui; + QETProject *m_project = nullptr; +}; + +#endif // TERMINALSTRIPEDITOR_H diff --git a/sources/TerminalStrip/ui/terminalstripeditor.ui b/sources/TerminalStrip/ui/terminalstripeditor.ui new file mode 100644 index 000000000..e659bb195 --- /dev/null +++ b/sources/TerminalStrip/ui/terminalstripeditor.ui @@ -0,0 +1,47 @@ + + + TerminalStripEditor + + + + 0 + 0 + 923 + 484 + + + + Form + + + + + + + + + Ajouter un bornier + + + + + + + Supprimer le bornier + + + + + + + + Explorateur de bornier + + + + + + + + + diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 69e392ea8..baa6f69ab 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -42,6 +42,7 @@ #include "undocommand/rotateselectioncommand.h" #include "undocommand/rotatetextscommand.h" #include "diagram.h" +#include "TerminalStrip/ui/terminalstripeditor.h" #ifdef BUILD_WITHOUT_KF5 #else @@ -436,6 +437,16 @@ void QETDiagramEditor::setUpActions() } }); + m_terminal_strip_dialog = new QAction(QET::Icons::TerminalStrip, tr("Gestionnaire de borniers (DEV)"), this); + connect(m_terminal_strip_dialog, &QAction::triggered, [this]() + { + if (auto project = this->currentProject()) + { + auto str = new TerminalStripEditor(project, this); + str->show(); + } + }); + //Lauch the plugin of terminal generator m_project_terminalBloc = new QAction(QET::Icons::TerminalStrip, tr("Lancer le plugin de création de borniers"), this); connect(m_project_terminalBloc, &QAction::triggered, this, &QETDiagramEditor::generateTerminalBlock); @@ -809,6 +820,7 @@ void QETDiagramEditor::setUpMenu() menu_project -> addAction(m_add_nomenclature); menu_project -> addAction(m_csv_export); menu_project -> addAction(m_project_export_conductor_num); + menu_project -> addAction(m_terminal_strip_dialog); menu_project -> addAction(m_project_terminalBloc); #ifdef QET_EXPORT_PROJECT_DB menu_project -> addSeparator(); @@ -1502,16 +1514,7 @@ void QETDiagramEditor::slot_updateActions() m_close_file-> setEnabled(opened_project); m_save_file-> setEnabled(opened_project); m_save_file_as-> setEnabled(opened_project); - m_project_edit_properties-> setEnabled(opened_project); - m_project_export_conductor_num->setEnabled(opened_project); - //prj_terminalBloc -> setEnabled(opened_project); m_rotate_texts-> setEnabled(editable_project); - m_project_add_diagram-> setEnabled(editable_project); - m_remove_diagram_from_project-> setEnabled(editable_project); - m_clean_project-> setEnabled(editable_project); - m_add_nomenclature-> setEnabled(editable_project); - m_add_summary-> setEnabled(editable_project); - m_csv_export-> setEnabled(editable_project); m_export_to_images-> setEnabled(opened_diagram); m_print-> setEnabled(opened_diagram); m_export_to_pdf-> setEnabled(opened_diagram); @@ -1522,6 +1525,17 @@ void QETDiagramEditor::slot_updateActions() m_row_column_actions_group. setEnabled(editable_project); m_grey_background-> setEnabled(opened_diagram); + //Project menu + m_project_edit_properties -> setEnabled(opened_project); + m_project_add_diagram -> setEnabled(editable_project); + m_remove_diagram_from_project -> setEnabled(editable_project); + m_clean_project -> setEnabled(editable_project); + m_add_summary -> setEnabled(editable_project); + m_add_nomenclature -> setEnabled(editable_project); + m_csv_export -> setEnabled(editable_project); + m_project_export_conductor_num-> setEnabled(opened_project); + m_terminal_strip_dialog -> setEnabled(editable_project); + slot_updateUndoStack(); slot_updateModeActions(); diff --git a/sources/qetdiagrameditor.h b/sources/qetdiagrameditor.h index db17ea877..34d9da9f1 100644 --- a/sources/qetdiagrameditor.h +++ b/sources/qetdiagrameditor.h @@ -192,6 +192,7 @@ class QETDiagramEditor : public QETMainWindow *m_csv_export, ///< generate nomenclature *m_add_nomenclature, ///< Add nomenclature graphics item; *m_add_summary, ///