forked from withrobot/oCam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolform_integer.cpp
72 lines (61 loc) · 1.79 KB
/
controlform_integer.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 "controlform_integer.h"
#include "ui_controlform_integer.h"
ControlFormInteger::ControlFormInteger(const char* name, int min, int max, int step, bool enable, QWidget *parent) :
QWidget(parent), ui(new Ui::ControlFormInteger), changed(false), step(step)
{
ui->setupUi(this);
ui->lblControlName->setText(tr(name));
ui->hsValue->setMinimum(min);
ui->hsValue->setMaximum(max);
ui->hsValue->setTickInterval(step);
ui->spnbxValue->setMinimum(min);
ui->spnbxValue->setMaximum(max);
ui->spnbxValue->setSingleStep(step);
ui->lblMin->setText(QString::number(min));
ui->lblMax->setText(QString::number(max));
set_enabled(enable);
}
ControlFormInteger::~ControlFormInteger()
{
delete ui;
}
bool ControlFormInteger::value_changed() {
return changed;
}
const char* ControlFormInteger::get_name()
{
//return ui->lblControlName->text().toStdString().c_str(); // fix the locale issue -20160801 gnohead
return ui->lblControlName->text().toLocal8Bit().constData();
}
int ControlFormInteger::get_value()
{
changed = false;
return ui->spnbxValue->value();
}
void ControlFormInteger::set_value(const int value)
{
ui->spnbxValue->setValue(value);
ui->hsValue->setValue(value);
}
void ControlFormInteger::on_hsValue_valueChanged(int value)
{
ui->spnbxValue->setValue(value);
changed = true;
}
void ControlFormInteger::on_spnbxValue_valueChanged(int arg1)
{
ui->hsValue->setValue(arg1);
changed = true;
}
void ControlFormInteger::set_enabled(bool flag)
{
ui->lblControlName->setEnabled(flag);
ui->hsValue->setEnabled(flag);
ui->spnbxValue->setEnabled(flag);
ui->lblMin->setEnabled(flag);
ui->lblMax->setEnabled(flag);
}
bool ControlFormInteger::is_enabled() const
{
return ui->lblControlName->isEnabled();
}