Skip to content

Commit

Permalink
修复悬赏封印重复调起自定义任务,优化日志模块动画
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaShue committed Nov 8, 2024
1 parent 7023a10 commit 1ec62fa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion assets
2 changes: 1 addition & 1 deletion src/custom_actions/task_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run(self, context: Context, argv: CustomAction.RunArg) -> bool:
print(f"执行任务: {task}")
context.run_pipeline(task)
print(f"任务 {task} 执行完成")
context.run_pipeline("返回庭院")
# context.run_pipeline("返回庭院")
time.sleep(2)
return True

Expand Down
47 changes: 40 additions & 7 deletions src/ui/containers/log_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ class LogContainer(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.expanded = False
# 初始化时完全收起
self.setFixedWidth(0)
self.setMinimumWidth(0)
self.setMaximumWidth(0)
self.setup_ui()

def setup_ui(self):
main_layout = QVBoxLayout(self)
main_layout.setSpacing(0)
main_layout.setContentsMargins(0, 0, 0, 0)

# 标题栏
title_frame = QFrame()
title_layout = QVBoxLayout(title_frame)
title_layout.setContentsMargins(10, 10, 10, 10)
Expand All @@ -24,17 +28,46 @@ def setup_ui(self):
title_layout.addWidget(self.title_label)
main_layout.addWidget(title_frame)

log_area = QTextEdit()
log_area.setPlaceholderText("日志输出...")
log_area.setReadOnly(True)
main_layout.addWidget(log_area)
# 日志区域
self.log_area = QTextEdit()
self.log_area.setPlaceholderText("日志输出...")
self.log_area.setReadOnly(True)
main_layout.addWidget(self.log_area)

# 初始状态隐藏所有子组件
self.title_label.hide()
self.log_area.hide()

def toggle_log_container(self):
# 设置目标宽度
target_width = 300 if not self.expanded else 0
self.width_anim = QPropertyAnimation(self, b"minimumWidth")

# 创建宽度动画
self.width_anim = QPropertyAnimation(self, b"maximumWidth")
self.width_anim.setDuration(300)
self.width_anim.setStartValue(self.minimumWidth())
self.width_anim.setStartValue(self.width())
self.width_anim.setEndValue(target_width)
self.width_anim.setEasingCurve(QEasingCurve.OutCubic)

# 同步最小宽度动画
self.min_width_anim = QPropertyAnimation(self, b"minimumWidth")
self.min_width_anim.setDuration(300)
self.min_width_anim.setStartValue(self.width())
self.min_width_anim.setEndValue(target_width)
self.min_width_anim.setEasingCurve(QEasingCurve.OutCubic)

# 切换展开状态
self.expanded = not self.expanded
self.width_anim.start()

# 根据展开状态显示/隐藏组件
if self.expanded:
self.title_label.show()
self.log_area.show()
else:
# 在动画结束时隐藏组件
self.width_anim.finished.connect(lambda: self.title_label.hide())
self.width_anim.finished.connect(lambda: self.log_area.hide())

# 启动动画
self.width_anim.start()
self.min_width_anim.start()
3 changes: 1 addition & 2 deletions src/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
self.controller = UIController()

self.setWindowTitle('MaaYYs')
self.setMinimumSize(1440, 720)
self.setMinimumSize(1280, 720)

# 加载样式
self.controller.load_styles(self)
Expand Down Expand Up @@ -209,7 +209,6 @@ def init_splitter(self):
layout = QVBoxLayout()
group.setLayout(layout)
details_container_splitter.addWidget(group)

# 设置大小比例
details_container_splitter.setSizes([500, 500])
details_container_splitter.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
Expand Down

0 comments on commit 1ec62fa

Please sign in to comment.