qss
This commit is contained in:
		@@ -7,6 +7,7 @@ from zhdate import ZhDate
 | 
			
		||||
 | 
			
		||||
from codes.common import clibs
 | 
			
		||||
from codes.common.signal_bus import signal_bus
 | 
			
		||||
from codes.common.qss_reloader import qss_reloader
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class LunarClockLabel(QLabel):
 | 
			
		||||
@@ -35,7 +36,7 @@ class LunarClockLabel(QLabel):
 | 
			
		||||
        g = dt.date()
 | 
			
		||||
        z = ZhDate.today()
 | 
			
		||||
        week = "一二三四五六日"[g.dayOfWeek() - 1]
 | 
			
		||||
        text = f"{dt.toString('hh:mm:ss')}"
 | 
			
		||||
        text = f"{dt.toString('hh:mm')}"
 | 
			
		||||
        self.setText(text)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -50,25 +51,28 @@ class DoubleClickLabel(QLabel):
 | 
			
		||||
class WidgetWithBg(QWidget):
 | 
			
		||||
    def __init__(self, parent=None):
 | 
			
		||||
        super().__init__(parent)
 | 
			
		||||
        self.predos()
 | 
			
		||||
        self.pre_do()
 | 
			
		||||
        self.init_ui()
 | 
			
		||||
        self.setup_slot()
 | 
			
		||||
        self.post_do()
 | 
			
		||||
 | 
			
		||||
    def predos(self):
 | 
			
		||||
    def pre_do(self):
 | 
			
		||||
        font_id = QFontDatabase.addApplicationFont(f"{clibs.base_path}/assets/media/font/OldEnglishTextMT/OldEnglishTextMT.ttf")
 | 
			
		||||
        family = QFontDatabase.applicationFontFamilies(font_id)[0]
 | 
			
		||||
        self.lb_font = QFont(family, 28, QFont.Weight.Medium)
 | 
			
		||||
        self.lb_font = QFont(family, 32, QFont.Weight.Medium)
 | 
			
		||||
        self.background_pixmap = QPixmap(clibs.bg)
 | 
			
		||||
 | 
			
		||||
    def init_ui(self):
 | 
			
		||||
        self.setObjectName("WidgetWithBg")
 | 
			
		||||
        layout_v = QVBoxLayout()
 | 
			
		||||
        # 最上层的空白区
 | 
			
		||||
        self.lb_empty_up = QLabel(self)
 | 
			
		||||
        self.lb_empty_up.setObjectName("lb_empty_up")
 | 
			
		||||
        layout_v.addWidget(self.lb_empty_up)
 | 
			
		||||
        # 头像区
 | 
			
		||||
        layout_h_1 = QHBoxLayout()
 | 
			
		||||
        layout_h_1.addStretch(1)
 | 
			
		||||
        self.lb_avatar = DoubleClickLabel(self)
 | 
			
		||||
        self.lb_avatar.setObjectName("lb_avatar")
 | 
			
		||||
        self.lb_avatar.setAlignment(Qt.AlignmentFlag.AlignCenter)
 | 
			
		||||
        avatar = QPixmap(clibs.avatar)
 | 
			
		||||
        avatar = self.circle_pixmap(avatar, 200)
 | 
			
		||||
@@ -77,54 +81,41 @@ class WidgetWithBg(QWidget):
 | 
			
		||||
        self.lb_avatar.setFixedSize(144, 144)
 | 
			
		||||
        layout_h_1.addWidget(self.lb_avatar)
 | 
			
		||||
        self.lb_time = LunarClockLabel(self, flag=1)
 | 
			
		||||
        self.lb_time.setObjectName("lb_time")
 | 
			
		||||
        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.setObjectName("lb_name")
 | 
			
		||||
        self.lb_name.setAlignment(Qt.AlignmentFlag.AlignCenter)
 | 
			
		||||
        self.lb_name.setText("Manford Fan · Code Create Life")
 | 
			
		||||
        self.lb_name.setStyleSheet("color: rgba(255,255,255,255);")
 | 
			
		||||
        self.lb_name.setFont(self.lb_font)
 | 
			
		||||
        layout_v.addWidget(self.lb_name)
 | 
			
		||||
        # 时间区-左横线
 | 
			
		||||
        layout_h = QHBoxLayout()
 | 
			
		||||
        self.line_left = QFrame(self)
 | 
			
		||||
        self.line_left.setObjectName("line_left")
 | 
			
		||||
        self.line_left.setFrameShape(QFrame.Shape.HLine)
 | 
			
		||||
        self.line_left.setFrameShadow(QFrame.Shadow.Plain)
 | 
			
		||||
        self.line_left.setStyleSheet("""
 | 
			
		||||
            QFrame {
 | 
			
		||||
                border: none;
 | 
			
		||||
                background-color: rgba(255, 255, 255, 40);
 | 
			
		||||
            }
 | 
			
		||||
        """)
 | 
			
		||||
        policy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
 | 
			
		||||
        self.line_left.setSizePolicy(policy)
 | 
			
		||||
        self.line_left.setLineWidth(1)
 | 
			
		||||
        self.line_left.setFixedWidth(100)
 | 
			
		||||
        # 时间区-右横线
 | 
			
		||||
        self.line_right = QFrame(self)
 | 
			
		||||
        self.line_right.setObjectName("line_right")
 | 
			
		||||
        self.line_right.setFrameShape(QFrame.Shape.HLine)
 | 
			
		||||
        self.line_right.setFrameShadow(QFrame.Shadow.Plain)
 | 
			
		||||
        self.line_right.setStyleSheet("""
 | 
			
		||||
            QFrame {
 | 
			
		||||
                border: none;
 | 
			
		||||
                background-color: rgba(255, 255, 255, 40);
 | 
			
		||||
            }
 | 
			
		||||
        """)
 | 
			
		||||
        policy = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Fixed)
 | 
			
		||||
        self.line_right.setSizePolicy(policy)
 | 
			
		||||
        self.line_right.setLineWidth(1)
 | 
			
		||||
        self.line_right.setFixedWidth(100)
 | 
			
		||||
        # 时间区-时间
 | 
			
		||||
        self.lb_date = LunarClockLabel(self)
 | 
			
		||||
        self.lb_date.setObjectName("lb_date")
 | 
			
		||||
        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_date)
 | 
			
		||||
@@ -133,21 +124,22 @@ class WidgetWithBg(QWidget):
 | 
			
		||||
        layout_v.addLayout(layout_h)
 | 
			
		||||
 | 
			
		||||
        self.lb_proverb = QLabel(self)
 | 
			
		||||
        self.lb_proverb.setObjectName("lb_proverb")
 | 
			
		||||
        self.lb_proverb.setAlignment(Qt.AlignmentFlag.AlignCenter)
 | 
			
		||||
        self.lb_proverb.setText(clibs.proverb)
 | 
			
		||||
        self.lb_proverb.setStyleSheet("color: rgba(255,255,255,255);")
 | 
			
		||||
        self.lb_proverb.setFont(QFont("Consolas", 14, QFont.Weight.Bold))
 | 
			
		||||
        layout_v.addWidget(self.lb_proverb)
 | 
			
		||||
 | 
			
		||||
        self.le_password = QLineEdit(self)
 | 
			
		||||
        self.le_password.setObjectName("le_password")
 | 
			
		||||
        self.le_password.setEchoMode(QLineEdit.EchoMode.Password)
 | 
			
		||||
        self.le_password.setFont(QFont("Consolas", 12, QFont.Weight.Normal))
 | 
			
		||||
        # self.le_password.setFont(QFont("Consolas", 12, QFont.Weight.Normal))
 | 
			
		||||
        self.le_password.setMinimumWidth(300)
 | 
			
		||||
        self.le_password.setFixedHeight(30)
 | 
			
		||||
        layout_v.addWidget(self.le_password, alignment=Qt.AlignmentFlag.AlignCenter)
 | 
			
		||||
        self.hide_le_password()
 | 
			
		||||
 | 
			
		||||
        self.lb_empty_down = QLabel(self)
 | 
			
		||||
        self.lb_empty_down.setObjectName("lb_empty_down")
 | 
			
		||||
        layout_v.addWidget(self.lb_empty_down)
 | 
			
		||||
 | 
			
		||||
        layout_v.setStretch(0, 2)  # empty up
 | 
			
		||||
@@ -159,6 +151,10 @@ class WidgetWithBg(QWidget):
 | 
			
		||||
        layout_v.setStretch(6, 2)  # empty down
 | 
			
		||||
        self.setLayout(layout_v)
 | 
			
		||||
 | 
			
		||||
    def post_do(self):
 | 
			
		||||
        qss_reloader.register(clibs.qss_home_overlay, self)
 | 
			
		||||
        self.setup_slot()
 | 
			
		||||
 | 
			
		||||
    def setup_slot(self):
 | 
			
		||||
        self.lb_avatar.doubleClicked.connect(self.toggle_auth_show)
 | 
			
		||||
        self.le_password.returnPressed.connect(self.validate_password)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user