mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-08-02 06:09:36 +08:00
fix(settings): 修复测试公告栏连接时 QThread 未等待导致闪退
This commit is contained in:
@@ -73,9 +73,9 @@ class ALCheckUpdateDialog(QDialog):
|
|||||||
)
|
)
|
||||||
TitleLabel.setTextFormat(Qt.TextFormat.RichText)
|
TitleLabel.setTextFormat(Qt.TextFormat.RichText)
|
||||||
TitleLabel.setText(
|
TitleLabel.setText(
|
||||||
f"检测到最新版本: "
|
f"检测到新版本: "
|
||||||
f"<span style='color: inherit;'>{self.__current_version}</span>"
|
f"<span>{self.__current_version}</span> "
|
||||||
f" <span style='color: green; font-weight: bold;'>></span> "
|
f"<span>></span> "
|
||||||
f"<span style='color: green; font-weight: bold;'>{self.__latest_version}</span>"
|
f"<span style='color: green; font-weight: bold;'>{self.__latest_version}</span>"
|
||||||
)
|
)
|
||||||
layout.addWidget(TitleLabel)
|
layout.addWidget(TitleLabel)
|
||||||
@@ -83,8 +83,7 @@ class ALCheckUpdateDialog(QDialog):
|
|||||||
InfoLabel.setTextFormat(Qt.TextFormat.RichText)
|
InfoLabel.setTextFormat(Qt.TextFormat.RichText)
|
||||||
InfoLabel.setWordWrap(True)
|
InfoLabel.setWordWrap(True)
|
||||||
InfoLabel.setText(
|
InfoLabel.setText(
|
||||||
f"发布版本: <b>{self.__tag_name}</b><br>"
|
f"最新版本: <b>{self.__tag_name}</b><br>"
|
||||||
f"发布页面: <a href='{self.__html_url}'>{self.__html_url}</a>"
|
|
||||||
)
|
)
|
||||||
InfoLabel.setOpenExternalLinks(True)
|
InfoLabel.setOpenExternalLinks(True)
|
||||||
layout.addWidget(InfoLabel)
|
layout.addWidget(InfoLabel)
|
||||||
@@ -94,14 +93,26 @@ class ALCheckUpdateDialog(QDialog):
|
|||||||
"前往 GitHub",
|
"前往 GitHub",
|
||||||
QDialogButtonBox.ButtonRole.AcceptRole
|
QDialogButtonBox.ButtonRole.AcceptRole
|
||||||
)
|
)
|
||||||
|
self.__btn_github.setMinimumWidth(100)
|
||||||
|
self.__btn_github.setMaximumWidth(100)
|
||||||
|
self.__btn_github.setMinimumHeight(25)
|
||||||
|
self.__btn_github.setMaximumHeight(25)
|
||||||
self.__btn_download = self.__button_box.addButton(
|
self.__btn_download = self.__button_box.addButton(
|
||||||
"官网下载",
|
"官网下载",
|
||||||
QDialogButtonBox.ButtonRole.ActionRole
|
QDialogButtonBox.ButtonRole.ActionRole
|
||||||
)
|
)
|
||||||
|
self.__btn_download.setMinimumWidth(80)
|
||||||
|
self.__btn_download.setMaximumWidth(80)
|
||||||
|
self.__btn_download.setMinimumHeight(25)
|
||||||
|
self.__btn_download.setMaximumHeight(25)
|
||||||
self.__btn_cancel = self.__button_box.addButton(
|
self.__btn_cancel = self.__button_box.addButton(
|
||||||
"取消",
|
"取消",
|
||||||
QDialogButtonBox.ButtonRole.RejectRole
|
QDialogButtonBox.ButtonRole.RejectRole
|
||||||
)
|
)
|
||||||
|
self.__btn_cancel.setMinimumWidth(80)
|
||||||
|
self.__btn_cancel.setMaximumWidth(80)
|
||||||
|
self.__btn_cancel.setMinimumHeight(25)
|
||||||
|
self.__btn_cancel.setMaximumHeight(25)
|
||||||
layout.addWidget(self.__button_box)
|
layout.addWidget(self.__button_box)
|
||||||
|
|
||||||
def buildUpToDateUi(
|
def buildUpToDateUi(
|
||||||
@@ -117,7 +128,9 @@ class ALCheckUpdateDialog(QDialog):
|
|||||||
TitleLabel.setText(f"已是最新版本 !")
|
TitleLabel.setText(f"已是最新版本 !")
|
||||||
layout.addWidget(TitleLabel)
|
layout.addWidget(TitleLabel)
|
||||||
InfoLabel = QLabel()
|
InfoLabel = QLabel()
|
||||||
InfoLabel.setText(f"当前版本: {self.__current_version}")
|
InfoLabel.setText(
|
||||||
|
f"当前版本: <b>{self.__current_version}</b><br>"
|
||||||
|
)
|
||||||
layout.addWidget(InfoLabel)
|
layout.addWidget(InfoLabel)
|
||||||
layout.addStretch()
|
layout.addStretch()
|
||||||
self.__button_box = QDialogButtonBox()
|
self.__button_box = QDialogButtonBox()
|
||||||
@@ -125,6 +138,10 @@ class ALCheckUpdateDialog(QDialog):
|
|||||||
"确定",
|
"确定",
|
||||||
QDialogButtonBox.ButtonRole.AcceptRole
|
QDialogButtonBox.ButtonRole.AcceptRole
|
||||||
)
|
)
|
||||||
|
self.__btn_close.setMinimumWidth(80)
|
||||||
|
self.__btn_close.setMaximumWidth(80)
|
||||||
|
self.__btn_close.setMinimumHeight(25)
|
||||||
|
self.__btn_close.setMaximumHeight(25)
|
||||||
layout.addWidget(self.__button_box)
|
layout.addWidget(self.__button_box)
|
||||||
|
|
||||||
def connectSignals(
|
def connectSignals(
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ class ALSettingsWidget(CenterOnParentMixin, QWidget, Ui_ALSettingsWidget):
|
|||||||
event: QCloseEvent
|
event: QCloseEvent
|
||||||
):
|
):
|
||||||
|
|
||||||
|
if hasattr(self, '__bulletin_test_worker') and self.__bulletin_test_worker is not None:
|
||||||
|
self.__bulletin_test_worker.wait(3000)
|
||||||
self.settingsWidgetIsClosed.emit()
|
self.settingsWidgetIsClosed.emit()
|
||||||
super().closeEvent(event)
|
super().closeEvent(event)
|
||||||
|
|
||||||
@@ -485,25 +487,26 @@ class ALSettingsWidget(CenterOnParentMixin, QWidget, Ui_ALSettingsWidget):
|
|||||||
self, api_url, {"date": "", "time": "", "range_hour": "1"}
|
self, api_url, {"date": "", "time": "", "range_hour": "1"}
|
||||||
)
|
)
|
||||||
self.__bulletin_test_worker.fetchWorkerIsFinished.connect(
|
self.__bulletin_test_worker.fetchWorkerIsFinished.connect(
|
||||||
self.onBulletinTestFetched
|
self.onBulletinTestIsFinished
|
||||||
)
|
)
|
||||||
self.__bulletin_test_worker.fetchWorkerFinishedWithError.connect(
|
self.__bulletin_test_worker.fetchWorkerFinishedWithError.connect(
|
||||||
self.onBulletinTestError
|
self.onBulletinTestFinishedWithError
|
||||||
)
|
)
|
||||||
self.__bulletin_test_worker.start()
|
self.__bulletin_test_worker.start()
|
||||||
|
|
||||||
@Slot(dict)
|
@Slot(dict)
|
||||||
def onBulletinTestFetched(
|
def onBulletinTestIsFinished(
|
||||||
self,
|
self,
|
||||||
data: dict
|
data: dict
|
||||||
):
|
):
|
||||||
|
|
||||||
self.__bulletin_test_worker.fetchWorkerIsFinished.disconnect(
|
self.__bulletin_test_worker.fetchWorkerIsFinished.disconnect(
|
||||||
self.onBulletinTestFetched
|
self.onBulletinTestIsFinished
|
||||||
)
|
)
|
||||||
self.__bulletin_test_worker.fetchWorkerFinishedWithError.disconnect(
|
self.__bulletin_test_worker.fetchWorkerFinishedWithError.disconnect(
|
||||||
self.onBulletinTestError
|
self.onBulletinTestFinishedWithError
|
||||||
)
|
)
|
||||||
|
self.__bulletin_test_worker.wait(3000)
|
||||||
self.__bulletin_test_worker.deleteLater()
|
self.__bulletin_test_worker.deleteLater()
|
||||||
self.__bulletin_test_worker = None
|
self.__bulletin_test_worker = None
|
||||||
elapsed_ms = (time.monotonic() - self.__bulletin_test_t0) * 1000
|
elapsed_ms = (time.monotonic() - self.__bulletin_test_t0) * 1000
|
||||||
@@ -515,17 +518,18 @@ class ALSettingsWidget(CenterOnParentMixin, QWidget, Ui_ALSettingsWidget):
|
|||||||
QTimer.singleShot(3000, self, self.clearBulletinTestStatus)
|
QTimer.singleShot(3000, self, self.clearBulletinTestStatus)
|
||||||
|
|
||||||
@Slot(str)
|
@Slot(str)
|
||||||
def onBulletinTestError(
|
def onBulletinTestFinishedWithError(
|
||||||
self,
|
self,
|
||||||
error_message: str
|
error_message: str
|
||||||
):
|
):
|
||||||
|
|
||||||
self.__bulletin_test_worker.fetchWorkerIsFinished.disconnect(
|
self.__bulletin_test_worker.fetchWorkerIsFinished.disconnect(
|
||||||
self.onBulletinTestFetched
|
self.onBulletinTestIsFinished
|
||||||
)
|
)
|
||||||
self.__bulletin_test_worker.fetchWorkerFinishedWithError.disconnect(
|
self.__bulletin_test_worker.fetchWorkerFinishedWithError.disconnect(
|
||||||
self.onBulletinTestError
|
self.onBulletinTestFinishedWithError
|
||||||
)
|
)
|
||||||
|
self.__bulletin_test_worker.wait(3000)
|
||||||
self.__bulletin_test_worker.deleteLater()
|
self.__bulletin_test_worker.deleteLater()
|
||||||
self.__bulletin_test_worker = None
|
self.__bulletin_test_worker = None
|
||||||
self.BulletinTestStatusLabel.setText(f"连接失败:{error_message}")
|
self.BulletinTestStatusLabel.setText(f"连接失败:{error_message}")
|
||||||
|
|||||||
Reference in New Issue
Block a user