Ver código fonte

Adding buttons and progressBar to csl

Rémi Synave 2 anos atrás
pai
commit
d8e888d9ed
3 arquivos alterados com 77 adições e 15 exclusões
  1. 2 2
      WorkArea/WorkArea.cpp
  2. 67 13
      csl/MainWindow.cpp
  3. 8 0
      csl/MainWindow.hpp

+ 2 - 2
WorkArea/WorkArea.cpp

@@ -65,7 +65,7 @@ WorkArea::loadImage (const std::string & filename)
 void
 WorkArea::loadSL (const std::string & filename)
 {
-  qDebug() << resizeFactor << Qt::endl;
+  //qDebug() << resizeFactor << Qt::endl;
   liste_points.clear();
   QFile file(QString::fromStdString (filename));
   if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
@@ -77,7 +77,7 @@ WorkArea::loadSL (const std::string & filename)
     QStringList parts = line.split(" ");
     liste_points << new QPoint((int)(parts[0].toDouble()*resizeFactor), (int)(parts[1].toDouble()*resizeFactor));
     liste_points << new QPoint((int)(parts[2].toDouble()*resizeFactor), (int)(parts[3].toDouble()*resizeFactor));
-    qDebug() << liste_points.back()->x() << " " << liste_points.back()->y() << Qt::endl;
+    //qDebug() << liste_points.back()->x() << " " << liste_points.back()->y() << Qt::endl;
   }
   file.close();
 }

+ 67 - 13
csl/MainWindow.cpp

@@ -28,25 +28,71 @@ MainWindow::MainWindow ()
   setCentralWidget (central);
   setContentsMargins(0, 0, 0, 0);
 
-  QHBoxLayout *layout = new QHBoxLayout(central);
-  layout->setSpacing(0);
-  layout->setContentsMargins(0, 0, 0, 0);
-  central->setLayout(layout);
+  QVBoxLayout *layoutV = new QVBoxLayout(central);
+  layoutV->setSpacing(0);
+  layoutV->setContentsMargins(0, 0, 0, 0);
+  central->setLayout(layoutV);
+
+  // First line of the interface
+  QHBoxLayout *layoutH1 = new QHBoxLayout(central);
+  layoutH1->setSpacing(0);
+  layoutH1->setContentsMargins(0, 0, 0, 0);
+  layoutV->addLayout(layoutH1);
   
-  waLeft = new WorkArea (((screenWidth-spaceInBetween)/2), screenHeight, this);
+  waLeft = new WorkArea (((screenWidth-spaceInBetween)/2), screenHeight, central);
   waLeft->setContentsMargins(0, 0, 0, 0);
-  layout->addWidget(waLeft);
+  layoutH1->addWidget(waLeft);
 
-  QWidget *wSpaceInBetween = new QWidget();
-  wSpaceInBetween->setContentsMargins(0, 0, 0, 0);
-  wSpaceInBetween->setFixedSize(spaceInBetween,0);
-  layout->addWidget(wSpaceInBetween);
+  QWidget *w1SpaceInBetween = new QWidget(central);
+  w1SpaceInBetween->setContentsMargins(0, 0, 0, 0);
+  w1SpaceInBetween->setFixedSize(spaceInBetween,0);
+  layoutH1->addWidget(w1SpaceInBetween);
   
-  waRight = new WorkArea ((screenWidth/2), screenHeight, this);
+  waRight = new WorkArea (((screenWidth-spaceInBetween)/2), screenHeight, central);
   waRight->setContentsMargins(0, 0, 0, 0);
-  layout->addWidget(waRight);
+  layoutH1->addWidget(waRight);
+
+  // second line of interface
+  QWidget *hSpaceInBetween = new QWidget(central);
+  hSpaceInBetween->setContentsMargins(0, 0, 0, 0);
+  hSpaceInBetween->setFixedSize(0, spaceInBetween);
+  layoutV->addWidget(hSpaceInBetween);
+
+  // third line of interface
+  QHBoxLayout *layoutH2 = new QHBoxLayout(central);
+  layoutH2->setSpacing(0);
+  layoutH2->setContentsMargins(0, 0, 0, 0);
+  layoutV->addLayout(layoutH2);
+
+  leftButton = new QPushButton("Image de gauche", central);
+  leftButton->setFixedHeight(30);
+  connect(leftButton, SIGNAL(clicked(bool)), this, SLOT(leftImage()));
+  layoutH2->addWidget(leftButton);
+
+  QWidget *w2SpaceInBetween = new QWidget();
+  w2SpaceInBetween->setContentsMargins(0, 0, 0, 0);
+  w2SpaceInBetween->setFixedSize(spaceInBetween,0);
+  layoutH2->addWidget(w2SpaceInBetween);
+
+  rightButton = new QPushButton("Image de droite", central);
+  rightButton->setFixedHeight(30);
+  connect(rightButton, SIGNAL(clicked(bool)), this, SLOT(rightImage()));
+  layoutH2->addWidget(rightButton);
+
+  // Fourth line of the interface
+  progressBar = new QProgressBar(central);
+  progressBar->setFixedHeight(20);
+  layoutV->addWidget(progressBar);
   
   setFixedSize (screenWidth, screenHeight);
+
+  /*POUR TEST*/
+  
+  QString img_a_ouvrir("/home/remi/images/screenshot.png");
+  QString sl1_a_ouvrir("/home/remi/images/screenshot.txt");
+  QString sl2_a_ouvrir("/home/remi/images/screenshotb.txt");
+
+  openC( img_a_ouvrir, sl1_a_ouvrir, sl2_a_ouvrir);
 }
 
 void
@@ -77,6 +123,14 @@ MainWindow::open ()
   openC(imageFilename, SLLeftFilename, SLRightFilename);
 }
 
+void MainWindow::leftImage(){
+  qDebug() << "Clic sur image gauche" << Qt::endl;
+}
+
+void MainWindow::rightImage(){
+  qDebug() << "Clic sur image droite" << Qt::endl;
+}
+
 void
 MainWindow::openC (QString image, QString leftSL, QString rightSL){
   waLeft->loadImage (image.toStdString ());
@@ -85,7 +139,7 @@ MainWindow::openC (QString image, QString leftSL, QString rightSL){
   waRight->loadSL(rightSL.toStdString());
   waLeft->setReadOnly(true);
   waRight->setReadOnly(true);
-  setFixedSize (waLeft->geometry().width()*2+spaceInBetween, waLeft->geometry().height()+waLeft->geometry().y()+22); // +22 ??!!
+  setFixedSize (waLeft->geometry().width()*2+spaceInBetween, waLeft->geometry().height()+waLeft->geometry().y()+spaceInBetween+leftButton->geometry().height()+22); // +22 ??!!
 }
 
 void

+ 8 - 0
csl/MainWindow.hpp

@@ -4,6 +4,8 @@
 #include <QMainWindow>
 #include <QAction>
 #include <QMenu>
+#include <QPushButton>
+#include <QProgressBar>
 
 #include "WorkArea.hpp"
 
@@ -25,12 +27,18 @@ private:
   WorkArea *waLeft;
   WorkArea *waRight;
 
+  QPushButton *leftButton, *rightButton;
+
+  QProgressBar *progressBar;
+
   void createActions ();
   void createMenus ();
 
 		     
 private slots:
   void open ();
+  void leftImage();
+  void rightImage();
 
   
 public: