Browse Source

minor optimizations, less self referencing

master
Christian Voigt 1 year ago
parent
commit
67875cc2c6
  1. 22
      sdtd_world/region_label.py

22
sdtd_world/region_label.py

@ -39,6 +39,9 @@ class RegionLabel(QLabel):
self.setScaledContents(True)
self.setMouseTracking(True)
def trigger_cursor_change(self):
self.parent_collection.trigger_cursor_change(self)
def clear_image(self):
self.image = None
@ -60,25 +63,18 @@ class RegionLabel(QLabel):
def update_graphics_effect(self):
effect = QGraphicsColorizeEffect()
effect_required = False
style_required = False
if self.is_marked:
style_required = True
style = "*{ border: 1px dotted #aaaaaa; }"
self.setStyleSheet(style)
else:
self.remove_style_effects()
if self.is_selected:
effect_required = True
effect.setColor(QColor(255, 255, 255, 16))
if effect_required:
self.setGraphicsEffect(effect)
else:
self.remove_graphics_effects()
if style_required:
self.setStyleSheet(style)
else:
self.remove_style_effects()
""" altering class functions """
def mousePressEvent(self, event):
modifiers = QApplication.keyboardModifiers()
@ -92,14 +88,14 @@ class RegionLabel(QLabel):
self.is_selected = True
self.update_graphics_effect()
self.parent_collection.set_currently_hovered_label(self)
self.parent_collection.trigger_cursor_change(self)
self.trigger_cursor_change()
super().enterEvent(event)
def leaveEvent(self, event) -> None:
self.is_selected = False
self.update_graphics_effect()
self.parent_collection.trigger_cursor_change(self)
self.trigger_cursor_change()
super().leaveEvent(event)

Loading…
Cancel
Save