forked from withrobot/oCam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrolform_boolean.cpp
64 lines (53 loc) · 1.38 KB
/
controlform_boolean.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
#include "controlform_boolean.h"
#include "ui_controlform_boolean.h"
ControlFormBoolean::ControlFormBoolean(const char* name, bool enable, QWidget *parent) :
QWidget(parent), ui(new Ui::ControlFormBoolean), changed(false)
{
ui->setupUi(this);
ui->lblControlName->setText(tr(name));
set_enabled(enable);
}
ControlFormBoolean::~ControlFormBoolean()
{
delete ui;
}
const char* ControlFormBoolean::get_name()
{
//return ui->lblControlName->text().toStdString().c_str();
return ui->lblControlName->text().toLocal8Bit().constData();
}
int ControlFormBoolean::get_value()
{
changed = false;
return (int)ui->rbEnable->isChecked();
}
void ControlFormBoolean::set_value(const int value)
{
changed = true;
ui->rbEnable->setChecked((bool)value);
ui->rbDisable->setChecked(!(bool)value);
}
bool ControlFormBoolean::value_changed()
{
return changed;
}
void ControlFormBoolean::on_rbDisable_toggled(bool checked)
{
ui->rbEnable->setChecked(!checked);
changed = true;
}
void ControlFormBoolean::on_rbEnable_toggled(bool checked)
{
ui->rbDisable->setChecked(!checked);
changed = true;
}
void ControlFormBoolean::set_enabled(bool flag)
{
ui->lblControlName->setEnabled(flag);
ui->rbDisable->setEnabled(flag);
ui->rbEnable->setEnabled(flag);
}
bool ControlFormBoolean::is_enabled() const
{
return ui->lblControlName->isEnabled();
}