blob: 9deaee7d68b6e0a809337c5ceee96b4d82bd1513 (
plain)
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
|
#include "tool.h"
#include <QDrag>
#include "widgetwrapper.h"
#include "macrowindow.h"
#include "widget.h"
#include <QDomElement>
Tool::Tool(QDomNode node)
: QLabel()
{
this->node = node;
QDomElement elem = node.toElement();
if(elem.hasAttribute("name")) {
setText(elem.attribute("name"));
} else {
setText("Unknown");
}
show();
}
void Tool::mousePressEvent(QMouseEvent *event)
{
if(event->button() == Qt::LeftButton) {
QDrag *drag = new QDrag(this);
drag->setPixmap(QPixmap::grabWidget(this, 0, 0));
QMimeData *mimedata = new QMimeData();
mimedata->setData("pracro/widget", wrapWidget(new Widget(node)));
drag->setMimeData(mimedata);
drag->exec();
}
}
|