-
Notifications
You must be signed in to change notification settings - Fork 10
/
initialsetup.cpp
172 lines (151 loc) · 4.04 KB
/
initialsetup.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include "initialsetup.h"
#include "ui_initialsetup.h"
initialSetup::initialSetup(QWidget *parent) :
QDialog(parent),
ui(new Ui::initialSetup)
{
ui->setupUi(this);
this->options = NULL;
}
initialSetup::~initialSetup()
{
delete ui;
}
void initialSetup::acceptOptions(startupOptionsType *opts)
{
this->options = opts;
// if(options->xioDirectory == NULL)
// {
// options->xioDirectory = new QString();
// }
if(options->heightWidthSet)
{
ui->heightSpin->blockSignals(true);
ui->widthSpin->blockSignals(true);
ui->heightSpin->setValue(options->xioHeight);
ui->widthSpin->setValue(options->xioWidth);
ui->heightSpin->blockSignals(false);
ui->widthSpin->blockSignals(false);
}
// if(options->xioDirectory == NULL)
// {
// abort(); // let's know if this happens.
// }
// if(!options->xioDirectory->isEmpty())
// {
// // ui->xioPathText->setText(*options->xioDirectory);
// }
if(options->xioDirectoryArray == NULL)
{
abort();
} else {
ui->xioPathText->setText(options->xioDirectoryArray);
// int c = 0;
// while((c<4096) && options->xioDirectoryArray[c])
}
ui->fpsSpin->setValue((double)options->targetFPS);
}
void initialSetup::setHeightWidthLock(bool locked)
{
this->lockHeightWidthControls = locked;
ui->heightSpin->setEnabled(!locked);
ui->widthSpin->setEnabled(!locked);
}
startupOptionsType *initialSetup::getOptions()
{
return options;
}
void initialSetup::on_selectButton_clicked()
{
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
"/mnt",
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if(dir.isEmpty())
{
return;
} else {
ui->xioPathText->setText(dir);
if(options->xioDirectoryArray == NULL)
{
abort();
} else {
if (dir.length() > 4096)
abort();
int n=0;
for(; n < dir.length(); n++)
{
options->xioDirectoryArray[n] = dir.toLocal8Bit().at(n);
}
}
}
}
void initialSetup::on_heightSpin_valueChanged(int arg1)
{
options->xioHeight = arg1;
}
void initialSetup::on_widthSpin_valueChanged(int arg1)
{
options->xioWidth = arg1;
}
void initialSetup::on_xioPathText_editingFinished()
{
// if(ui->xioPathText->text().isEmpty())
// {
// if(!options->xioDirectory->isEmpty())
// {
// ui->xioPathText->setText(*options->xioDirectory);
// } else {
// // not sure, we do not have a good default here...
// }
// return;
// } else {
// options->xioDirectory->clear();
// options->xioDirectory->append(ui->xioPathText->text());
// }
}
void initialSetup::on_xioPathText_returnPressed()
{
// if(options->xioDirectory == NULL)
// {
// abort();
// }
// if(ui->xioPathText->text().isEmpty())
// {
// return;
// } else {
// options->xioDirectory->clear();
// options->xioDirectory->append(ui->xioPathText->text());
// }
}
void initialSetup::on_buttonBox_rejected()
{
// TODO: Do not abort, since we can now bring this box up
// while the program is running.
//abort();
}
void initialSetup::on_buttonBox_accepted()
{
if((options->xioHeight !=0) && (options->xioWidth != 0))
options->heightWidthSet = true;
// if(options->xioDirectory == NULL)
// {
// abort();
// }
// if(options->xioDirectory->isEmpty())
// {
// abort();
// }
char c;
int n=0;
for(n=0; (n < ui->xioPathText->text().length()) and (n < 4094); n++)
{
c = ui->xioPathText->text().at(n).toLatin1();
options->xioDirectoryArray[n] = c;
}
options->xioDirectoryArray[n] = '\x00';
}
void initialSetup::on_fpsSpin_valueChanged(double arg1)
{
options->targetFPS = (float)arg1;
}