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
|
#include "button.h"
#include <stdio.h>
#include <QPushButton>
#include "common.h"
#include "macrowindow.h"
Button::Button(QDomNode &node, MacroWindow *macrowindow)
: Widget(node, macrowindow)
{
button = new QPushButton();
widget = button;
setCommonAttributes(button, node);
QDomElement elem = node.toElement();
button->setText(elem.attribute("caption", ""));
if(elem.hasAttribute("action")) {
if(elem.attribute("action") == "commit") {
connect(button, SIGNAL(clicked()), this, SLOT(commit()));
button->setIcon(QPixmap(":icons/add.png"));
button->setEnabled(false);
} else if(elem.attribute("action") == "cancel") {
connect(button, SIGNAL(clicked()), this, SLOT(cancel()));
button->setIcon(QPixmap(":icons/del.png"));
}
}
connect(this, SIGNAL(act_commit()), macrowindow, SLOT(commit()));
connect(this, SIGNAL(act_cancel()), macrowindow, SLOT(cancel()));
connect(macrowindow, SIGNAL(macroHasChanged()), this, SLOT(do_enable()));
}
Button::~Button()
{
}
void Button::commit()
{
emit act_commit();
printf("Emit: commit\n");
}
void Button::cancel()
{
emit act_cancel();
printf("Emit: cancel\n");
}
void Button::do_enable()
{
button->setEnabled(true);
}
|