터치 패널 상태등 이벤트 홀드 적용
This commit is contained in:
1 parent
0075d5f38e
commit
6e3c809f22
2 files changed
+25
-7
No files matched your search
+24
-6
@@ -179,11 +179,17 @@ class StatusDot(QWidget):
|
||||
|
||||
|
||||
class StatusTile(QFrame):
|
||||
ACTIVITY_HOLD_SECONDS = 0.12
|
||||
ERROR_HOLD_SECONDS = 2.0
|
||||
|
||||
def __init__(self, title):
|
||||
super().__init__()
|
||||
self.read_dot = StatusDot("#16a34a")
|
||||
self.write_dot = StatusDot("#f97316")
|
||||
self.error_dot = StatusDot("#dc2626")
|
||||
self.last_read_at = 0.0
|
||||
self.last_write_at = 0.0
|
||||
self.last_error_at = 0.0
|
||||
self.title = QLabel(title)
|
||||
self.title.setObjectName("statusTitle")
|
||||
self.detail = QLabel("-")
|
||||
@@ -212,15 +218,23 @@ class StatusTile(QFrame):
|
||||
self.setObjectName("statusTile")
|
||||
|
||||
def set_state(self, detail, error=False, read_activity=False, write_activity=False):
|
||||
self.error_dot.set_steady(error)
|
||||
self.read_dot.set_steady(read_activity)
|
||||
self.write_dot.set_steady(write_activity)
|
||||
now = time.monotonic()
|
||||
if read_activity:
|
||||
self.last_read_at = now
|
||||
if write_activity:
|
||||
self.last_write_at = now
|
||||
if error:
|
||||
self.last_error_at = now
|
||||
self.update_dots(now)
|
||||
self.detail.setText(detail)
|
||||
|
||||
def tick(self):
|
||||
self.read_dot.tick()
|
||||
self.write_dot.tick()
|
||||
self.error_dot.tick()
|
||||
self.update_dots(time.monotonic())
|
||||
|
||||
def update_dots(self, now):
|
||||
self.read_dot.set_steady(now - self.last_read_at <= self.ACTIVITY_HOLD_SECONDS)
|
||||
self.write_dot.set_steady(now - self.last_write_at <= self.ACTIVITY_HOLD_SECONDS)
|
||||
self.error_dot.set_steady(now - self.last_error_at <= self.ERROR_HOLD_SECONDS)
|
||||
|
||||
|
||||
class PcWakeButton(StatusTile):
|
||||
@@ -277,6 +291,10 @@ class PcWakeButton(StatusTile):
|
||||
self.error_dot.set_steady(True)
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def tick(self):
|
||||
self.write_dot.tick()
|
||||
self.error_dot.tick()
|
||||
|
||||
|
||||
class MetricCard(QFrame):
|
||||
def __init__(self, title):
|
||||
|
||||
Reference in new issue
Block a user