-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyoGui.cpp
executable file
·144 lines (137 loc) · 4.59 KB
/
MyoGui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#include "MyoGui.h"
#include <QFileDialog>
MyoGui::MyoGui(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
startButton = ui.startButton;
connect(ui.startButton, SIGNAL(released()), this, SLOT (recordButtonHandler()));
//QPushButton *playButton = ui.playButton;
connect(ui.playButton,SIGNAL(released()),this, SLOT(playButtonHandler()));
QPushButton *stopButton = ui.stopButton;
connect(stopButton, SIGNAL(released()), this, SLOT(stopButtonHandler()));
//QPushButton *browseButton = ui.browseButton;
//connect(browseButton, SIGNAL(released()), this, SLOT(browseButtonHandler()));
QPushButton *pauseButton = ui.pauseButton;
connect(pauseButton, SIGNAL(released()), this, SLOT(pauseButtonHandler()));
//QPushButton *modeButton = ui.modeButton;
//connect(modeButton, SIGNAL(released()), this, SLOT(modeButtonHandler()));
QSlider *progressSlider = ui.progressSlider;
progressSlider->setMinimum(0);
connect(progressSlider, SIGNAL(sliderMoved(int)), this, SLOT(sliderValueChanged()));
connect(&ui.videowidget->player, SIGNAL(durationChanged(qint64)), this, SLOT(setSliderMaximum()));
connect(&ui.videowidget->player, SIGNAL(positionChanged(qint64)), this, SLOT(setSliderValue()));
mode = true;
playing = false;
ui.videowidget->hide();
}
void MyoGui::playButtonHandler(){
mode = false;
ui.glwidget->setMode(false);
ui.videowidget->show();
ui.camerawidget->hide();
QString fileName;
fileName = QFileDialog::getOpenFileName(this,"Open Video","/Users", tr("Video Files (*.mp4)"));
if(fileName!=NULL){
ui.pauseButton->setText("Pause");
playing = true;
ui.videowidget->setVideo(fileName);
fileName.replace(fileName.length()-4,4,".txt");
ui.glwidget->openRecordFile(fileName);
ui.glwidget->paint(true);
ui.glwidget->timerStart();
ui.videowidget->playVideo();
}
}
void MyoGui::modeButtonHandler(){
mode = !mode;
if(mode){
startButton->setText("Record");
ui.videowidget->hide();
ui.camerawidget->show();
ui.glwidget->setMode(true);
}
else{
startButton->setText("Play");
ui.videowidget->show();
ui.camerawidget->hide();
ui.glwidget->setMode(false);
}
}
void MyoGui::recordButtonHandler()
{
mode = true;
ui.glwidget->setMode(true);
ui.videowidget->hide();
ui.camerawidget->show();
QString file;
file = QFileDialog::getSaveFileName(this,"Open Record","/Users");
if(file!=NULL){
ui.glwidget->setRecordFile(file+".txt");
ui.camerawidget->setVideoName(file+".mp4");
ui.glwidget->paint(true);
ui.glwidget->timerStart();
ui.camerawidget->startRecord();
}
}
void MyoGui::stopButtonHandler()
{
ui.glwidget->paint(false);
ui.glwidget->timerStop();
if(!mode)
ui.videowidget->stopVideo();
else
ui.camerawidget->stopRecord();
}
void MyoGui::browseButtonHandler()
{
if(!mode){
ui.glwidget->openRecordFile(
QFileDialog::getOpenFileName(this,"Open Record","/Users", tr("Text Files (*.txt)"))
);
ui.videowidget->setVideo(
QFileDialog::getOpenFileName(this,"Open Video","/Users", tr("Video Files (*.mp4)"))
);
}
else{
QString file;
file = QFileDialog::getSaveFileName(this,"Open Record","/Users");
ui.glwidget->setRecordFile(file+".txt");
ui.camerawidget->setVideoName(file+".mp4");
}
}
void MyoGui::pauseButtonHandler()
{
if(mode){
ui.glwidget->timerStop();
ui.camerawidget->stopRecord();
}else{
if(playing){
ui.pauseButton->setText("Resume");
playing = false;
ui.glwidget->timerPause();
ui.videowidget->pauseVideo();
}else{
ui.pauseButton->setText("Pause");
playing = true;
ui.glwidget->timerStart();
ui.videowidget->playVideo();
}
}
}
void MyoGui::sliderValueChanged()
{
if(!mode&&ui.videowidget->player.isAvailable()){
ui.videowidget->setVideoPosition(ui.progressSlider->value());
ui.glwidget->setPosition((ui.progressSlider->value()));
}
}
void MyoGui::setSliderValue()
{
ui.progressSlider->setValue(ui.videowidget->player.position());
}
void MyoGui::setSliderMaximum()
{
ui.progressSlider->setMaximum(ui.videowidget->player.duration());
ui.glwidget->setGap((ui.videowidget->player.duration()));
}