Commit 08e920f3 authored by Thiago Santini's avatar Thiago Santini

Reorganizing commands

parent a07b649b
...@@ -12,12 +12,18 @@ CommandManager::CommandManager(QObject *parent) ...@@ -12,12 +12,18 @@ CommandManager::CommandManager(QObject *parent)
bool hasSettings = QFile::exists(settingsFileName); bool hasSettings = QFile::exists(settingsFileName);
QSettings *settings = new QSettings(settingsFileName, QSettings::IniFormat); QSettings *settings = new QSettings(settingsFileName, QSettings::IniFormat);
if (hasSettings) { if (hasSettings) {
calibrationToggleKey = settings->value("calibrationToggleKey").toInt(); remoteCalibrationToggleKey = settings->value("remoteCalibrationToggleKey").toInt();
recordingToggleKey = settings->value("recordingToggleKey").toInt(); remoteRecordingToggleKey = settings->value("remoteRecordingToggleKey").toInt();
calibrationToggleKey = settings->value("calibrationToggleKey").toInt();
collectionToggleKey = settings->value("collectionToggleKey").toInt();
recordingToggleKey = settings->value("recordingToggleKey").toInt();
previewToggleKey = settings->value("previewToggleKey").toInt(); previewToggleKey = settings->value("previewToggleKey").toInt();
} else { } else {
settings->setValue("calibrationToggleKey", calibrationToggleKey); settings->setValue("remoteCalibrationToggleKey", remoteCalibrationToggleKey);
settings->setValue("recordingToggleKey", recordingToggleKey); settings->setValue("remoteRecordingToggleKey", remoteRecordingToggleKey);
settings->setValue("calibrationToggleKey", calibrationToggleKey);
settings->setValue("collectionToggleKey", collectionToggleKey);
settings->setValue("recordingToggleKey", recordingToggleKey);
settings->setValue("previewToggleKey", previewToggleKey); settings->setValue("previewToggleKey", previewToggleKey);
} }
settings->deleteLater(); settings->deleteLater();
...@@ -29,17 +35,15 @@ void CommandManager::keyPress(QKeyEvent *event) ...@@ -29,17 +35,15 @@ void CommandManager::keyPress(QKeyEvent *event)
if (event->isAutoRepeat()) if (event->isAutoRepeat())
return; return;
if (event->key() == calibrationToggleKey) { if (event->key() == remoteCalibrationToggleKey) {
if (calibrating) { emit toggleRemoteCalibration();
calibrating = false; } else if (event->key() == remoteRecordingToggleKey) {
emit disableMarkerCollection(); emit toggleRemoteRecording();
emit toggleCalibration(); } else if (event->key() == calibrationToggleKey) {
} else { emit toggleCalibration();
calibrating = true; } else if (event->key() == collectionToggleKey) {
emit toggleCalibration(); emit toggleMarkerCollection();
emit enableMarkerCollection(); } else if (event->key() == recordingToggleKey) {
}
} else if (event->key() == recordingToggleKey) {
emit toggleRecording(); emit toggleRecording();
} else if (event->key() == previewToggleKey ){ } else if (event->key() == previewToggleKey ){
emit togglePreview(); emit togglePreview();
......
...@@ -20,18 +20,21 @@ public slots: ...@@ -20,18 +20,21 @@ public slots:
signals: signals:
void toggleCalibration(); void toggleCalibration();
void toggleRecording(); void toggleMarkerCollection();
void togglePreview(); void toggleRemoteCalibration();
void enableMarkerCollection(); void toggleRecording();
void disableMarkerCollection(); void toggleRemoteRecording();
void togglePreview();
void freezeCameraImages(); void freezeCameraImages();
void unfreezeCameraImages(); void unfreezeCameraImages();
private: private:
bool calibrating = false; int remoteCalibrationToggleKey = Qt::Key_PageDown;
int calibrationToggleKey = Qt::Key_PageDown; int calibrationToggleKey = Qt::Key_S;
int recordingToggleKey = Qt::Key_PageUp; int collectionToggleKey = Qt::Key_C;
int previewToggleKey = Qt::Key_B; int recordingToggleKey = Qt::Key_R;
int remoteRecordingToggleKey = Qt::Key_PageUp;
int previewToggleKey = Qt::Key_B;
}; };
#endif // COMMANDMANAGER_H #endif // COMMANDMANAGER_H
...@@ -347,7 +347,23 @@ void GazeEstimationWidget::keyReleaseEvent(QKeyEvent *event) ...@@ -347,7 +347,23 @@ void GazeEstimationWidget::keyReleaseEvent(QKeyEvent *event)
void GazeEstimationWidget::toggleCalibration() void GazeEstimationWidget::toggleCalibration()
{ {
ui->startFinishButton->click(); ui->startFinishButton->click();
//ui->startFinishButton->setChecked(!ui->startFinishButton->isChecked()); }
void GazeEstimationWidget::toggleRemoteCalibration()
{
ui->startFinishButton->click();
if ( ui->startFinishButton->isChecked() )
enableMarkerCollection();
else
disableMarkerCollection();
}
void GazeEstimationWidget::toggleMarkerCollection()
{
if (isMarkerCollectionEnabled)
disableMarkerCollection();
else
enableMarkerCollection();
} }
void GazeEstimationWidget::enableMarkerCollection() void GazeEstimationWidget::enableMarkerCollection()
...@@ -355,6 +371,7 @@ void GazeEstimationWidget::enableMarkerCollection() ...@@ -355,6 +371,7 @@ void GazeEstimationWidget::enableMarkerCollection()
if (isCollecting) { if (isCollecting) {
connect(this, SIGNAL(inDataTuple(DataTuple)), this, SLOT(collectMarkerTuple(DataTuple)) ); connect(this, SIGNAL(inDataTuple(DataTuple)), this, SLOT(collectMarkerTuple(DataTuple)) );
collectedSound.play(); collectedSound.play();
isMarkerCollectionEnabled = true;
} }
} }
...@@ -363,6 +380,7 @@ void GazeEstimationWidget::disableMarkerCollection() ...@@ -363,6 +380,7 @@ void GazeEstimationWidget::disableMarkerCollection()
disconnect(this, SIGNAL(inDataTuple(DataTuple)), this, SLOT(collectMarkerTuple(DataTuple)) ); disconnect(this, SIGNAL(inDataTuple(DataTuple)), this, SLOT(collectMarkerTuple(DataTuple)) );
if (isCollecting) if (isCollecting)
collectedSound.play(); collectedSound.play();
isMarkerCollectionEnabled = false;
} }
void GazeEstimationWidget::collectMarkerTuple(DataTuple dataTuple) void GazeEstimationWidget::collectMarkerTuple(DataTuple dataTuple)
......
...@@ -40,8 +40,8 @@ signals: ...@@ -40,8 +40,8 @@ signals:
public slots: public slots:
void toggleCalibration(); void toggleCalibration();
void enableMarkerCollection(); void toggleMarkerCollection();
void disableMarkerCollection(); void toggleRemoteCalibration();
void startRecording(); void startRecording();
void stopRecording(); void stopRecording();
...@@ -60,6 +60,7 @@ private: ...@@ -60,6 +60,7 @@ private:
bool lastStatus; bool lastStatus;
bool calibrationRequested; bool calibrationRequested;
bool isRecording; bool isRecording;
bool isMarkerCollectionEnabled = false;
QLabel *statusBarLabel; QLabel *statusBarLabel;
...@@ -72,6 +73,8 @@ private slots: ...@@ -72,6 +73,8 @@ private slots:
void finishSampling(); void finishSampling();
void collectMarkerTuple(DataTuple dataTuple); void collectMarkerTuple(DataTuple dataTuple);
void updateStatus(bool status, QString msg); void updateStatus(bool status, QString msg);
void enableMarkerCollection();
void disableMarkerCollection();
void on_saveTuples_clicked(); void on_saveTuples_clicked();
void on_loadTuples_clicked(); void on_loadTuples_clicked();
......
...@@ -138,15 +138,25 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -138,15 +138,25 @@ MainWindow::MainWindow(QWidget *parent) :
setupWidget(this, settings); setupWidget(this, settings);
// Commands /***************************************************************************
* Commands
**************************************************************************/
// Calibration
connect(&commandManager, SIGNAL(toggleCalibration()), connect(&commandManager, SIGNAL(toggleCalibration()),
gazeEstimationWidget, SLOT(toggleCalibration()) ); gazeEstimationWidget, SLOT(toggleCalibration()) );
connect(&commandManager, SIGNAL(enableMarkerCollection()), connect(&commandManager, SIGNAL(toggleMarkerCollection()),
gazeEstimationWidget, SLOT(enableMarkerCollection()) ); gazeEstimationWidget, SLOT(toggleMarkerCollection()) );
connect(&commandManager, SIGNAL(disableMarkerCollection()), connect(&commandManager, SIGNAL(toggleRemoteCalibration()),
gazeEstimationWidget, SLOT(disableMarkerCollection()) ); gazeEstimationWidget, SLOT(toggleRemoteCalibration()) );
// Recording
connect(&commandManager, SIGNAL(toggleRecording()), connect(&commandManager, SIGNAL(toggleRecording()),
this, SLOT(toggleRecording()) ); ui->recordingToggle, SLOT(click()) );
connect(&commandManager, SIGNAL(toggleRemoteRecording()),
this, SLOT(toggleRemoteRecording()) );
// Additionals
connect(&commandManager, SIGNAL(freezeCameraImages()), connect(&commandManager, SIGNAL(freezeCameraImages()),
this, SLOT(freezeCameraImages()) ); this, SLOT(freezeCameraImages()) );
connect(&commandManager, SIGNAL(unfreezeCameraImages()), connect(&commandManager, SIGNAL(unfreezeCameraImages()),
...@@ -372,7 +382,8 @@ void MainWindow::on_recordingToggle_clicked() ...@@ -372,7 +382,8 @@ void MainWindow::on_recordingToggle_clicked()
ui->recordingToggle->setChecked(false); ui->recordingToggle->setChecked(false);
return; return;
} }
qInfo() << "Record starting (Subject:" << ui->subject->text() << ")"; QMetaObject::invokeMethod(performanceMonitorWidget, "on_resetCounters_clicked");
qInfo() << "Record starting (Subject:" << ui->subject->text() << ")";
ui->changeSubjectButton->setEnabled(false); ui->changeSubjectButton->setEnabled(false);
ui->changePwdButton->setEnabled(false); ui->changePwdButton->setEnabled(false);
emit startRecording(); emit startRecording();
...@@ -396,7 +407,8 @@ void MainWindow::on_recordingToggle_clicked() ...@@ -396,7 +407,8 @@ void MainWindow::on_recordingToggle_clicked()
ui->changeSubjectButton->setEnabled(true); ui->changeSubjectButton->setEnabled(true);
ui->changePwdButton->setEnabled(true); ui->changePwdButton->setEnabled(true);
recStopSound.play(); recStopSound.play();
} gPerformanceMonitor.report();
}
} }
void MainWindow::effectiveRecordingStart() void MainWindow::effectiveRecordingStart()
{ {
...@@ -582,15 +594,11 @@ void MainWindow::setupWidget(ERWidget *widget, QSettings* settings, QPushButton ...@@ -582,15 +594,11 @@ void MainWindow::setupWidget(ERWidget *widget, QSettings* settings, QPushButton
} }
void MainWindow::toggleRecording() void MainWindow::toggleRemoteRecording()
{ {
if ( ! ui->recordingToggle->isChecked()) { // If the subject name is empty, use the remote label
if (ui->subject->text().isEmpty()) // Unset remote recording if ( !ui->recordingToggle->isChecked() && ui->subject->text().isEmpty() )
setSubjectName("remote"); setSubjectName("remote");
QMetaObject::invokeMethod(performanceMonitorWidget, "on_resetCounters_clicked");
} else {
gPerformanceMonitor.report();
}
ui->recordingToggle->click(); ui->recordingToggle->click();
} }
......
...@@ -124,7 +124,7 @@ private slots: ...@@ -124,7 +124,7 @@ private slots:
void on_log_clicked(); void on_log_clicked();
void on_performanceMonitor_clicked(); void on_performanceMonitor_clicked();
void toggleRecording(); void toggleRemoteRecording();
void freezeCameraImages(); void freezeCameraImages();
void unfreezeCameraImages(); void unfreezeCameraImages();
void togglePreview(); void togglePreview();
......
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