diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-08-07 20:53:37 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-08-07 20:53:37 -0400 |
commit | 1dce60bb270caaf75165ef274b9503e2b0d80eb4 (patch) | |
tree | ab1a68a01f31390ed2778bc08d2854c829e3e70d | |
parent | b355ed0b80f5da02024824d73d0e985a560ecbb2 (diff) | |
download | sigen-1dce60bb270caaf75165ef274b9503e2b0d80eb4.tar.gz sigen-1dce60bb270caaf75165ef274b9503e2b0d80eb4.tar.xz sigen-1dce60bb270caaf75165ef274b9503e2b0d80eb4.zip |
Add focus handling to world map items
-rw-r--r-- | sigmodr/widgets/mapeditor/WorldMapItem.cpp | 17 | ||||
-rw-r--r-- | sigmodr/widgets/mapeditor/WorldMapItem.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/sigmodr/widgets/mapeditor/WorldMapItem.cpp b/sigmodr/widgets/mapeditor/WorldMapItem.cpp index 6dceaed3..e614d2b2 100644 --- a/sigmodr/widgets/mapeditor/WorldMapItem.cpp +++ b/sigmodr/widgets/mapeditor/WorldMapItem.cpp @@ -80,6 +80,11 @@ void WorldMapItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* opti painter->setPen(QPen(m_locked ? Qt::red : Qt::black, 2)); painter->drawRect(QRect(0, 0, m_map->width(), m_map->height())); painter->setBrush(QBrush(Qt::yellow)); + if (option->state & QStyle::State_HasFocus) + { + painter->setPen(QPen(KStatefulBrush(KColorScheme::View, KColorScheme::FocusColor).brush(QPalette::Active), 3)); + painter->drawRect(boundingRect()); + } if (option->state & QStyle::State_MouseOver) { painter->setPen(QPen(KStatefulBrush(KColorScheme::View, KColorScheme::HoverColor).brush(QPalette::Active), 3)); @@ -108,6 +113,18 @@ bool WorldMapItem::isLocked() const return m_locked; } +void WorldMapItem::focusInEvent(QFocusEvent* event) +{ + QGraphicsItem::focusInEvent(event); + update(); +} + +void WorldMapItem::focusOutEvent(QFocusEvent* event) +{ + QGraphicsItem::focusOutEvent(event); + update(); +} + void WorldMapItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { m_label->show(); diff --git a/sigmodr/widgets/mapeditor/WorldMapItem.h b/sigmodr/widgets/mapeditor/WorldMapItem.h index 38e70098..d8334b09 100644 --- a/sigmodr/widgets/mapeditor/WorldMapItem.h +++ b/sigmodr/widgets/mapeditor/WorldMapItem.h @@ -66,6 +66,8 @@ class SIGMODRWIDGETS_NO_EXPORT WorldMapItem : public QObject, public QGraphicsIt void maskTiles(const bool mask); protected: + void focusInEvent(QFocusEvent* event); + void focusOutEvent(QFocusEvent* event); void hoverEnterEvent(QGraphicsSceneHoverEvent* event); void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event); |