X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fcolumnhandleitem.cpp;h=8ab7331b7ed05e99cc2bb96a40b6da6943ef3b25;hp=3b84f5783ef08e06cc99b75de2f3f25f5f89fc4e;hb=9806418efa4c59dae71fd628ea9c57453ca81434;hpb=206ce9444661cc7b2f65bdd8c8c0d1c365e6306f diff --git a/src/qtui/columnhandleitem.cpp b/src/qtui/columnhandleitem.cpp index 3b84f578..8ab7331b 100644 --- a/src/qtui/columnhandleitem.cpp +++ b/src/qtui/columnhandleitem.cpp @@ -20,17 +20,25 @@ #include #include +#include #include #include #include "columnhandleitem.h" -ColumnHandleItem::ColumnHandleItem(qreal w, QGraphicsItem *parent) : QGraphicsItem(parent) { - _width = w; +ColumnHandleItem::ColumnHandleItem(qreal w, QGraphicsItem *parent) + : QGraphicsItem(parent), + _width(w), + _hover(0), + _timeLine(150) +{ + setAcceptsHoverEvents(true); setZValue(10); setCursor(QCursor(Qt::OpenHandCursor)); setFlag(ItemIsMovable); + + connect(&_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(hoverChanged(qreal))); } void ColumnHandleItem::setXPos(qreal xpos) { @@ -43,7 +51,6 @@ void ColumnHandleItem::sceneRectChanged(const QRectF &rect) { } void ColumnHandleItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { - QGraphicsItem::mouseMoveEvent(event); } @@ -61,7 +68,31 @@ void ColumnHandleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * Q_UNUSED(option); Q_UNUSED(widget); - painter->drawRect(boundingRect()); + QLinearGradient gradient(0, 0, width(), 0); + gradient.setColorAt(0.25, Qt::transparent); + gradient.setColorAt(0.5, QColor(0, 0, 0, _hover * 200)); + gradient.setColorAt(0.75, Qt::transparent); + painter->fillRect(boundingRect(), gradient); +} +void ColumnHandleItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { + Q_UNUSED(event); + _timeLine.setDirection(QTimeLine::Forward); + if(_timeLine.state() != QTimeLine::Running) + _timeLine.start(); } + +void ColumnHandleItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { + Q_UNUSED(event); + + _timeLine.setDirection(QTimeLine::Backward); + if(_timeLine.state() != QTimeLine::Running) + _timeLine.start(); +} + +void ColumnHandleItem::hoverChanged(qreal value) { + _hover = value; + update(); +} +