1
1
mirror of https://github.com/KenanZhu/AutoLibrary.git synced 2026-06-18 07:23:03 +08:00

Compare commits

...

2 Commits

Author SHA1 Message Date
KenanZhu c67a7e3773 fix(gui.ALConfigWidget): allow earlier selection of next day and fix dialog title on config load
previous time that you can select the next day is 19:00, this may be
tensive, because the time rested to modify the reserve date is limited.
So in current commit, we change this into 18:00.
2025-11-06 20:07:43 +08:00
KenanZhu bdc700d3da fix(ALConfigWidget): prevent config load from overriding unsaved UI changes
The previous implementation directly replaced the current
in-memory state of system and user configurations during
file loading. This behavior did not align with user
expectations, as it could discard unsaved changes made in the UI.

The fix ensures that loading a configuration file only
updates the internal in-memory state of system and user
configurations, preserving any unsaved UI modifications.
2025-11-06 19:55:54 +08:00
3 changed files with 54 additions and 9 deletions
+8 -8
View File
@@ -268,7 +268,7 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget):
self.DateEdit.setDate(QDate.currentDate())
self.DateEdit.setMinimumDate(QDate.currentDate())
self.DateEdit.setMaximumDate(QDate.currentDate())
if QTime.currentTime() > QTime(19, 0, 0) and QTime.currentTime() < QTime(23, 0, 0):
if QTime.currentTime() > QTime(18, 0, 0) and QTime.currentTime() < QTime(23, 0, 0):
self.DateEdit.setMaximumDate(QDate.currentDate().addDays(1))
self.BeginTimeEdit.setTime(QTime.currentTime())
self.PreferEarlyBeginTimeCheckBox.setChecked(False)
@@ -479,7 +479,7 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget):
if not config_path:
config_path = QFileDialog.getOpenFileName(
self,
"选择配置文件 - AutoLibrary",
"从现有配置文件中加载 - AutoLibrary",
f"{QDir.toNativeSeparators(QDir.currentPath())}",
"JSON 文件 (*.json);;所有文件 (*)"
)[0]
@@ -489,16 +489,12 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget):
system_config = self.loadSystemConfig(config_path)
users_config = self.loadUsersConfig(config_path)
if system_config is not None:
self.__config_paths["system"] = config_path
self.__system_config_data.update(system_config)
self.setSystemConfigToWidget(self.__system_config_data)
self.CurrentSystemConfigEdit.setText(config_path)
return True
if users_config is not None:
self.__config_paths["users"] = config_path
self.__users_config_data.update(users_config)
self.fillUsersList(self.__users_config_data)
self.CurrentUserConfigEdit.setText(config_path)
return True
except:
return False
@@ -644,7 +640,9 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget):
)[0]
if system_config_path:
system_config_path = QDir.toNativeSeparators(system_config_path)
self.loadConfig(system_config_path)
if self.loadConfig(system_config_path):
self.__config_paths["system"] = system_config_path
self.CurrentSystemConfigEdit.setText(system_config_path)
@Slot()
def onBrowseCurrentUserConfigButtonClicked(
@@ -659,7 +657,9 @@ class ALConfigWidget(QWidget, Ui_ALConfigWidget):
)[0]
if users_config_path:
users_config_path = QDir.toNativeSeparators(users_config_path)
self.loadConfig(users_config_path)
if self.loadConfig(users_config_path):
self.__config_paths["users"] = users_config_path
self.CurrentUserConfigEdit.setText(users_config_path)
@Slot()
def onBrowseExportSystemConfigButtonClicked(
+40 -1
View File
@@ -560,6 +560,9 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;勾选此项,如果有多个与目标&lt;span style=&quot; font-weight:700; font-style:italic;&quot;&gt;开始时间&lt;/span&gt;相近的可选时间,选择时间最早项&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>优先选择最早</string>
</property>
@@ -601,6 +604,9 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;期望的&lt;span style=&quot; font-weight:700; font-style:italic;&quot;&gt;结束时间&lt;/span&gt;不可用时,按照该偏差范围寻找最近可选时间&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>120</number>
</property>
@@ -691,6 +697,9 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;期望的&lt;span style=&quot; font-weight:700; font-style:italic;&quot;&gt;开始时间&lt;/span&gt;不可用时,按照该偏差范围寻找最近可选时间&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>120</number>
</property>
@@ -710,6 +719,9 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;勾选此项,如果有多个与目标&lt;span style=&quot; font-weight:700; font-style:italic;&quot;&gt;结束时间&lt;/span&gt;相近的可选时间,选择时间最晚项&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>优先选择最晚</string>
</property>
@@ -789,6 +801,9 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;期望的预约时长,脚本会尽量满足&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<double>8.000000000000000</double>
</property>
@@ -869,6 +884,9 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;勾选此项,会优先满足预约时长限制,当座位紧张时可能会导致&lt;span style=&quot; font-weight:700; font-style:italic;&quot;&gt;预约失败&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>优先满足时长要求</string>
</property>
@@ -1046,6 +1064,12 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;脚本运行使用的浏览器类型&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="currentText">
<string>edge</string>
</property>
@@ -1113,6 +1137,12 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;详情请参阅根目录中的 manual.html&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
@@ -1150,6 +1180,12 @@
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;运行时不显示浏览器&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>无头模式</string>
</property>
@@ -1237,6 +1273,9 @@
<height>25</height>
</size>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;无需更改&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>主机URL</string>
</property>
@@ -1758,7 +1797,7 @@
</size>
</property>
<property name="text">
<string>载配置</string>
<string>载配置</string>
</property>
</widget>
</item>
+6
View File
@@ -127,6 +127,12 @@
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;开始运行自动脚本&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(10, 170, 10);
font: 12pt &quot;Microsoft YaHei UI&quot;;