-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreferences.cpp
More file actions
92 lines (76 loc) · 2.93 KB
/
preferences.cpp
File metadata and controls
92 lines (76 loc) · 2.93 KB
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
#include "preferences.h"
#include "ui_preferences.h"
#include "QAbstractButton"
#include "QFileDialog"
#include <QStandardPaths>
Preferences::Preferences(pref_t* pPref, QWidget *parent) :
QDialog(parent),
ui(new Ui::Preferences)
{
ui->setupUi(this);
if (pPref)
setPref(*pPref);
else {
m_pref.host = "googlearm.local";
m_pref.iPort = 8080;
m_pref.iBlockSize = 8;
m_pref.iSensorGain = 2;
m_pref.defaultSavePath = QDir::homePath() + "/Documents/GoogleArm/Data/";
m_pref.iRecordingLength = 60;
m_pref.serverPath = "/home/pi/EMGDataServer/";
m_pref.annotationMapJSONFilePath = QDir::homePath() + "/Documents/GoogleArm/annotation_map.json";
}
ui->le_host->setText(m_pref.host);
ui->le_port->setText(QString::number(m_pref.iPort));
ui->le_gain->setText(QString::number(m_pref.iSensorGain));
ui->le_blockSize->setText(QString::number(m_pref.iBlockSize));
ui->le_savePath->setText(m_pref.defaultSavePath);
ui->le_recordingLength->setText(QString::number(m_pref.iRecordingLength));
ui->le_serverPath->setText(m_pref.serverPath);
ui->annotationMapFilePath->setText(m_pref.annotationMapJSONFilePath);
}
Preferences::~Preferences() {
delete ui;
}
Preferences::pref_t& Preferences::getPref() {
return m_pref;
}
void Preferences::setPref(const pref_t& pref) {
m_pref = pref;
}
void Preferences::setBlockSize(uint16_t blockSize) {
m_pref.iBlockSize = blockSize;
}
void Preferences::setSensorGain(uint16_t sensorGain) {
m_pref.iSensorGain = sensorGain;
}
void Preferences::setDefaultSavePath(QString path) {
m_pref.defaultSavePath = path;
}
void Preferences::setRecordingLength(uint16_t recLength) {
m_pref.iRecordingLength = recLength;
}
void Preferences::on_buttonBox_clicked(QAbstractButton *button)
{
if (button->text() == "Cancel") {
return;
}
m_pref.host = ui->le_host->text();
m_pref.iPort = ui->le_port->text().toUInt();
m_pref.iSensorGain = ui->le_gain->text().toUInt();
m_pref.iBlockSize = ui->le_blockSize->text().toUInt();
m_pref.defaultSavePath = ui->le_savePath->text();
m_pref.iRecordingLength = ui->le_recordingLength->text().toUInt();
m_pref.serverPath = ui->le_serverPath->text();
m_pref.annotationMapJSONFilePath = ui->annotationMapFilePath->text();
}
void Preferences::on_btn_annotationMapFilePath_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose annotation_map"),
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation),
tr("Annotation Map (*.json)"));
if (fileName.isEmpty())
return;
m_pref.annotationMapJSONFilePath = fileName;
ui->annotationMapFilePath->setText(fileName);
}