-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
RecordingDialog.cpp
74 lines (63 loc) · 1.47 KB
/
RecordingDialog.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
#include "RecordingDialog.h"
#include "ui_RecordingDialog.h"
#include "MySettings.h"
#include <QFileDialog>
RecordingDialog::RecordingDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::RecoringDialog)
{
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
ui->timeEdit->setTime(QTime(3, 0, 0));
{
MySettings s;
s.beginGroup("Global");
{
QString path = s.value("SaveVideoPath").toString();
ui->lineEdit_path->setText(path);
}
{
QString t = s.value("MaximumLength").toString();
int h, m, s;
h = m = s = 0;
if (sscanf(t.toStdString().c_str(), "%d:%d:%d", &h, &m, &s) != 3) {
h = 3;
m = s = 0;
}
ui->timeEdit->setTime({h, m, s});
}
s.endGroup();
}
}
RecordingDialog::~RecordingDialog()
{
delete ui;
}
QTime RecordingDialog::maximumLength() const
{
return ui->timeEdit->time();
}
QString RecordingDialog::path() const
{
return ui->lineEdit_path->text();
}
void RecordingDialog::on_pushButton_browse_clicked()
{
QString path = ui->lineEdit_path->text();
path = QFileDialog::getSaveFileName(this, tr("Save as"), path);
if (!path.isEmpty()) {
ui->lineEdit_path->setText(path);
}
}
void RecordingDialog::done(int v)
{
if (v == QDialog::Accepted) {
QTime t = ui->timeEdit->time();
MySettings s;
s.beginGroup("Global");
s.setValue("SaveVideoPath", path());
s.setValue("MaximumLength", QString::asprintf("%d:%02d:%02d", t.hour(), t.minute(), t.second()));
s.endGroup();
}
QDialog::done(v);
}