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

Commit 8357c34

Browse files
committed
update 1.0.0.1.5600
Fix Some Bug
1 parent 59cbb1b commit 8357c34

20 files changed

+228
-167
lines changed

assets/old_utils/titlebar.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
from PyQt5.QtWidgets import QFrame, QHBoxLayout, QPushButton, QLabel, QDesktopWidget
2+
from PyQt5.QtGui import QIcon
3+
from PyQt5.QtCore import Qt, QSize, QPropertyAnimation, QEasingCurve, QRect, QPoint
4+
5+
class Clut_Bar(QFrame):
6+
def __init__(self, parent=None):
7+
super().__init__(parent)
8+
self.setFixedHeight(40)
9+
self.setStyleSheet("""
10+
QFrame {
11+
background-color: #202020;
12+
color: white;
13+
border-top-left-radius: 10px;
14+
border-top-right-radius: 10px;
15+
}
16+
QPushButton {
17+
border: none;
18+
background-color: transparent;
19+
color: white;
20+
padding: 5px;
21+
border-radius: 5px;
22+
}
23+
QPushButton:hover {
24+
background-color: #3a3a3a;
25+
}
26+
""")
27+
28+
# 初始化动画和状态
29+
self._is_maximized = False
30+
self._normal_geometry = None
31+
self.animation = QPropertyAnimation(self.window(), b"geometry")
32+
self.animation.setEasingCurve(QEasingCurve.OutCubic) # 使用更平滑的曲线
33+
self.animation.setDuration(100) # 增加动画持续时间以提高流畅性
34+
35+
# 获取屏幕尺寸
36+
self.screen = QDesktopWidget().availableGeometry()
37+
38+
layout = QHBoxLayout()
39+
layout.setContentsMargins(10, 0, 0, 0)
40+
self.title = QLabel("ClutUI | Ver0.0.1 | 感谢体验 | 测试框架 非软件")
41+
self.title.setStyleSheet("font-size: 14px; font-weight: bold;")
42+
layout.addWidget(self.title)
43+
44+
self.min_button = QPushButton()
45+
self.min_button.setIcon(QIcon("assets/icons/mini.png"))
46+
47+
self.max_button = QPushButton()
48+
self.max_button.setIcon(QIcon("assets/icons/max3.png"))
49+
50+
self.close_button = QPushButton()
51+
self.close_button.setIcon(QIcon("assets/icons/close2.png"))
52+
53+
for btn in [self.min_button, self.max_button, self.close_button]:
54+
btn.setFixedSize(QSize(40, 30))
55+
layout.addWidget(btn)
56+
57+
self.setLayout(layout)
58+
self.start_pos = None
59+
60+
self.min_button.clicked.connect(self.window().showMinimized)
61+
self.max_button.clicked.connect(self.toggle_maximize_animation)
62+
self.close_button.clicked.connect(self.window().close)
63+
64+
def toggle_maximize_animation(self):
65+
"""切换最大化状态的动画"""
66+
if self.animation.state() == QPropertyAnimation.Running:
67+
return
68+
69+
if not self._is_maximized:
70+
self._maximize_window()
71+
else:
72+
self._restore_window()
73+
74+
self.animation.start()
75+
76+
def _maximize_window(self):
77+
"""最大化窗口"""
78+
self._normal_geometry = self.window().geometry()
79+
self.animation.setStartValue(self._normal_geometry)
80+
self.animation.setEndValue(self.screen)
81+
self._is_maximized = True
82+
self.max_button.setIcon(QIcon("assets/icons/restore.png")) # 更改为还原图标
83+
84+
def _restore_window(self):
85+
"""还原窗口"""
86+
self.animation.setStartValue(self.window().geometry())
87+
self.animation.setEndValue(self._normal_geometry)
88+
self._is_maximized = False
89+
self.max_button.setIcon(QIcon("assets/icons/max3.png")) # 更改为最大化图标
90+
91+
def mousePressEvent(self, event):
92+
if event.button() == Qt.LeftButton:
93+
self.start_pos = event.globalPos() - self.window().frameGeometry().topLeft()
94+
event.accept()
95+
96+
def mouseMoveEvent(self, event):
97+
if event.buttons() == Qt.LeftButton and self.start_pos:
98+
if not self._is_maximized:
99+
self.window().move(event.globalPos() - self.start_pos)
100+
else:
101+
self._restore_and_move(event)
102+
event.accept()
103+
104+
def _restore_and_move(self, event):
105+
"""在最大化状态下还原并移动窗口"""
106+
self.toggle_maximize_animation()
107+
ratio = event.globalPos().x() / self.screen.width()
108+
new_x = int(self._normal_geometry.width() * ratio)
109+
self.start_pos = QPoint(new_x, event.pos().y())
110+
111+
def mouseReleaseEvent(self, event):
112+
self.start_pos = None
113+
114+
def mouseDoubleClickEvent(self, event):
115+
"""双击标题栏切换最大化状态"""
116+
if event.button() == Qt.LeftButton:
117+
self.toggle_maximize_animation()
4.89 KB
Binary file not shown.
5.88 KB
Binary file not shown.

assets/styles/sidebar.qss

Lines changed: 0 additions & 23 deletions
This file was deleted.

assets/styles/sidebar_expanded.qss

Lines changed: 0 additions & 23 deletions
This file was deleted.
8.83 KB
Binary file not shown.
5.77 KB
Binary file not shown.
14.1 KB
Binary file not shown.
6.8 KB
Binary file not shown.
13.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)