MCPcopy Create free account
hub / github.com/MCSLTeam/MCSL2 / __init__

Method __init__

MCSL2Lib/ServerControllers/windowCreator.py:594–633  ·  view source on GitHub ↗
(self, parent)

Source from the content-addressed store, hash-verified

592
593class ServerWindowTitleBar(FluentTitleBar):
594 def __init__(self, parent):
595 super().__init__(parent)
596 self.setFixedHeight(40)
597 self.macOSLeftColumn = None # 保存macOS左侧列控件
598 self.hBoxLayout.removeWidget(self.minBtn)
599 self.hBoxLayout.removeWidget(self.maxBtn)
600 self.hBoxLayout.removeWidget(self.closeBtn)
601
602 # add window icon
603 self.placeholderLabel = QLabel(self)
604 self.placeholderLabel.setFixedSize(18, 18)
605 self.hBoxLayout.insertWidget(0, self.placeholderLabel, 0, Qt.AlignRight | Qt.AlignVCenter)
606
607 self.iconLabel = QLabel(self)
608 self.iconLabel.setFixedSize(18, 18)
609 self.hBoxLayout.insertWidget(1, self.iconLabel, 0, Qt.AlignLeft | Qt.AlignVCenter)
610 self.window().windowIconChanged.connect(self.setIcon)
611
612 # add title label
613 self.titleLabel = QLabel(self)
614 self.hBoxLayout.insertWidget(2, self.titleLabel, 0, Qt.AlignLeft | Qt.AlignVCenter)
615 self.titleLabel.setObjectName("titleLabel")
616 self.window().windowTitleChanged.connect(self.setTitle)
617
618 self.vBoxLayout = QVBoxLayout()
619 self.buttonLayout = QHBoxLayout()
620 self.buttonLayout.setSpacing(0)
621 self.buttonLayout.setContentsMargins(0, 0, 0, 0)
622 self.buttonLayout.setAlignment(Qt.AlignTop)
623 self.buttonLayout.addWidget(self.minBtn)
624 self.buttonLayout.addWidget(self.maxBtn)
625 self.buttonLayout.addWidget(self.closeBtn)
626 self.vBoxLayout.addLayout(self.buttonLayout)
627 self.vBoxLayout.addStretch(1)
628 self.hBoxLayout.addLayout(self.vBoxLayout, 0)
629 self.fixMacOSTitleBar()
630 self.setQss()
631
632 # 在window上安装事件过滤器以捕获全屏状态变化
633 self.window().installEventFilter(self)
634
635 def fixMacOSTitleBar(self):
636 """在macOS上为titleBar添加占位符"""

Callers

nothing calls this directly

Calls 4

fixMacOSTitleBarMethod · 0.95
setQssMethod · 0.95
__init__Method · 0.45
addWidgetMethod · 0.45

Tested by

no test coverage detected