Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit 33c7561

Browse files
committed
feat: 改进 UI 界面
1. 添加了标题栏和背景的渐变色。 2. 添加了 MyRoundButton 控件。 3. 调整了整体界面比例,更接近原版。 4. 增加了 PageLaunchLeft.py ,启动页左侧面板。 5. 添加了自制的图标。 6. 简化了 ModSetup 的逻辑过程。 7. 重命名了一些控件以与原版保持一致。
1 parent d5132a0 commit 33c7561

11 files changed

Lines changed: 62 additions & 24 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ Plain_Craft_Launcher_2/data/*.log
1414
# Debugging Files
1515
**/.minecraft/
1616
**/dist/*
17-
nuitka-crash-report.xml
17+
nuitka-crash-report.xml
18+
icon/

.idea/.name

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plain_Craft_Launcher_2/Controls/MyRoundButton.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class MyRoundButton(QPushButton):
1010
一个可以显示 SVG 图标的圆形按钮,支持悬停效果和点击效果
1111
"""
1212

13-
def __init__(self, parent=None, svg_path="", size=(64, 64), tooltip="",
13+
def __init__(self, parent=None, svg_path="", size=(36, 36), tooltip="",
1414
svg_size=None,
1515
border_width=1, border_color=QColor(255, 255, 255, 0),
1616
svg_color=QColor(255, 255, 255, 255),
@@ -21,7 +21,7 @@ def __init__(self, parent=None, svg_path="", size=(64, 64), tooltip="",
2121
Args:
2222
parent: 父控件
2323
svg_path: SVG 文件路径
24-
size: 按钮大小,默认为 (64, 64)
24+
size: 按钮大小,默认为 (36, 36)
2525
tooltip: 鼠标悬停提示文本
2626
svg_size: SVG 图标大小,默认与按钮大小相同
2727
border_width: 边框宽度,默认为 1
@@ -30,6 +30,10 @@ def __init__(self, parent=None, svg_path="", size=(64, 64), tooltip="",
3030
margin: SVG 图标外边距,格式为 (左, 上, 右, 下),默认为 (0, 0, 0, 0)
3131
padding: SVG 图标内边距,格式为 (左, 上, 右, 下),默认为 (0, 0, 0, 0)
3232
"""
33+
# 如果提供了svg_size,则按钮尺寸应该比svg尺寸大8px
34+
if svg_size is not None:
35+
size = (svg_size[0] + 8, svg_size[1] + 8)
36+
3337
super().__init__(parent)
3438

3539
# 设置按钮属性
@@ -58,7 +62,10 @@ def __init__(self, parent=None, svg_path="", size=(64, 64), tooltip="",
5862
self.svg_widget.load(svg_path)
5963

6064
# 设置 SVG 控件大小和位置
61-
self.svg_size = svg_size if svg_size is not None else size
65+
# 如果没有指定SVG大小,则默认为按钮大小减8px
66+
if svg_size is None:
67+
svg_size = (size[0] - 8, size[1] - 8)
68+
self.svg_size = svg_size
6269
self.margin = margin # 设置外边距 (左, 上, 右, 下)
6370
self.padding = padding # 设置内边距 (左, 上, 右, 下)
6471
self.centerSvg() # 居中 SVG 图标
@@ -256,7 +263,8 @@ def paintEvent(self, event):
256263
# 悬停状态 - 50% 透明度
257264
bg_color = QColor(255, 255, 255, 127)
258265
border_color = QColor(self.border_color)
259-
border_color.setAlpha(127)
266+
# border_color.setAlpha(127) 这里边框做成全透明更好看
267+
border_color.setAlpha(0)
260268
else:
261269
# 正常状态 - 完全透明
262270
bg_color = QColor(255, 255, 255, 0)

Plain_Craft_Launcher_2/FormMain.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ def resizeEvent(self, a0: QResizeEvent):
8888
# 更新容器大小
8989
self.container.setGeometry(9, 9, self.width() - 18, self.height() - 18)
9090

91-
# 更新面板大小
92-
self.ui.PanTitle.setGeometry(0, 0, self.container.width(), 40)
93-
self.ui.PanMain.setGeometry(0, 40, self.container.width(), self.container.height() - 40)
91+
# 更新面板大小,标题栏高度为窗口高度的10%
92+
title_height = int(self.container.height() * 0.1)
93+
self.ui.PanTitle.setGeometry(0, 0, self.container.width(), title_height)
94+
self.ui.PanMain.setGeometry(0, title_height, self.container.width(), self.container.height() - title_height)
9495

9596
def close_window(self):
9697
"""处理窗口关闭(对应的信号:BtnExit.clicked)"""

Plain_Craft_Launcher_2/FormMain_ui.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from Controls.MyRoundButton import MyRoundButton
1212
from Modules.Base.ModSetup import ModSetup as Setup
13+
from Pages.PageLaunch.PageLaunchLeft import PageLaunchLeft
1314

1415
class Ui_FormMain(object):
1516
def setupUi(self, FormMain: QtWidgets.QWidget):
@@ -30,11 +31,13 @@ def setupUi(self, FormMain: QtWidgets.QWidget):
3031

3132
# 标题栏 Panel
3233
self.PanTitle = QtWidgets.QFrame(FormMain)
33-
self.PanTitle.setGeometry(QtCore.QRect(0, 0, size[0], 40))
34-
self.PanTitle.setBaseSize(QtCore.QSize(size[0], 40))
34+
title_height = 48
35+
self.PanTitle.setGeometry(QtCore.QRect(0, 0, size[0], title_height))
36+
self.PanTitle.setBaseSize(QtCore.QSize(size[0], title_height))
3537
self.PanTitle.setStyleSheet(f"""
3638
QFrame#PanTitle {{
37-
background-color: {fg_color};
39+
background-color: qlineargradient(spread:pad, x1:0.99, y1:0.01, x2:0, y2:1,
40+
stop:0 {setup.get_settings('ColorBrush2')}, stop:1 {setup.get_settings('ColorBrush3')});
3841
border-top-left-radius: {corner_radius}px;
3942
border-top-right-radius: {corner_radius}px;
4043
border-bottom: none;
@@ -46,35 +49,36 @@ def setupUi(self, FormMain: QtWidgets.QWidget):
4649

4750
# 主 Panel
4851
self.PanMain = QtWidgets.QFrame(FormMain)
49-
self.PanMain.setGeometry(QtCore.QRect(0, 40, size[0], (size[1] - 40)))
52+
self.PanMain.setGeometry(QtCore.QRect(300, title_height, size[0], (size[1] - title_height)))
5053
self.PanMain.setStyleSheet(f"""
5154
QFrame#PanMain {{
52-
background-color: {bg_color};
55+
background-color: qlineargradient(spread:pad, x1:0.9, y1:0.1, x2:0, y2:1,
56+
stop:0 {setup.get_settings('ColorBrush5')}, stop:1 {setup.get_settings('ColorBrush6')});
5357
border-bottom-left-radius: {corner_radius}px;
5458
border-bottom-right-radius: {corner_radius}px;
55-
border-top: none;
5659
}}
5760
""")
5861
self.PanMain.setFrameShape(QtWidgets.QFrame.NoFrame)
5962
self.PanMain.setFrameShadow(QtWidgets.QFrame.Plain)
6063
self.PanMain.setObjectName("PanMain")
6164

65+
# 左侧 Panel
66+
self.PanLeft = PageLaunchLeft(FormMain)
67+
6268
# 标题栏按钮 -- 退出
63-
self.BtnExit = MyRoundButton(self.PanTitle, svg_path="Images/BtnTitleClose.svg", size=(28, 28), tooltip="Exit", padding=(6, 6, -10, -10))
64-
self.BtnExit.setGeometry(QtCore.QRect((size[0] - 60), 4, 28, 28))
69+
self.BtnExit = MyRoundButton(self.PanTitle, svg_path="Images/BtnTitleExit.svg", size=(36, 36), tooltip="Exit")
70+
self.BtnExit.setGeometry(QtCore.QRect((size[0] - 72), 8, 36, 36))
6571
self.BtnExit.setObjectName("BtnExit")
6672

6773
# 标题栏按钮 -- 最小化
68-
self.BtnMin = QtWidgets.QPushButton(self.PanTitle)
69-
self.BtnMin.setGeometry(QtCore.QRect((size[0] - 100), 0, 40, 40))
70-
self.BtnMin.setStyleSheet("background-color: transparent;")
71-
self.BtnMin.setText("—")
74+
self.BtnMin = MyRoundButton(self.PanTitle, svg_path="Images/BtnTitleMin.svg", size=(36, 36), tooltip="Minisize")
75+
self.BtnMin.setGeometry(QtCore.QRect((size[0] - 120), 8, 36, 36))
7276
self.BtnMin.setObjectName("BtnMin")
7377

7478
# 标题栏标签 -- 标题
7579
self.SVGTitle = QSvgWidget(self.PanTitle)
7680
self.SVGTitle.load("Images/svgtitle.svg")
77-
self.SVGTitle.setGeometry(QtCore.QRect(0, 4, 120, 40))
81+
self.SVGTitle.setGeometry(QtCore.QRect(8, 8, 120, 40)) # 缩小尺寸
7882
self.SVGTitle.setStyleSheet("background-color: transparent;")
7983
self.SVGTitle.setObjectName("SVGTitle")
8084

Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
16.5 KB
Loading
4.19 KB
Binary file not shown.

Plain_Craft_Launcher_2/Modules/Base/ModSetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def __init__(self):
2525

2626
def setup_settings(self):
2727
"""初始化设置项"""
28+
self.ColorBrush0 = "#ffffff"
2829
self.ColorBrush1 = "#343d4a"
2930
self.ColorBrush2 = "#0b5bcb"
3031
self.ColorBrush3 = "#1370f3"

0 commit comments

Comments
 (0)