45 #include <QVBoxLayout> 50 #include <QMouseEvent> 52 #include "toolBoxElement.hh" 53 #include "parser/element.hh" 55 #define BACKGROUND_RED 0x00 56 #define BACKGROUND_GREEN 0x00 57 #define BACKGROUND_BLUE 0x00 58 #define BACKGROUND_ALPHA 0xff 74 QVBoxLayout *layout =
new QVBoxLayout ();
76 layout->setContentsMargins (2, 2, 2, 2);
80 label->setAlignment (Qt::AlignHCenter);
81 label->setWordWrap (
true);
83 QPalette p = label->palette ();
84 p.setBrush (QPalette::WindowText, Qt::white);
85 p.setBrush (QPalette::ButtonText, Qt::white);
86 label->setPalette (p);
88 layout->addWidget (label);
105 void ToolBoxElement::paintEvent(QPaintEvent * )
108 p.setRenderHint(QPainter::Antialiasing);
110 p.setBrush(QBrush(QColor(BACKGROUND_RED,
114 p.setPen(QColor(BACKGROUND_RED + 0x30,
115 BACKGROUND_GREEN + 0x30,
116 BACKGROUND_BLUE + 0x30,
118 p.drawRoundedRect(0, 0, width (), height (), 4, 4);
127 QMimeData *mimeData =
new QMimeData;
129 QPoint off = _event->pos() - QPoint (width () / 2, height () / 2);
131 QString data = QString::number (off.x ()) +
";";
132 data += QString::number (off.y ()) +
";" + element_->
name ();
135 mimeData->setData (
"application/x-openflipper.vsi",data.toLocal8Bit ());
137 QDrag *drag =
new QDrag(
this);
138 drag->setMimeData(mimeData);
140 QPixmap pixmap (size ());
141 pixmap.fill(Qt::transparent);
145 drag->setPixmap(pixmap);
146 drag->setHotSpot(_event->pos());
ToolBoxElement(Element *_element, QWidget *_parent=NULL)
Constructor.
QString name() const
Element name.
const QString & longDescription() const
Long description.
~ToolBoxElement()
Destructor.
const QString & shortDescription() const
Short description.
void mousePressEvent(QMouseEvent *_event)
Starts drag on mouse press.