Commit 12743c1e authored by Thiago Santini's avatar Thiago Santini

Unchecks widgets' button when window is closed

Man, I really need to make a base class for the widgets...
parent 8aad4435
...@@ -42,7 +42,8 @@ signals: ...@@ -42,7 +42,8 @@ signals:
void newROI(QPointF sROI, QPointF eROI); void newROI(QPointF sROI, QPointF eROI);
void newData(EyeData data); void newData(EyeData data);
void newData(FieldData data); void newData(FieldData data);
void newClick(Timestamp,QPoint,QSize); void newClick(Timestamp,QPoint,QSize);
void closed();
public slots: public slots:
void preview(Timestamp t, const cv::Mat &frame); void preview(Timestamp t, const cv::Mat &frame);
...@@ -108,7 +109,10 @@ private: ...@@ -108,7 +109,10 @@ private:
void drawROI(QPainter &painter); void drawROI(QPainter &painter);
void drawPupil(const cv::RotatedRect ellipse, QPainter &painter); void drawPupil(const cv::RotatedRect ellipse, QPainter &painter);
void drawMarker(const Marker &marker, QPainter &painter, QColor color); void drawMarker(const Marker &marker, QPainter &painter, QColor color);
void drawGaze(const FieldData &field, QPainter &painter); void drawGaze(const FieldData &field, QPainter &painter);
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE { Q_UNUSED(event) emit closed(); }
}; };
#endif // CAMERAWIDGET_H #endif // CAMERAWIDGET_H
...@@ -35,6 +35,7 @@ signals: ...@@ -35,6 +35,7 @@ signals:
void loadTuplesFromFile(CollectionTuple::TupleType type, QString fileName); void loadTuplesFromFile(CollectionTuple::TupleType type, QString fileName);
void calibrationRequest(); void calibrationRequest();
void setCalibrating(bool v); void setCalibrating(bool v);
void closed();
public slots: public slots:
...@@ -87,7 +88,10 @@ private slots: ...@@ -87,7 +88,10 @@ private slots:
void on_granularitySB_valueChanged(int arg1); void on_granularitySB_valueChanged(int arg1);
void on_rangeFactorSB_valueChanged(int arg1); void on_rangeFactorSB_valueChanged(int arg1);
void on_visualizationGroupBox_toggled(bool arg1); void on_visualizationGroupBox_toggled(bool arg1);
void on_visualizationTimeSpinBox_valueChanged(int arg1); void on_visualizationTimeSpinBox_valueChanged(int arg1);
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE { Q_UNUSED(event) emit closed(); }
}; };
#endif // GAZEESTIMATIONWIDGET_H #endif // GAZEESTIMATIONWIDGET_H
...@@ -14,7 +14,10 @@ class LogWidget : public QMainWindow ...@@ -14,7 +14,10 @@ class LogWidget : public QMainWindow
public: public:
explicit LogWidget(QWidget *parent = 0); explicit LogWidget(QWidget *parent = 0);
~LogWidget(); ~LogWidget();
signals:
void closed();
public slots: public slots:
void appendMessage(const QString &msg); void appendMessage(const QString &msg);
...@@ -25,7 +28,10 @@ private slots: ...@@ -25,7 +28,10 @@ private slots:
void on_addMsg_clicked(); void on_addMsg_clicked();
private: private:
Ui::LogWidget *ui; Ui::LogWidget *ui;
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE { Q_UNUSED(event) emit closed(); }
}; };
#endif // LOGWIDGET_H #endif // LOGWIDGET_H
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "ui_MainWindow.h" #include "ui_MainWindow.h"
// TODO: refactor MainWindow into a config aware class that can be shared by the // TODO: refactor MainWindow into a config aware class that can be shared by the
// widgets // widgets. Also add the gui interface there.
void MainWindow::createExtraMenus() void MainWindow::createExtraMenus()
{ {
...@@ -37,7 +37,9 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -37,7 +37,9 @@ MainWindow::MainWindow(QWidget *parent) :
logWidget = new LogWidget(); logWidget = new LogWidget();
setupWidget(logWidget, cfg.logWidgetPos, cfg.logWidgetSize, cfg.logWidgetVisible, ui->log); setupWidget(logWidget, cfg.logWidgetPos, cfg.logWidgetSize, cfg.logWidgetVisible, ui->log);
gLogWidget = logWidget; connect(logWidget, SIGNAL(closed()),
this, SLOT(logWidgetClosed()) );
gLogWidget = logWidget;
/* /*
* WARNING: DO NOT REMOVE THIS CALL to QCameraInfo::availableCameras() * WARNING: DO NOT REMOVE THIS CALL to QCameraInfo::availableCameras()
...@@ -52,15 +54,21 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -52,15 +54,21 @@ MainWindow::MainWindow(QWidget *parent) :
*/ */
lEyeWidget = new CameraWidget("LeftEye", ImageProcessor::Eye); lEyeWidget = new CameraWidget("LeftEye", ImageProcessor::Eye);
lEyeWidget->setWindowIcon(QIcon(":/icons/lEyeWidget.png")); lEyeWidget->setWindowIcon(QIcon(":/icons/lEyeWidget.png"));
setupWidget(lEyeWidget, cfg.leftEyeWidgetPos, cfg.leftEyeWidgetSize, cfg.leftEyeWidgetVisible, ui->leftEyeCam); setupWidget(lEyeWidget, cfg.leftEyeWidgetPos, cfg.leftEyeWidgetSize, cfg.leftEyeWidgetVisible, ui->leftEyeCam);
QThread::msleep(200); connect(lEyeWidget, SIGNAL(closed()),
this, SLOT(lEyeWidgetClosed()) );
QThread::msleep(200);
rEyeWidget = new CameraWidget("RightEye", ImageProcessor::Eye); rEyeWidget = new CameraWidget("RightEye", ImageProcessor::Eye);
rEyeWidget->setWindowIcon(QIcon(":/icons/rEyeWidget.png")); rEyeWidget->setWindowIcon(QIcon(":/icons/rEyeWidget.png"));
setupWidget(rEyeWidget, cfg.rightEyeWidgetPos, cfg.rightEyeWidgetSize, cfg.rightEyeWidgetVisible, ui->rightEyeCam); setupWidget(rEyeWidget, cfg.rightEyeWidgetPos, cfg.rightEyeWidgetSize, cfg.rightEyeWidgetVisible, ui->rightEyeCam);
QThread::msleep(200); connect(rEyeWidget, SIGNAL(closed()),
this, SLOT(rEyeWidgetClosed()) );
QThread::msleep(200);
fieldWidget = new CameraWidget("Field", ImageProcessor::Field); fieldWidget = new CameraWidget("Field", ImageProcessor::Field);
fieldWidget->setWindowIcon(QIcon(":/icons/fieldWidget.png")); fieldWidget->setWindowIcon(QIcon(":/icons/fieldWidget.png"));
setupWidget(fieldWidget, cfg.fieldWidgetPos, cfg.fieldWidgetSize, cfg.fieldWidgetVisible, ui->fieldCam); setupWidget(fieldWidget, cfg.fieldWidgetPos, cfg.fieldWidgetSize, cfg.fieldWidgetVisible, ui->fieldCam);
connect(fieldWidget, SIGNAL(closed()),
this, SLOT(fieldWidgetClosed()) );
/* /*
* Synchronizer * Synchronizer
...@@ -82,6 +90,8 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -82,6 +90,8 @@ MainWindow::MainWindow(QWidget *parent) :
gazeEstimationWidget, SIGNAL(inDataTuple(DataTuple)) ); gazeEstimationWidget, SIGNAL(inDataTuple(DataTuple)) );
connect(fieldWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)), connect(fieldWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)),
gazeEstimationWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)) ); gazeEstimationWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)) );
connect(gazeEstimationWidget, SIGNAL(closed()),
this, SLOT(gazeEstimationWidgetClosed()) );
connect(gazeEstimationWidget, SIGNAL(outDataTuple(DataTuple)), connect(gazeEstimationWidget, SIGNAL(outDataTuple(DataTuple)),
fieldWidget, SLOT(preview(DataTuple)) ); fieldWidget, SLOT(preview(DataTuple)) );
...@@ -101,6 +111,8 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -101,6 +111,8 @@ MainWindow::MainWindow(QWidget *parent) :
performanceMonitorWidget = new PerformanceMonitorWidget(); performanceMonitorWidget = new PerformanceMonitorWidget();
setupWidget(performanceMonitorWidget, cfg.performanceMonitorWidgetPos, cfg.performanceMonitorWidgetSize, cfg.performanceMonitorWidgetVisible, ui->performanceMonitor); setupWidget(performanceMonitorWidget, cfg.performanceMonitorWidgetPos, cfg.performanceMonitorWidgetSize, cfg.performanceMonitorWidgetVisible, ui->performanceMonitor);
connect(performanceMonitorWidget, SIGNAL(closed()),
this, SLOT(performanceMonitorWidgetClosed()) );
// GUI to Widgets signals // GUI to Widgets signals
connect(this, SIGNAL(startRecording()), connect(this, SIGNAL(startRecording()),
...@@ -551,5 +563,12 @@ void MainWindow::setupWidget(QMainWindow *window, QPoint &position, const QSize ...@@ -551,5 +563,12 @@ void MainWindow::setupWidget(QMainWindow *window, QPoint &position, const QSize
window->show(); window->show();
if (button) if (button)
button->setChecked(visible); button->setChecked(visible);
} }
void MainWindow::logWidgetClosed() { ui->log->setChecked(false); }
void MainWindow::lEyeWidgetClosed() { ui->leftEyeCam->setChecked(false); }
void MainWindow::rEyeWidgetClosed() { ui->rightEyeCam->setChecked(false); }
void MainWindow::fieldWidgetClosed() { ui->fieldCam->setChecked(false); }
void MainWindow::gazeEstimationWidgetClosed() { ui->gazeEstimation->setChecked(false); }
void MainWindow::performanceMonitorWidgetClosed() { ui->performanceMonitor->setChecked(false); }
...@@ -172,8 +172,8 @@ private: ...@@ -172,8 +172,8 @@ private:
void setSubjectName(QString newSubjectName); void setSubjectName(QString newSubjectName);
void setWorkingDirectory(QString dir); void setWorkingDirectory(QString dir);
void widgetButtonReact(QMainWindow *window, bool checked); void widgetButtonReact(QMainWindow *window, bool checked);
void createExtraMenus(); void createExtraMenus();
void setupWidget(QMainWindow *window, QPoint &position, const QSize &size, const bool &visible=true, QPushButton *button=NULL); void setupWidget(QMainWindow *window, QPoint &position, const QSize &size, const bool &visible=true, QPushButton *button=NULL);
protected: protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
...@@ -196,7 +196,14 @@ private slots: ...@@ -196,7 +196,14 @@ private slots:
void showReferencesDialog(); void showReferencesDialog();
void showAboutDialog(); void showAboutDialog();
void on_log_clicked(); void on_log_clicked();
void on_performanceMonitor_clicked(); void on_performanceMonitor_clicked();
void logWidgetClosed();
void lEyeWidgetClosed();
void rEyeWidgetClosed();
void fieldWidgetClosed();
void gazeEstimationWidgetClosed();
void performanceMonitorWidgetClosed();
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
...@@ -17,13 +17,12 @@ public: ...@@ -17,13 +17,12 @@ public:
QString getEnrolled(const unsigned int &idx) { return idx < enrolled.size() ? enrolled[idx] : QString(); } QString getEnrolled(const unsigned int &idx) { return idx < enrolled.size() ? enrolled[idx] : QString(); }
unsigned int enrolledCount() { return (unsigned int) enrolled.size(); } unsigned int enrolledCount() { return (unsigned int) enrolled.size(); }
void report();
void report();
private: private:
std::vector<QString> enrolled; std::vector<QString> enrolled;
unsigned int delayedFrameCount; unsigned int delayedFrameCount;
bool frameDropEnabled; bool frameDropEnabled;
}; };
#endif // PERFORMANCEMONITOR_H #endif // PERFORMANCEMONITOR_H
...@@ -20,7 +20,10 @@ class PerformanceMonitorWidget : public QMainWindow ...@@ -20,7 +20,10 @@ class PerformanceMonitorWidget : public QMainWindow
public: public:
explicit PerformanceMonitorWidget(QWidget *parent = 0); explicit PerformanceMonitorWidget(QWidget *parent = 0);
~PerformanceMonitorWidget(); ~PerformanceMonitorWidget();
signals:
void closed();
private: private:
Ui::PerformanceMonitorWidget *ui; Ui::PerformanceMonitorWidget *ui;
...@@ -34,7 +37,10 @@ private: ...@@ -34,7 +37,10 @@ private:
private slots: private slots:
void update(); void update();
void on_resetCounters_clicked(); void on_resetCounters_clicked();
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE { Q_UNUSED(event) emit closed(); }
}; };
#endif // PERFORMANCEMONITORWIDGET_H #endif // PERFORMANCEMONITORWIDGET_H
Markdown is supported
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