MainWindow.h 3.02 KB
Newer Older
Thiago Santini's avatar
Thiago Santini committed
1 2 3 4
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QCloseEvent>
5 6
#include <QDebug>
#include <QDesktopWidget>
Thiago Santini's avatar
Thiago Santini committed
7
#include <QDir>
8 9
#include <QDirIterator>
#include <QElapsedTimer>
Thiago Santini's avatar
Thiago Santini committed
10
#include <QFileDialog>
11 12
#include <QInputDialog>
#include <QMainWindow>
Thiago Santini's avatar
Thiago Santini committed
13
#include <QMessageBox>
14
#include <QRegExp>
Thiago Santini's avatar
Thiago Santini committed
15 16
#include <QTimer>

17 18
#include "ERWidget.h"

Thiago Santini's avatar
Thiago Santini committed
19
#include "AudioRecorder.h"
20
#include "CameraWidget.h"
Thiago Santini's avatar
Thiago Santini committed
21 22 23 24 25 26 27
#include "Synchronizer.h"

#include "GazeEstimationWidget.h"
#include "NetworkStream.h"

#include "Reference.h"

Thiago Santini's avatar
Thiago Santini committed
28
#include "LogWidget.h"
29
#include "PerformanceMonitorWidget.h"
Thiago Santini's avatar
Thiago Santini committed
30

31 32
#include "CommandManager.h"

Thiago Santini's avatar
Thiago Santini committed
33 34
#include "utils.h"

35
class MainWindowConfig {
Thiago Santini's avatar
Thiago Santini committed
36
public:
37 38 39 40
    MainWindowConfig()
        : workingDirectory("./")
    {
    }
Thiago Santini's avatar
Thiago Santini committed
41

42
    void save(QSettings* settings)
Thiago Santini's avatar
Thiago Santini committed
43 44
    {
        settings->sync();
45
        settings->setValue("workingDirectory", workingDirectory);
Thiago Santini's avatar
Thiago Santini committed
46 47
    }

48
    void load(QSettings* settings)
Thiago Santini's avatar
Thiago Santini committed
49 50 51
    {
        settings->sync();
        set(settings, "workingDirectory", workingDirectory);
52
    }
Thiago Santini's avatar
Thiago Santini committed
53

54
    QString workingDirectory;
Thiago Santini's avatar
Thiago Santini committed
55 56 57 58 59 60
};

namespace Ui {
class MainWindow;
}

61
class MainWindow : public ERWidget {
Thiago Santini's avatar
Thiago Santini committed
62 63 64
    Q_OBJECT

public:
65
    explicit MainWindow(QWidget* parent = 0);
Thiago Santini's avatar
Thiago Santini committed
66 67 68 69 70 71 72
    ~MainWindow();

signals:
    void startRecording();
    void stopRecording();

private:
73 74
    Ui::MainWindow* ui;
    QSettings* settings;
Thiago Santini's avatar
Thiago Santini committed
75 76
    MainWindowConfig cfg;

77 78 79 80 81 82 83 84 85 86 87 88
    CameraWidget* lEyeWidget;
    CameraWidget* rEyeWidget;
    CameraWidget* fieldWidget;
    AudioRecorder* audioRecorder;
    Synchronizer* synchronizer;
    GazeEstimationWidget* gazeEstimationWidget;
    QThread* journalThread;
    DataRecorderThread* journal;
    NetworkStream* networkStream;
    LogWidget* logWidget;
    PerformanceMonitorWidget* performanceMonitorWidget;
    CommandManager commandManager;
Thiago Santini's avatar
Thiago Santini committed
89 90 91 92 93

    QElapsedTimer elapsedTime;
    int elapsedTimeUpdateTimer;
    QString previousPwd;

Thiago Santini's avatar
Thiago Santini committed
94 95
    QSoundEffect recStartSound, recStopSound;

Thiago Santini's avatar
Thiago Santini committed
96 97 98
    bool setupSubjectDirectory();
    void setSubjectName(QString newSubjectName);
    void setWorkingDirectory(QString dir);
99 100 101
    void widgetButtonReact(QMainWindow* window, bool checked);
    void createExtraMenus();
    void setupWidget(ERWidget* widget, QSettings* settings, QPushButton* button = nullptr);
Thiago Santini's avatar
Thiago Santini committed
102

103
    const QString metaDataFile = "meta.tsv";
104
    const QString metaDateFormat = "yyyy-mm-dd HH:mm:ss.zzz";
105 106
    void storeMetaDataHead();
    void storeMetaDataTail();
Thiago Santini's avatar
Thiago Santini committed
107

Thiago Santini's avatar
Thiago Santini committed
108
protected:
109
    void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
Thiago Santini's avatar
Thiago Santini committed
110 111 112 113 114 115 116 117 118 119 120

private slots:
    void on_changePwdButton_clicked();
    void on_changeSubjectButton_clicked();
    void on_recordingToggle_clicked();
    void timerEvent(QTimerEvent* event);
    void on_leftEyeCam_clicked();
    void on_rightEyeCam_clicked();
    void on_fieldCam_clicked();
    void on_gazeEstimation_clicked();

121
    void effectiveRecordingStart();
Thiago Santini's avatar
Thiago Santini committed
122 123 124 125

    void menuOption(QAction*);
    void showReferencesDialog();
    void showAboutDialog();
Thiago Santini's avatar
Thiago Santini committed
126
    void on_log_clicked();
127
    void on_performanceMonitor_clicked();
128

129 130
    void toggleRemoteRecording();
    void freezeCameraImages();
131 132
    void unfreezeCameraImages();
    void togglePreview();
Thiago Santini's avatar
Thiago Santini committed
133 134 135
};

#endif // MAINWINDOW_H