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:
void newROI(QPointF sROI, QPointF eROI);
void newData(EyeData data);
void newData(FieldData data);
void newClick(Timestamp,QPoint,QSize);
void newClick(Timestamp,QPoint,QSize);
void closed();
public slots:
void preview(Timestamp t, const cv::Mat &frame);
......@@ -108,7 +109,10 @@ private:
void drawROI(QPainter &painter);
void drawPupil(const cv::RotatedRect ellipse, QPainter &painter);
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
......@@ -35,6 +35,7 @@ signals:
void loadTuplesFromFile(CollectionTuple::TupleType type, QString fileName);
void calibrationRequest();
void setCalibrating(bool v);
void closed();
public slots:
......@@ -87,7 +88,10 @@ private slots:
void on_granularitySB_valueChanged(int arg1);
void on_rangeFactorSB_valueChanged(int 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
......@@ -14,7 +14,10 @@ class LogWidget : public QMainWindow
public:
explicit LogWidget(QWidget *parent = 0);
~LogWidget();
~LogWidget();
signals:
void closed();
public slots:
void appendMessage(const QString &msg);
......@@ -25,7 +28,10 @@ private slots:
void on_addMsg_clicked();
private:
Ui::LogWidget *ui;
Ui::LogWidget *ui;
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE { Q_UNUSED(event) emit closed(); }
};
#endif // LOGWIDGET_H
......@@ -2,7 +2,7 @@
#include "ui_MainWindow.h"
// 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()
{
......@@ -37,7 +37,9 @@ MainWindow::MainWindow(QWidget *parent) :
logWidget = new LogWidget();
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()
......@@ -52,15 +54,21 @@ MainWindow::MainWindow(QWidget *parent) :
*/
lEyeWidget = new CameraWidget("LeftEye", ImageProcessor::Eye);
lEyeWidget->setWindowIcon(QIcon(":/icons/lEyeWidget.png"));
setupWidget(lEyeWidget, cfg.leftEyeWidgetPos, cfg.leftEyeWidgetSize, cfg.leftEyeWidgetVisible, ui->leftEyeCam);
QThread::msleep(200);
setupWidget(lEyeWidget, cfg.leftEyeWidgetPos, cfg.leftEyeWidgetSize, cfg.leftEyeWidgetVisible, ui->leftEyeCam);
connect(lEyeWidget, SIGNAL(closed()),
this, SLOT(lEyeWidgetClosed()) );
QThread::msleep(200);
rEyeWidget = new CameraWidget("RightEye", ImageProcessor::Eye);
rEyeWidget->setWindowIcon(QIcon(":/icons/rEyeWidget.png"));
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->setWindowIcon(QIcon(":/icons/fieldWidget.png"));
setupWidget(fieldWidget, cfg.fieldWidgetPos, cfg.fieldWidgetSize, cfg.fieldWidgetVisible, ui->fieldCam);
connect(fieldWidget, SIGNAL(closed()),
this, SLOT(fieldWidgetClosed()) );
/*
* Synchronizer
......@@ -82,6 +90,8 @@ MainWindow::MainWindow(QWidget *parent) :
gazeEstimationWidget, SIGNAL(inDataTuple(DataTuple)) );
connect(fieldWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)),
gazeEstimationWidget, SIGNAL(newClick(Timestamp,QPoint,QSize)) );
connect(gazeEstimationWidget, SIGNAL(closed()),
this, SLOT(gazeEstimationWidgetClosed()) );
connect(gazeEstimationWidget, SIGNAL(outDataTuple(DataTuple)),
fieldWidget, SLOT(preview(DataTuple)) );
......@@ -101,6 +111,8 @@ MainWindow::MainWindow(QWidget *parent) :
performanceMonitorWidget = new PerformanceMonitorWidget();
setupWidget(performanceMonitorWidget, cfg.performanceMonitorWidgetPos, cfg.performanceMonitorWidgetSize, cfg.performanceMonitorWidgetVisible, ui->performanceMonitor);
connect(performanceMonitorWidget, SIGNAL(closed()),
this, SLOT(performanceMonitorWidgetClosed()) );
// GUI to Widgets signals
connect(this, SIGNAL(startRecording()),
......@@ -551,5 +563,12 @@ void MainWindow::setupWidget(QMainWindow *window, QPoint &position, const QSize
window->show();
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:
void setSubjectName(QString newSubjectName);
void setWorkingDirectory(QString dir);
void widgetButtonReact(QMainWindow *window, bool checked);
void createExtraMenus();
void setupWidget(QMainWindow *window, QPoint &position, const QSize &size, const bool &visible=true, QPushButton *button=NULL);
void createExtraMenus();
void setupWidget(QMainWindow *window, QPoint &position, const QSize &size, const bool &visible=true, QPushButton *button=NULL);
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
......@@ -196,7 +196,14 @@ private slots:
void showReferencesDialog();
void showAboutDialog();
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
......@@ -17,13 +17,12 @@ public:
QString getEnrolled(const unsigned int &idx) { return idx < enrolled.size() ? enrolled[idx] : QString(); }
unsigned int enrolledCount() { return (unsigned int) enrolled.size(); }
void report();
void report();
private:
std::vector<QString> enrolled;
unsigned int delayedFrameCount;
bool frameDropEnabled;
bool frameDropEnabled;
};
#endif // PERFORMANCEMONITOR_H
......@@ -20,7 +20,10 @@ class PerformanceMonitorWidget : public QMainWindow
public:
explicit PerformanceMonitorWidget(QWidget *parent = 0);
~PerformanceMonitorWidget();
~PerformanceMonitorWidget();
signals:
void closed();
private:
Ui::PerformanceMonitorWidget *ui;
......@@ -34,7 +37,10 @@ private:
private slots:
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
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