Parcourir la source

Adding some informations to fill in the first window in csl

Rémi Synave il y a 1 an
Parent
commit
5c4a2e0efa
6 fichiers modifiés avec 121 ajouts et 24 suppressions
  1. 13 11
      csl/MainWindow.cpp
  2. 4 4
      csl/MainWindow.hpp
  3. 52 0
      csl/Informations.cpp
  4. 31 0
      csl/Informations.hpp
  5. 4 2
      csl/csl.pro
  6. 17 7
      csl/main.cpp

+ 13 - 11
csl/MainWindow.cpp

@@ -9,10 +9,10 @@
 
 #include <QDebug>
 
-#include "MainWindow.hpp"
+#include "Experiment.hpp"
 
 
-MainWindow::MainWindow ()
+Experiment::Experiment ():QMainWindow()
 {
   createActions ();
   createMenus ();
@@ -106,7 +106,7 @@ MainWindow::MainWindow ()
 }
 
 void
-MainWindow::open ()
+Experiment::open ()
 {
   QString imageFilename = QFileDialog::getOpenFileName (this,
 						   QObject::
@@ -133,26 +133,28 @@ MainWindow::open ()
   openC(imageFilename, SLLeftFilename, SLRightFilename);
 }
 
-void MainWindow::leftImage(){
+void Experiment::leftImage(){
   qDebug() << "Clic sur image gauche" << Qt::endl;
+  progressBar->setValue(0);
 }
 
-void MainWindow::rightImage(){
+void Experiment::rightImage(){
   qDebug() << "Clic sur image droite" << Qt::endl;
+  progressBar->setValue(0);
 }
 
-void MainWindow::progressBarValueChanged(int value){
+void Experiment::progressBarValueChanged(int value){
   if(value == maxProgressBar ){
     QApplication::quit();
   }
 }
 
-void MainWindow::ticTimer(){
+void Experiment::ticTimer(){
   progressBar->setValue(progressBar->value()+time);
 }
 
 void
-MainWindow::openC (QString image, QString leftSL, QString rightSL){
+Experiment::openC (QString image, QString leftSL, QString rightSL){
   waLeft->loadImage (image.toStdString ());
   waRight->loadImage (image.toStdString ());
   waLeft->loadSL(leftSL.toStdString());
@@ -163,11 +165,11 @@ MainWindow::openC (QString image, QString leftSL, QString rightSL){
 }
 
 void
-MainWindow::createActions ()
+Experiment::createActions ()
 {
   openAct = new QAction (tr ("&Open image"), this);
   openAct->setShortcuts (QKeySequence::Open);
-  connect (openAct, &QAction::triggered, this, &MainWindow::open);
+  connect (openAct, &QAction::triggered, this, &Experiment::open);
 
   exitAct = new QAction (tr ("E&xit"), this);
   exitAct->setShortcuts (QKeySequence::Quit);
@@ -175,7 +177,7 @@ MainWindow::createActions ()
 }
 
 void
-MainWindow::createMenus ()
+Experiment::createMenus ()
 {
   fileMenu = menuBar ()->addMenu (tr ("&File"));
   fileMenu->addAction (openAct);

+ 4 - 4
csl/MainWindow.hpp

@@ -1,5 +1,5 @@
-#ifndef MAINWINDOW_HPP
-#define MAINWINDOW_HPP
+#ifndef EXPERIMENT_HPP
+#define EXPERIMENT_HPP
 
 #include <QApplication>
 #include <QMainWindow>
@@ -12,7 +12,7 @@
 #include "WorkArea.hpp"
 
 
-class MainWindow: public QMainWindow
+class Experiment: public QMainWindow
 {
   Q_OBJECT 
 
@@ -48,7 +48,7 @@ private slots:
   void ticTimer();
   
 public:
-  MainWindow ();
+  Experiment ();
   void openC (QString image, QString leftSL, QString rightSL);
   
 };

+ 52 - 0
csl/Informations.cpp

@@ -0,0 +1,52 @@
+#include <QWidget>
+#include <QFileDialog>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+
+#include <QDebug>
+
+#include "Informations.hpp"
+
+
+Informations::Informations (QString &fts):QMainWindow(),fileToSave(fts)
+{
+  setWindowTitle (tr ("DSL - Draw Strength Line"));
+
+  QWidget *central= new QWidget(this);
+  setCentralWidget (central);
+
+  QVBoxLayout *layoutV = new QVBoxLayout(central);
+  central->setLayout(layoutV);
+
+  // First line of the interface
+  QHBoxLayout *layoutH1 = new QHBoxLayout(central);
+  layoutV->addLayout(layoutH1);
+  nameL = new QLabel("Nom : ", central);
+  layoutH1->addWidget(nameL);
+  nameT = new QTextEdit(central);
+  layoutH1->addWidget(nameT);
+
+  // Second line of the interface
+  QHBoxLayout *layoutH2 = new QHBoxLayout(central);
+  layoutV->addLayout(layoutH2);
+  surnameL = new QLabel("Prénom : ", central);
+  layoutH2->addWidget(surnameL);
+  surnameT = new QTextEdit(central);
+  layoutH2->addWidget(surnameT);
+
+
+
+  readyB = new QPushButton("Prêt !");
+  connect(readyB, SIGNAL(clicked(bool)), this, SLOT(ready()));
+  layoutV->addWidget(readyB);
+
+}
+
+
+
+void Informations::ready(){
+  qDebug() << "Je suis prêt" << Qt::endl;
+  fileToSave = "test.txt";
+  close();
+}
+

+ 31 - 0
csl/Informations.hpp

@@ -0,0 +1,31 @@
+#ifndef INFORMATIONS_HPP
+#define INFORMATIONS_HPP
+
+#include <QApplication>
+#include <QMainWindow>
+#include <QLabel>
+#include <QTextEdit>
+#include <QPushButton>
+
+
+class Informations: public QMainWindow
+{
+  Q_OBJECT 
+
+
+private:
+  QString &fileToSave;
+  
+  QPushButton *readyB;
+
+  QLabel *nameL, *surnameL;
+  QTextEdit *nameT, *surnameT;
+		     
+private slots:
+  void ready ();
+  
+public:
+  Informations (QString &fts);  
+};
+
+#endif

+ 4 - 2
csl/csl.pro

@@ -5,11 +5,13 @@ INCLUDEPATH = ../StrengthLine/ \
 
 HEADERS = ../StrengthLine/StrengthLine.hpp \
           ../WorkArea/WorkArea.hpp \
-          MainWindow.hpp
+          Experiment.hpp \
+          Informations.hpp
                 
 SOURCES = ../StrengthLine/StrengthLine.cpp \
           ../WorkArea/WorkArea.cpp \
-          MainWindow.cpp \
+          Experiment.cpp \
+          Informations.cpp \
           main.cpp
 
 # install

+ 17 - 7
csl/main.cpp

@@ -1,19 +1,29 @@
 #include <QApplication>
 #include <QDebug>
 
-#include "MainWindow.hpp"
+#include "Informations.hpp"
+#include "Experiment.hpp"
 
 int
 main (int argc, char *argv[])
 {
+  QString fileToSave = "";
+  
   QApplication app (argc, argv);
   
-  QMainWindow waitingWindow;
-  waitingWindow.show();
+  Informations infos(fileToSave);
+  infos.show();
   app.exec();
-    
-  MainWindow window;
-  window.show ();
-  app.exec ();
+
+  if(fileToSave=="")
+    qDebug() << "Erreur dans le formulaire de départ" << Qt::endl;
+  else
+    {
+      qDebug() << "Chaine recue : " << fileToSave << Qt::endl;
+      
+      Experiment window;
+      window.show ();
+      app.exec ();
+    }
   return 0;
 }