修复一些问题

This commit is contained in:
2025-09-29 11:26:29 +08:00
parent 943130b875
commit ed947743fc
8 changed files with 130 additions and 69 deletions

View File

@@ -10,20 +10,32 @@ from codes.common.signal_bus import signal_bus
class LunarClockLabel(QLabel):
def __init__(self, parent=None):
def __init__(self, parent=None, flag=0):
super().__init__(parent)
self.setMinimumWidth(350)
timer = QTimer(self)
timer.timeout.connect(self.update_time)
timer.start(1000)
self.update_time()
if flag == 0:
self.update_date()
timer.timeout.connect(self.update_date)
else:
self.update_time()
timer.timeout.connect(self.update_time)
def update_date(self):
dt = QDateTime.currentDateTime()
g = dt.date()
z = ZhDate.today()
week = "一二三四五六日"[g.dayOfWeek() - 1]
text = f"{g.year()}{g.month()}{g.day()}{z.chinese()[5:]} 星期{week}"
self.setText(text)
def update_time(self):
dt = QDateTime.currentDateTime()
g = dt.date()
z = ZhDate.today()
week = "一二三四五六日"[g.dayOfWeek() - 1]
text = f"{g.year()}{g.month()}{g.day()}{z.chinese()[5:]} 星期{week} {dt.toString('hh:mm:ss')}"
text = f"{dt.toString('hh:mm:ss')}"
self.setText(text)
@@ -54,6 +66,8 @@ class WidgetWithBg(QWidget):
self.lb_empty_up = QLabel(self)
layout_v.addWidget(self.lb_empty_up)
# 头像区
layout_h_1 = QHBoxLayout()
layout_h_1.addStretch(1)
self.lb_avatar = DoubleClickLabel(self)
self.lb_avatar.setAlignment(Qt.AlignmentFlag.AlignCenter)
avatar = QPixmap(clibs.avatar)
@@ -61,7 +75,15 @@ class WidgetWithBg(QWidget):
self.lb_avatar.setPixmap(avatar)
self.lb_avatar.setScaledContents(True)
self.lb_avatar.setFixedSize(144, 144)
layout_v.addWidget(self.lb_avatar, alignment=Qt.AlignmentFlag.AlignCenter)
layout_h_1.addWidget(self.lb_avatar)
self.lb_time = LunarClockLabel(self, flag=1)
self.lb_time.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.lb_time.setStyleSheet("color: rgba(255,255,255,255);")
self.lb_time.setFont(QFont("Arial Black", 56, QFont.Weight.Bold))
layout_h_1.addWidget(self.lb_time)
layout_h_1.addStretch(1)
layout_v.addLayout(layout_h_1)
# layout_v.addWidget(self.lb_avatar, alignment=Qt.AlignmentFlag.AlignCenter)
# 艺术字区
self.lb_name = QLabel(self)
self.lb_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
@@ -99,13 +121,13 @@ class WidgetWithBg(QWidget):
self.line_right.setLineWidth(1)
self.line_right.setFixedWidth(100)
# 时间区-时间
self.lb_time = LunarClockLabel(self)
self.lb_time.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.lb_time.setStyleSheet("color: rgba(255,255,255,255);")
self.lb_time.setFont(QFont("Consolas", 12, QFont.Weight.Bold))
self.lb_date = LunarClockLabel(self)
self.lb_date.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.lb_date.setStyleSheet("color: rgba(255,255,255,255);")
self.lb_date.setFont(QFont("Consolas", 12, QFont.Weight.Bold))
layout_h.addStretch(1)
layout_h.addWidget(self.line_left)
layout_h.addWidget(self.lb_time)
layout_h.addWidget(self.lb_date)
layout_h.addWidget(self.line_right)
layout_h.addStretch(1)
layout_v.addLayout(layout_h)
@@ -141,10 +163,6 @@ class WidgetWithBg(QWidget):
self.lb_avatar.doubleClicked.connect(self.toggle_auth_show)
self.le_password.returnPressed.connect(self.validate_password)
signal_bus.home_overlay_auth.connect(self.toggle_auth_show)
# self.sc_caL = QShortcut(QKeySequence("Esc"), self)
# self.sc_caL.activated.connect(self.toggle_auth_show)
# self.sc_caS = QShortcut(QKeySequence("Ctrl+Alt+M"), self)
# self.sc_caS.activated.connect(signal_bus.ho_full_screen.emit)
def toggle_auth_show(self):
if self.le_is_visible:
@@ -178,7 +196,7 @@ class WidgetWithBg(QWidget):
self.hide_le_password()
return False
else:
QMessageBox.critical(self, "错误", "密码不正确,请确认后重新输入!")
# QMessageBox.critical(self, "错误", "密码不正确,请确认后重新输入!")
self.show_le_password()
return False