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

Compare commits

..

2 Commits

Author SHA1 Message Date
KenanZhu 829a8440ad chore(gui): fix some widget length to match the design 2025-11-11 09:14:04 +08:00
KenanZhu 389ac885d3 fix(ALMainWindow): optimize the resource usage of gui
This commit fixes memory management issues in the
ALMainWindow class where config window and
task threads were not properly deleted after use,
leading to continuously increasing memory usage.

The fix ensures that all GUI components are
deleted after close and background threads are
correctly terminated.
2025-11-11 09:05:55 +08:00
2 changed files with 336 additions and 304 deletions
+329 -303
View File
@@ -232,8 +232,8 @@
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
<item row="0" column="0"> <item row="2" column="0">
<widget class="QLabel" name="UsernameKabel"> <widget class="QLabel" name="PasswordLabel">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>100</width>
@@ -247,7 +247,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>用户名</string> <string>密码</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -299,25 +299,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="PasswordLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>密码:</string>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="UsernameEdit"> <widget class="QLineEdit" name="UsernameEdit">
<property name="minimumSize"> <property name="minimumSize">
@@ -340,6 +321,25 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="UsernameKabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>用户名:</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -376,8 +376,65 @@
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
</property> </property>
<item row="4" column="4"> <item row="0" column="1">
<widget class="QLineEdit" name="SeatIDEdit"> <widget class="QLabel" name="DateLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>日期:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="MaxBeginTimeDiffLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最大时长偏差:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="PlaceLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>地点:</string>
</property>
</widget>
</item>
<item row="12" column="4">
<widget class="QDoubleSpinBox" name="ExpectDurationSpinBox">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@@ -390,6 +447,37 @@
<height>25</height> <height>25</height>
</size> </size>
</property> </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>
</widget>
</item>
<item row="11" column="4">
<widget class="QCheckBox" name="PreferLateEndTimeCheckBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<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>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="9" column="1">
@@ -411,11 +499,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="5" column="1">
<widget class="QComboBox" name="PlaceComboBox"> <widget class="QLabel" name="BeginTimeLabel">
<property name="enabled"> <property name="minimumSize">
<bool>false</bool> <size>
<width>100</width>
<height>25</height>
</size>
</property> </property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>开始时间:</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="FloorComboBox">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@@ -430,13 +534,28 @@
</property> </property>
<item> <item>
<property name="text"> <property name="text">
<string>图书馆</string> <string>二层</string>
</property>
</item>
<item>
<property name="text">
<string>三层</string>
</property>
</item>
<item>
<property name="text">
<string>四层</string>
</property>
</item>
<item>
<property name="text">
<string>五层</string>
</property> </property>
</item> </item>
</widget> </widget>
</item> </item>
<item row="12" column="1"> <item row="10" column="1">
<widget class="QLabel" name="ExpectDurationLabel"> <widget class="QLabel" name="MaxEndTimeDiffLabel">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>100</width>
@@ -450,7 +569,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>期望时长</string> <string>最大时长偏差</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -487,8 +606,31 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="4">
<widget class="QLabel" name="DateLabel"> <widget class="QDateEdit" name="DateEdit">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<property name="date">
<date>
<year>2025</year>
<month>11</month>
<day>1</day>
</date>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLabel" name="ExpectDurationLabel">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>100</width>
@@ -502,7 +644,26 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>期:</string> <string>期望时长</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="RoomLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>区域:</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -546,11 +707,11 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="4"> <item row="13" column="4">
<widget class="QCheckBox" name="PreferEarlyBeginTimeCheckBox"> <widget class="QCheckBox" name="SatisfyDurationCheckBox">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>100</width> <width>0</width>
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
@@ -561,128 +722,16 @@
</size> </size>
</property> </property>
<property name="toolTip"> <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> <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>
<property name="text"> <property name="text">
<string>优先选择最早</string> <string>优先满足时长要求</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="10" column="1">
<widget class="QLabel" name="MaxEndTimeDiffLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最大时长偏差:</string>
</property>
</widget>
</item>
<item row="10" column="4">
<widget class="QSpinBox" name="MaxEndTimeDiffSpinBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<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>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="RoomLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>区域:</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QComboBox" name="FloorComboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<item>
<property name="text">
<string>二层</string>
</property>
</item>
<item>
<property name="text">
<string>三层</string>
</property>
</item>
<item>
<property name="text">
<string>四层</string>
</property>
</item>
<item>
<property name="text">
<string>五层</string>
</property>
</item>
</widget>
</item>
<item row="3" column="4">
<widget class="QComboBox" name="RoomComboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="7" column="4"> <item row="7" column="4">
<widget class="QSpinBox" name="MaxBeginTimeDiffSpinBox"> <widget class="QSpinBox" name="MaxBeginTimeDiffSpinBox">
<property name="minimumSize"> <property name="minimumSize">
@@ -705,50 +754,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="4">
<widget class="QCheckBox" name="PreferLateEndTimeCheckBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<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>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="BeginTimeLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>开始时间:</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLabel" name="FloorLabel"> <widget class="QLabel" name="FloorLabel">
<property name="minimumSize"> <property name="minimumSize">
@@ -768,6 +773,93 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4">
<widget class="QComboBox" name="PlaceComboBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
<item>
<property name="text">
<string>图书馆</string>
</property>
</item>
</widget>
</item>
<item row="8" column="4">
<widget class="QCheckBox" name="PreferEarlyBeginTimeCheckBox">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<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>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="4">
<widget class="QSpinBox" name="MaxEndTimeDiffSpinBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<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>
</widget>
</item>
<item row="3" column="4">
<widget class="QComboBox" name="RoomComboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="4" column="1"> <item row="4" column="1">
<widget class="QLabel" name="SeatIDLabel"> <widget class="QLabel" name="SeatIDLabel">
<property name="minimumSize"> <property name="minimumSize">
@@ -787,113 +879,47 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="4"> <item row="4" column="4">
<widget class="QDoubleSpinBox" name="ExpectDurationSpinBox"> <layout class="QHBoxLayout" name="SeatIDLayout">
<property name="minimumSize"> <item>
<size> <widget class="QLineEdit" name="SeatIDEdit">
<width>0</width> <property name="minimumSize">
<height>25</height> <size>
</size> <width>0</width>
</property> <height>25</height>
<property name="maximumSize"> </size>
<size> </property>
<width>16777215</width> <property name="maximumSize">
<height>25</height> <size>
</size> <width>130</width>
</property> <height>25</height>
<property name="toolTip"> </size>
<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> </widget>
<property name="maximum"> </item>
<double>8.000000000000000</double> <item>
</property> <widget class="QPushButton" name="SelectSeatsButton">
</widget> <property name="minimumSize">
</item> <size>
<item row="0" column="4"> <width>25</width>
<widget class="QDateEdit" name="DateEdit"> <height>25</height>
<property name="minimumSize"> </size>
<size> </property>
<width>0</width> <property name="maximumSize">
<height>25</height> <size>
</size> <width>25</width>
</property> <height>25</height>
<property name="maximumSize"> </size>
<size> </property>
<width>16777215</width> <property name="text">
<height>25</height> <string/>
</size> </property>
</property> <property name="icon">
<property name="date"> <iconset theme="edit-find"/>
<date> </property>
<year>2025</year> </widget>
<month>11</month> </item>
<day>1</day> </layout>
</date>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="MaxBeginTimeDiffLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>最大时长偏差:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="PlaceLabel">
<property name="minimumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>地点:</string>
</property>
</widget>
</item>
<item row="13" column="4">
<widget class="QCheckBox" name="SatisfyDurationCheckBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<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>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
+7 -1
View File
@@ -242,6 +242,8 @@ class ALMainWindow(QMainWindow, Ui_ALMainWindow):
config_paths: dict config_paths: dict
): ):
self.__alConfigWidget.configWidgetCloseSingal.disconnect(self.onConfigWidgetClosed)
self.__alConfigWidget.deleteLater()
self.__alConfigWidget = None self.__alConfigWidget = None
self.ConfigButton.setEnabled(True) self.ConfigButton.setEnabled(True)
self.StartButton.setEnabled(True) self.StartButton.setEnabled(True)
@@ -288,8 +290,12 @@ class ALMainWindow(QMainWindow, Ui_ALMainWindow):
): ):
if self.__auto_lib_thread and self.__auto_lib_thread.isRunning(): if self.__auto_lib_thread and self.__auto_lib_thread.isRunning():
self.__auto_lib_thread.stop()
self.showTrace("正在停止操作......") self.showTrace("正在停止操作......")
self.__auto_lib_thread.stop()
self.__auto_lib_thread.wait()
self.showTrace("操作已停止")
self.__auto_lib_thread.finishedSignal.disconnect(self.onStopButtonClicked)
self.__auto_lib_thread.deleteLater()
self.setControlButtons(True, True, False) self.setControlButtons(True, True, False)
@Slot() @Slot()