feat: add FS25_FarmHUD mod and FarmHUD desktop companion app
Initial commit: the FS25 Lua mod (live.json data export), the FS25-WebDashboard project (Node/web dashboard + PySide6 desktop variant), and FarmHUD (standalone PySide6 companion app with Discord Rich Presence, settings, and installer).
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""A collapsed-by-default group at the very bottom of the HUD for the
|
||||
low-glance-value / technical data (session settings, savegame metadata,
|
||||
per-vehicle technical flags, ...) - keeps the main view focused on what's
|
||||
actually useful while the app + and toggle keeps everything accessible."""
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide6.QtCore import QSettings, Signal
|
||||
from PySide6.QtWidgets import QFrame, QHBoxLayout, QLabel, QPushButton, QVBoxLayout
|
||||
|
||||
from version import APP_NAME, APP_ORG
|
||||
from widgets.common import style_role
|
||||
|
||||
SETTINGS_KEY = "ui/technical_section_expanded"
|
||||
|
||||
|
||||
class CollapsibleGroup(QFrame):
|
||||
toggled = Signal(bool)
|
||||
|
||||
def __init__(self, title: str, parent=None) -> None:
|
||||
super().__init__(parent)
|
||||
self.setProperty("role", "tile")
|
||||
outer = QVBoxLayout(self)
|
||||
outer.setContentsMargins(14, 10, 14, 10)
|
||||
outer.setSpacing(8)
|
||||
|
||||
header = QHBoxLayout()
|
||||
title_label = QLabel(title)
|
||||
style_role(title_label, "section-title")
|
||||
header.addWidget(title_label)
|
||||
header.addStretch(1)
|
||||
self._settings = QSettings(APP_ORG, APP_NAME)
|
||||
self._expanded = self._settings.value(SETTINGS_KEY, False, type=bool)
|
||||
|
||||
self.toggle_btn = QPushButton()
|
||||
self.toggle_btn.setProperty("flat", "true")
|
||||
self.toggle_btn.clicked.connect(self._on_toggle)
|
||||
header.addWidget(self.toggle_btn)
|
||||
outer.addLayout(header)
|
||||
|
||||
self.body = QFrame()
|
||||
self.body_layout = QVBoxLayout(self.body)
|
||||
self.body_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.body_layout.setSpacing(8)
|
||||
outer.addWidget(self.body)
|
||||
|
||||
self._apply_state()
|
||||
|
||||
def _on_toggle(self) -> None:
|
||||
self._expanded = not self._expanded
|
||||
self._settings.setValue(SETTINGS_KEY, self._expanded)
|
||||
self._apply_state()
|
||||
self.toggled.emit(self._expanded)
|
||||
|
||||
def _apply_state(self) -> None:
|
||||
self.body.setVisible(self._expanded)
|
||||
self.toggle_btn.setText("▾ ausblenden" if self._expanded else "▸ mehr anzeigen")
|
||||
Reference in New Issue
Block a user