update server
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
# status_bar.py
|
||||
"""底部状态栏组件:日志 + 连接状态"""
|
||||
|
||||
import time
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
|
||||
class StatusBar(QWidget):
|
||||
"""底部状态栏 —— 左侧日志,右侧连接状态"""
|
||||
|
||||
def __init__(self, colors: dict, parent=None):
|
||||
super().__init__(parent)
|
||||
self.colors = colors
|
||||
self.setProperty("cssClass", "bottomBar")
|
||||
|
||||
layout = QHBoxLayout(self)
|
||||
layout.setContentsMargins(12, 6, 12, 6)
|
||||
|
||||
# ---- 左侧:日志 ----
|
||||
self.log_label = QLabel("就绪")
|
||||
self.log_label.setProperty("cssClass", "logLabel")
|
||||
self.log_label.setMinimumHeight(24)
|
||||
layout.addWidget(self.log_label, stretch=3)
|
||||
|
||||
# ---- 右侧:连接状态(● 未连接 / ● 已连接) ----
|
||||
self.status_label = QLabel("● 未连接")
|
||||
self.status_label.setProperty("cssClass", "statusLabel")
|
||||
self.status_label.setStyleSheet(
|
||||
f"color: {colors.get('ERROR_RED', '#FF2424')}; font-weight: bold; font-size: 14px;"
|
||||
)
|
||||
layout.addWidget(self.status_label, stretch=1, alignment=Qt.AlignRight | Qt.AlignVCenter)
|
||||
|
||||
# ---- 公开接口 ----
|
||||
def set_log(self, message: str):
|
||||
"""设置日志消息(仅显示最新一条)"""
|
||||
self.log_label.setText(f"{time.strftime('%H:%M:%S')} - {message}")
|
||||
|
||||
def set_connection_status(self, connected: bool, status_text: str = None):
|
||||
"""设置连接状态显示"""
|
||||
if status_text is None:
|
||||
status_text = "● 已连接" if connected else "● 未连接"
|
||||
color = self.colors.get("SUCCESS_GREEN", "#0F955D") if connected else self.colors.get("ERROR_RED", "#FF2424")
|
||||
self.status_label.setText(status_text)
|
||||
self.status_label.setStyleSheet(
|
||||
f"color: {color}; font-weight: bold; font-size: 14px;"
|
||||
)
|
||||
Reference in New Issue
Block a user