fix: remove dynamic setStyleSheet calls to prevent parsing errors
- Remove dynamic color changes from _refresh_display - Use fixed colors set during widget creation - Just update text values in _refresh_display - Prevents 'Could not parse stylesheet' errors
This commit is contained in:
parent
63f215a3a1
commit
bd40d3d5e0
|
|
@ -787,36 +787,11 @@ class HUDOverlay(QWidget):
|
||||||
def _refresh_display(self):
|
def _refresh_display(self):
|
||||||
"""Refresh all display labels."""
|
"""Refresh all display labels."""
|
||||||
try:
|
try:
|
||||||
# Profit/Loss
|
# Profit/Loss - just update text, no dynamic stylesheet
|
||||||
if hasattr(self, 'profit_label') and self.profit_label is not None:
|
self._safe_set_text('profit_label', f"{self._stats.profit_loss:+.2f} PED")
|
||||||
try:
|
|
||||||
profit = self._stats.profit_loss
|
|
||||||
color = "#7FFF7F" if profit >= 0 else "#FF7F7F"
|
|
||||||
self.profit_label.setText(f"{profit:+.2f} PED")
|
|
||||||
try:
|
|
||||||
self.profit_label.setStyleSheet(f"font-size: 18px; font-weight: bold; color: {color};")
|
|
||||||
except Exception:
|
|
||||||
pass # Stylesheet error, ignore
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Return %
|
# Return %
|
||||||
if hasattr(self, 'return_label') and self.return_label is not None:
|
self._safe_set_text('return_label', f"{self._stats.return_percentage:.1f}%")
|
||||||
try:
|
|
||||||
ret = self._stats.return_percentage
|
|
||||||
if ret >= 100:
|
|
||||||
color = "#7FFF7F"
|
|
||||||
elif ret >= 90:
|
|
||||||
color = "#FFFF7F"
|
|
||||||
else:
|
|
||||||
color = "#FF7F7F"
|
|
||||||
self.return_label.setText(f"{ret:.1f}%")
|
|
||||||
try:
|
|
||||||
self.return_label.setStyleSheet(f"font-size: 16px; font-weight: bold; color: {color};")
|
|
||||||
except Exception:
|
|
||||||
pass # Stylesheet error, ignore
|
|
||||||
except RuntimeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Total Cost + Loot breakdown + Highest
|
# Total Cost + Loot breakdown + Highest
|
||||||
self._safe_set_text('total_cost_label', f"Cost: {self._stats.cost_total:.2f}")
|
self._safe_set_text('total_cost_label', f"Cost: {self._stats.cost_total:.2f}")
|
||||||
|
|
@ -854,6 +829,12 @@ class HUDOverlay(QWidget):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error in _refresh_display: {e}")
|
logger.error(f"Error in _refresh_display: {e}")
|
||||||
|
|
||||||
|
# Skills
|
||||||
|
if hasattr(self, 'skills_label'):
|
||||||
|
self._safe_set_text('skills_label', f"Skills: {self._stats.total_skill_gained:.2f}")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error in _refresh_display: {e}")
|
||||||
|
|
||||||
# === Public Update Methods ===
|
# === Public Update Methods ===
|
||||||
|
|
||||||
def update_loot(self, value_ped: Decimal, is_shrapnel: bool = False):
|
def update_loot(self, value_ped: Decimal, is_shrapnel: bool = False):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue