Skip to content
Permalink
Browse files

[processing] Pre-highlight model components on hover

  • Loading branch information
nyalldawson committed Mar 1, 2019
1 parent 93de4d1 commit 2178e1a71a9b6f1f9b22415ac45fd8ac3b309818
Showing with 14 additions and 0 deletions.
  1. +14 −0 python/plugins/processing/modeler/ModelerGraphicItem.py
@@ -56,6 +56,7 @@ def __init__(self, element, model, controls, scene=None):
self.model = model
self.scene = scene
self.element = element
self.hover_over_item = False
if isinstance(element, QgsProcessingModelParameter):
svg = QSvgRenderer(os.path.join(pluginPath, 'images', 'input.svg'))
self.picture = QPicture()
@@ -182,11 +183,22 @@ def hoverEnterEvent(self, event):
def hoverMoveEvent(self, event):
self.updateToolTip(event)

def hoverLeaveEvent(self, event):
self.setToolTip('')
if self.hover_over_item:
self.hover_over_item = False
self.update()

def updateToolTip(self, event):
prev_status = self.hover_over_item
if self.itemRect().contains(event.pos()):
self.setToolTip(self.text)
self.hover_over_item = True
else:
self.setToolTip('')
self.hover_over_item = False
if self.hover_over_item != prev_status:
self.update()

def contextMenuEvent(self, event):
if isinstance(self.element, QgsProcessingModelOutput):
@@ -328,6 +340,8 @@ def paint(self, painter, option, widget=None):
if self.isSelected():
stroke = selected
color = color.darker(110)
if self.hover_over_item:
color = color.darker(105)
painter.setPen(QPen(stroke, 0)) # 0 width "cosmetic" pen
painter.setBrush(QBrush(color, Qt.SolidPattern))
painter.drawRect(rect)

0 comments on commit 2178e1a

Please sign in to comment.
You can’t perform that action at this time.