Commit 6e275ba2 authored by Yann Boucher's avatar Yann Boucher
Browse files

Implémentation de l'interface de sauvegarde de structuree

parent 5b6763f5
Pipeline #77954 passed with stages
in 17 seconds
...@@ -569,11 +569,38 @@ pattern recorded :</string> ...@@ -569,11 +569,38 @@ pattern recorded :</string>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1089</width> <width>1089</width>
<height>26</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFichier">
<property name="title">
<string>Fichier</string>
</property>
</widget>
<widget class="QMenu" name="menuEditer">
<property name="title">
<string>Éditer</string>
</property>
<addaction name="action_save_struct"/>
</widget>
<widget class="QMenu" name="menuA_propos">
<property name="title">
<string>À propos</string>
</property>
</widget>
<addaction name="menuFichier"/>
<addaction name="menuEditer"/>
<addaction name="menuA_propos"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<action name="action_save_struct">
<property name="text">
<string>Sauvegarder la sélection</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>StructureSavingDialog</class>
<widget class="QDialog" name="StructureSavingDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Sauvegarde d'une structure</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Nom : </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nom"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Auteur : </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="auteur"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Description : </string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPlainTextEdit" name="desc">
<property name="placeholderText">
<string>Entrer une description de la structure, ses caractéristiques remarquables...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Date de création : </string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDateEdit" name="date"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>StructureSavingDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>StructureSavingDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
...@@ -46,6 +46,9 @@ private slots: ...@@ -46,6 +46,9 @@ private slots:
//! \brief Active le bouton pour valider la dimension de la grille lors d'une modification dans le Line Edit //! \brief Active le bouton pour valider la dimension de la grille lors d'une modification dans le Line Edit
void on_heightSpinBox_valueChanged(int arg1); void on_heightSpinBox_valueChanged(int arg1);
//! \brief Affiche l'interface pour sauvegarder la sélection actuelle comme une structure
void afficher_interface_sauvegarde_structure(bool);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
}; };
......
#ifndef STRUCTURESAVINGDIALOG_HPP
#define STRUCTURESAVINGDIALOG_HPP
#include <QDialog>
namespace Ui {
class StructureSavingDialog;
}
class StructureSavingDialog : public QDialog
{
Q_OBJECT
public:
explicit StructureSavingDialog(QWidget *parent = nullptr);
~StructureSavingDialog();
QString auteur() const;
QString titre() const;
QString desc() const;
QDate date() const;
private:
Ui::StructureSavingDialog *ui;
};
#endif // STRUCTURESAVINGDIALOG_HPP
#include "interface.hpp" #include "interface.hpp"
#include "ui_interface.h" #include "ui_interface.h"
#include "structuresavingdialog.hpp"
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent) : QMainWindow(parent)
, ui(new Ui::MainWindow) , ui(new Ui::MainWindow)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(ui->action_save_struct, &QAction::triggered, this, &MainWindow::afficher_interface_sauvegarde_structure);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -68,6 +72,12 @@ void MainWindow::on_heightSpinBox_valueChanged(int arg1) ...@@ -68,6 +72,12 @@ void MainWindow::on_heightSpinBox_valueChanged(int arg1)
ui->validateGridDim->setEnabled(true); ui->validateGridDim->setEnabled(true);
} }
void MainWindow::afficher_interface_sauvegarde_structure(bool)
{
StructureSavingDialog dialog(this);
dialog.exec();
}
void MainWindow::on_validateGridDim_clicked() void MainWindow::on_validateGridDim_clicked()
{ {
......
...@@ -24,7 +24,8 @@ SOURCES += \ ...@@ -24,7 +24,8 @@ SOURCES += \
grid.cpp \ grid.cpp \
history.cpp \ history.cpp \
vonNeumannNeighborhoodRule.cpp \ vonNeumannNeighborhoodRule.cpp \
structurewriter.cpp structurewriter.cpp \
structuresavingdialog.cpp
HEADERS += \ HEADERS += \
../include/coord.hpp \ ../include/coord.hpp \
...@@ -44,10 +45,12 @@ HEADERS += \ ...@@ -44,10 +45,12 @@ HEADERS += \
../include/alphabet.hpp \ ../include/alphabet.hpp \
../include/stateColor.hpp \ ../include/stateColor.hpp \
../include/state.hpp \ ../include/state.hpp \
../include/history.h ../include/history.h \
../include/structuresavingdialog.hpp
FORMS += \ FORMS += \
../forms/interface.ui ../forms/interface.ui \
../forms/structuresavingdialog.ui
# Default rules for deployment. # Default rules for deployment.
......
#include "structuresavingdialog.hpp"
#include "ui_structuresavingdialog.h"
#include <QDate>
StructureSavingDialog::StructureSavingDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::StructureSavingDialog)
{
ui->setupUi(this);
// récupérer le nom de l'utilisateur actuel
QString name;
name = qgetenv("USER"); // get the user name in Linux
if (name.isEmpty())
name = qgetenv("USERNAME"); // get the name in Windows
ui->auteur->setText(name);
ui->date->setDate(QDate::currentDate());
}
StructureSavingDialog::~StructureSavingDialog()
{
delete ui;
}
QString StructureSavingDialog::auteur() const
{
return ui->auteur->text();
}
QString StructureSavingDialog::titre() const
{
return ui->nom->text();
}
QString StructureSavingDialog::desc() const
{
return ui->desc->toPlainText();
}
QDate StructureSavingDialog::date() const
{
return ui->date->date();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment