From f37bcf836bf573d6711aa5bbf6f0f8ffaaef3a8c Mon Sep 17 00:00:00 2001
From: KenanZhu <3471685733@qq.com>
Date: Mon, 16 Mar 2026 21:16:46 +0800
Subject: [PATCH] =?UTF-8?q?feat(TimerTaskAddDialog):=20=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BB=BB=E5=8A=A1=20UI=20=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- UI 添加重复配置控件:复选框、周一到周日复选框
- 新增 onRepeatCheckBoxToggled 槽函数控制日期选择显示
- getTimerTask 支持提取重复配置(日期、时分秒)
- 调用 TimerUtils 计算首次执行时间
- 重构导入语句格式
---
src/gui/ALTimerTaskAddDialog.py | 64 ++++-
src/gui/resources/ui/ALTimerTaskAddDialog.ui | 263 ++++++++++++++++++-
2 files changed, 308 insertions(+), 19 deletions(-)
diff --git a/src/gui/ALTimerTaskAddDialog.py b/src/gui/ALTimerTaskAddDialog.py
index 6c99bb8..4c73715 100644
--- a/src/gui/ALTimerTaskAddDialog.py
+++ b/src/gui/ALTimerTaskAddDialog.py
@@ -12,15 +12,11 @@ import uuid
from enum import Enum
from datetime import datetime, timedelta
-from PySide6.QtCore import (
- Slot, QDateTime
-)
-from PySide6.QtWidgets import (
- QLabel, QDialog, QWidget, QSpinBox,
- QHBoxLayout, QGridLayout, QDateTimeEdit
-)
+from PySide6.QtCore import Slot, QDateTime
+from PySide6.QtWidgets import QLabel, QDialog, QWidget, QSpinBox, QHBoxLayout, QGridLayout, QDateTimeEdit
from gui.resources.ui.Ui_ALTimerTaskAddDialog import Ui_ALTimerTaskAddDialog
+import utils.TimerUtils as TimerUtils
class ALTimerTaskStatus(Enum):
@@ -43,8 +39,8 @@ class ALTimerTaskAddDialog(QDialog, Ui_ALTimerTaskAddDialog):
super().__init__(parent)
self.setupUi(self)
- self.connectSignals()
self.modifyUi()
+ self.connectSignals()
def modifyUi(
@@ -97,6 +93,7 @@ class ALTimerTaskAddDialog(QDialog, Ui_ALTimerTaskAddDialog):
self.CancelButton.clicked.connect(self.reject)
self.ConfirmButton.clicked.connect(self.accept)
self.TimerTypeComboBox.currentIndexChanged.connect(self.onTimerTypeComboBoxIndexChanged)
+ self.RepeatCheckBox.toggled.connect(self.onRepeatCheckBoxToggled)
def getTimerTask(
@@ -121,7 +118,7 @@ class ALTimerTaskAddDialog(QDialog, Ui_ALTimerTaskAddDialog):
minutes = self.RelativeMinuteSpinBox.value(),
seconds = self.RelativeSecondSpinBox.value()
)
- return {
+ task_data = {
"name": name,
"task_uuid": uuid.uuid4().hex.upper() + f"-{added_time.strftime("%Y%m%d%H%M%S")}",
"time_type": self.TimerTypeComboBox.currentText(),
@@ -129,9 +126,40 @@ class ALTimerTaskAddDialog(QDialog, Ui_ALTimerTaskAddDialog):
"silent": silent,
"add_time": added_time,
"status": ALTimerTaskStatus.PENDING,
- "executed": False
+ "executed": False,
+ "repeat": self.RepeatCheckBox.isChecked(),
+ "repeat_records": []
}
+ if task_data["repeat"]:
+ repeat_days = []
+ if self.MonCheckBox.isChecked():
+ repeat_days.append(0)
+ if self.TueCheckBox.isChecked():
+ repeat_days.append(1)
+ if self.WedCheckBox.isChecked():
+ repeat_days.append(2)
+ if self.ThuCheckBox.isChecked():
+ repeat_days.append(3)
+ if self.FriCheckBox.isChecked():
+ repeat_days.append(4)
+ if self.SatCheckBox.isChecked():
+ repeat_days.append(5)
+ if self.SunCheckBox.isChecked():
+ repeat_days.append(6)
+ if not repeat_days:
+ repeat_days = [0, 1, 2, 3, 4, 5, 6]
+ task_data["repeat_days"] = repeat_days
+ task_data["repeat_hour"] = execute_time.hour
+ task_data["repeat_minute"] = execute_time.minute
+ task_data["repeat_second"] = execute_time.second
+ task_data["execute_time"] = TimerUtils.calculateNextRepeatTime(
+ task_data["repeat_days"],
+ task_data["repeat_hour"],
+ task_data["repeat_minute"],
+ task_data["repeat_second"]
+ )
+ return task_data
@Slot(int)
def onTimerTypeComboBoxIndexChanged(
@@ -140,4 +168,18 @@ class ALTimerTaskAddDialog(QDialog, Ui_ALTimerTaskAddDialog):
):
self.SpecificTimerWidget.setVisible(index == 0)
- self.RelativeTimerWidget.setVisible(index == 1)
\ No newline at end of file
+ self.RelativeTimerWidget.setVisible(index == 1)
+
+ @Slot(bool)
+ def onRepeatCheckBoxToggled(
+ self,
+ checked: bool
+ ):
+
+ self.MonCheckBox.setEnabled(checked)
+ self.TueCheckBox.setEnabled(checked)
+ self.WedCheckBox.setEnabled(checked)
+ self.ThuCheckBox.setEnabled(checked)
+ self.FriCheckBox.setEnabled(checked)
+ self.SatCheckBox.setEnabled(checked)
+ self.SunCheckBox.setEnabled(checked)
\ No newline at end of file
diff --git a/src/gui/resources/ui/ALTimerTaskAddDialog.ui b/src/gui/resources/ui/ALTimerTaskAddDialog.ui
index 63a06a4..1d3155f 100644
--- a/src/gui/resources/ui/ALTimerTaskAddDialog.ui
+++ b/src/gui/resources/ui/ALTimerTaskAddDialog.ui
@@ -6,20 +6,20 @@
0
0
- 300
- 300
+ 350
+ 400
- 0
- 300
+ 350
+ 400
- 500
- 300
+ 350
+ 500
@@ -149,8 +149,20 @@
5
- -
+
-
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
静默运行
@@ -168,13 +180,248 @@
- -
+
-
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
运行前提示
+ -
+
+
+ 重复运行
+
+
+
+ 5
+
+
+ 3
+
+
+ 3
+
+
+ 3
+
+
+ 3
+
+
-
+
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+ 启用重复执行
+
+
+
+ -
+
+
+
+ 0
+ 25
+
+
+
+
+ 16777215
+ 25
+
+
+
+ 重复周期(全选为每日运行):
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周四
+
+
+
+ -
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周三
+
+
+
+ -
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周一
+
+
+
+ -
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周二
+
+
+
+ -
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周五
+
+
+
+ -
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周六
+
+
+
+ -
+
+
+ false
+
+
+
+ 50
+ 25
+
+
+
+
+ 50
+ 25
+
+
+
+ 周日
+
+
+
+
+
+
+
+