summaryrefslogtreecommitdiff
path: root/editor/tool.cc
diff options
context:
space:
mode:
authordeva <deva>2008-07-11 12:54:42 +0000
committerdeva <deva>2008-07-11 12:54:42 +0000
commit5a19d9218a5f3ed7d02b7fabd8f025922e9f7a13 (patch)
tree49ee6645bf55e620db824d0c95508a65d4d596e7 /editor/tool.cc
parent12bd3e7ff088b097bf4e280161aee646fbbb50dc (diff)
Now we have a nice little editor.
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();