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

Reorganizing commands

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