summaryrefslogtreecommitdiff
path: root/editor/tool.cc
diff options
context:
space:
mode:
Diffstat (limited to 'editor/tool.cc')
-rw-r--r--editor/tool.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/editor/tool.cc b/editor/tool.cc
index b9ed07d..c4686d2 100644
--- a/editor/tool.cc
+++ b/editor/tool.cc
@@ -32,12 +32,18 @@
#include "macrowindow.h"
#include "widget.h"
-Tool::Tool(QPixmap &pixmap, QString widget)
+#include <QDomElement>
+
+Tool::Tool(QDomNode &node)
: QLabel()
{
- setPixmap(pixmap);
- this->pixmap = pixmap;
- this->widget = widget;
+ this->node = node;
+ QDomElement elem = node.toElement();
+ if(elem.hasAttribute("name")) {
+ setText(elem.attribute("name"));
+ } else {
+ setText("Unknown");
+ }
show();
}
@@ -46,16 +52,12 @@ void Tool::mousePressEvent(QMouseEvent *event)
if(event->button() == Qt::LeftButton) {
QDrag *drag = new QDrag(this);
- drag->setPixmap(pixmap);
+ drag->setPixmap(QPixmap::grabWidget(this, 0, 0));
QMimeData *mimedata = new QMimeData();
- if(widget == "vertical") {
- mimedata->setData("pracro/widget", wrapWidget(new MacroWindow( Qt::Vertical)));
- } else if(widget == "horizontal") {
- mimedata->setData("pracro/widget", wrapWidget(new MacroWindow( Qt::Horizontal)));
- } else {
- mimedata->setData("pracro/widget", wrapWidget(new Widget(widget.toAscii())));
- }
+
+ mimedata->setData("pracro/widget", wrapWidget(new Widget(node)));
+
drag->setMimeData(mimedata);
drag->exec();