Numbers on gravity scale
[ameter] / asettings.cpp
1 #include "asettings.h"
2
3 extern qreal g_n;
4 extern qreal a_max;
5 extern int smoothing;
6 extern int angle_step;
7 extern int divisions;
8 extern int data_rate;
9
10 SettingsDialog::SettingsDialog(QWidget *parent): QDialog(parent)
11 {
12         QHBoxLayout *hbox;
13         QVBoxLayout *vbox;
14
15         vbox = new QVBoxLayout();
16
17         hbox = new QHBoxLayout();
18         label = new QLabel(QString::fromUtf8("&g, m/s²"), this);
19         hbox->addWidget(label);
20         editG = new QLineEdit(this);
21         hbox->addWidget(editG);
22         editG->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
23         editG->setText(QString::number(g_n));
24         label->setBuddy(editG);
25         label = new QLabel(QString::fromUtf8("&Scale limit, g"), this);
26         hbox->addWidget(label);
27         editMax = new QLineEdit(this);
28         hbox->addWidget(editMax);
29         editMax->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
30         editMax->setText(QString::number(a_max));
31         label->setBuddy(editMax);
32         vbox->addLayout(hbox);
33         
34         hbox = new QHBoxLayout();
35         label = new QLabel(QString::fromUtf8("g scale &divisions"), this);
36         hbox->addWidget(label);
37         editDiv = new QLineEdit(this);
38         hbox->addWidget(editDiv);
39         editDiv->setInputMethodHints(Qt::ImhDigitsOnly);
40         editDiv->setText(QString::number(divisions));
41         label->setBuddy(editDiv);
42         vbox->addLayout(hbox);
43
44         hbox = new QHBoxLayout();
45         label = new QLabel(QString::fromUtf8("&Inclinometer scale division, °"), this);
46         hbox->addWidget(label);
47         editAngle = new QLineEdit(this);
48         hbox->addWidget(editAngle);
49         editAngle->setInputMethodHints(Qt::ImhDigitsOnly);
50         editAngle->setText(QString::number(angle_step));
51         label->setBuddy(editAngle);
52         vbox->addLayout(hbox);
53
54         hbox = new QHBoxLayout();
55         label = new QLabel(QString::fromUtf8("Data &rate, Hz"), this);
56         hbox->addWidget(label);
57         editRate = new QLineEdit(this);
58         hbox->addWidget(editRate);
59         editRate->setInputMethodHints(Qt::ImhDigitsOnly);
60         editRate->setText(QString::number(data_rate));
61         label->setBuddy(editRate);
62         label = new QLabel(QString::fromUtf8("&Smoothing"), this);
63         hbox->addWidget(label);
64         comboSmoothing = new QComboBox(this);
65         comboSmoothing->addItem("None");
66         comboSmoothing->addItem("Light");
67         comboSmoothing->addItem("Medium");
68         comboSmoothing->addItem("Strong");
69         comboSmoothing->setCurrentIndex(smoothing);
70         hbox->addWidget(comboSmoothing);
71         label->setBuddy(comboSmoothing);
72         vbox->addLayout(hbox);
73
74         buttonOk = new QPushButton("Ok");
75         vbox->addWidget(buttonOk);
76         connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
77
78         setLayout(vbox);
79
80         layout()->setSizeConstraint(QLayout::SetFixedSize);
81 }
82
83 SettingsDialog::~SettingsDialog()
84 {
85 }
86
87 void SettingsDialog::accept()
88 {
89         g_n = editG->text().toDouble();
90         a_max = editMax->text().toDouble();
91         smoothing = comboSmoothing->currentIndex();
92         divisions = editDiv->text().toInt();
93         angle_step = editAngle->text().toInt();
94         data_rate = editRate->text().toInt();
95         QDialog::accept();
96 }
97