diff --git a/LDDC/backend/service.py b/LDDC/backend/service.py index 126f23a..9f93f14 100644 --- a/LDDC/backend/service.py +++ b/LDDC/backend/service.py @@ -546,7 +546,7 @@ def handle_task(self, task: dict) -> None: info["duration"] = info["duration"] / 1000 worker = AutoLyricsFetcher(info, source=[Source[s] for s in cfg["desktop_lyrics_sources"]], taskid=self.taskid) - worker.signals.result.connect(self.handle_fetch_result) + worker.signals.result.connect(self.handle_fetch_result, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) else: # 没有标题无法自动获取歌词 diff --git a/LDDC/backend/worker.py b/LDDC/backend/worker.py index 7ecb21f..a99f72d 100644 --- a/LDDC/backend/worker.py +++ b/LDDC/backend/worker.py @@ -65,6 +65,7 @@ class CheckUpdateSignal(QObject): class CheckUpdate(QRunnable): + def __init__(self, is_auto: bool, name: str, repo: str, version: str) -> None: super().__init__() self.isAuto = is_auto @@ -152,8 +153,8 @@ def run(self) -> None: else: self.search_task[task_id] = None worker = SearchWorker(task_id, self.keyword, self.search_type, source, self.page, self.info) - worker.signals.result.connect(self.handle_search_result) - worker.signals.error.connect(self.handle_search_error) + worker.signals.result.connect(self.handle_search_result, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(self.handle_search_error, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) if self.search_task_finished != len(self.search_task): @@ -381,7 +382,7 @@ def fetch_next_lyrics(self) -> None: info = self.song_infos[self.current_index] self.current_index += 1 worker = AutoLyricsFetcher(info, self.min_score, self.source) - worker.signals.result.connect(self.handle_fetch_result) + worker.signals.result.connect(self.handle_fetch_result, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) def run(self) -> None: diff --git a/LDDC/res/resource_rc.py b/LDDC/res/resource_rc.py index c62cd92..70ee579 100644 --- a/LDDC/res/resource_rc.py +++ b/LDDC/res/resource_rc.py @@ -1,6 +1,6 @@ # Resource object code (Python 3) # Created by: object code -# Created by: The Resource Compiler for Qt version 6.7.3 +# Created by: The Resource Compiler for Qt version 6.8.0 # WARNING! All changes made in this file will be lost! from PySide6 import QtCore diff --git a/LDDC/view/local_match.py b/LDDC/view/local_match.py index 736fc1c..bdf3ccf 100644 --- a/LDDC/view/local_match.py +++ b/LDDC/view/local_match.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-3.0-only import os -from PySide6.QtCore import Slot +from PySide6.QtCore import Qt, Slot from PySide6.QtWidgets import ( QCheckBox, QComboBox, @@ -131,10 +131,10 @@ def start_cancel_button_clicked(self) -> None: "source": source, }, ) - self.worker.signals.error.connect(self.worker_error) - self.worker.signals.finished.connect(self.worker_finished) - self.worker.signals.massage.connect(self.worker_massage) - self.worker.signals.progress.connect(self.change_progress) + self.worker.signals.error.connect(self.worker_error, Qt.ConnectionType.BlockingQueuedConnection) + self.worker.signals.finished.connect(self.worker_finished, Qt.ConnectionType.BlockingQueuedConnection) + self.worker.signals.massage.connect(self.worker_massage, Qt.ConnectionType.BlockingQueuedConnection) + self.worker.signals.progress.connect(self.change_progress, Qt.ConnectionType.BlockingQueuedConnection) threadpool.startOnReservedThread(self.worker) @Slot(str) diff --git a/LDDC/view/search.py b/LDDC/view/search.py index 0562bf6..96faec4 100644 --- a/LDDC/view/search.py +++ b/LDDC/view/search.py @@ -147,8 +147,8 @@ def search(self) -> None: self.taskid["results_table"] += 1 self.search_info = {'keyword': keyword, 'search_type': SearchType(self.search_type_comboBox.currentIndex()), 'source': self.get_source(), 'page': 1} worker = SearchWorker(self.taskid["results_table"], keyword, SearchType(self.search_type_comboBox.currentIndex()), self.get_source(), 1) - worker.signals.result.connect(self.search_result_slot) - worker.signals.error.connect(self.search_error_slot) + worker.signals.result.connect(self.search_result_slot, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(self.search_error_slot, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) self.results_tableWidget.setRowCount(0) self.results_tableWidget.setColumnCount(0) @@ -227,8 +227,8 @@ def update_preview_lyric(self, info: dict | None = None) -> None: "lyrics_format": LyricsFormat(self.lyricsformat_comboBox.currentIndex()), "id": self.taskid["update_preview_lyric"], "offset": self.offset_spinBox.value()}) - worker.signals.result.connect(self.update_preview_lyric_result_slot) - worker.signals.error.connect(self.update_preview_lyric_error_slot) + worker.signals.result.connect(self.update_preview_lyric_result_slot, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(self.update_preview_lyric_error_slot, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) self.preview_lyric_result = None @@ -340,8 +340,8 @@ def get_songlist_result(self, result_type: str, info: dict) -> None: else: msg = "Unknown result_type" raise ValueError(msg) - worker.signals.result.connect(self.show_songlist_result) - worker.signals.error.connect(self.get_songlist_error) + worker.signals.result.connect(self.show_songlist_result, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(self.get_songlist_error, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) self.results_tableWidget.setRowCount(0) self.results_tableWidget.setColumnCount(0) @@ -378,8 +378,8 @@ def search_lyrics(self, info: dict) -> None: worker = SearchWorker(self.taskid["results_table"], f"{get_artist_str(info.get('artist'), '、')} - {info['title'].strip()}", SearchType.LYRICS, info['source'], 1, info) - worker.signals.result.connect(self.search_lyrics_result_slot) - worker.signals.error.connect(self.search_lyrics_error_slot) + worker.signals.result.connect(self.search_lyrics_result_slot, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(self.search_lyrics_error_slot, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) @Slot(QModelIndex) @@ -488,8 +488,8 @@ def results_table_scroll_changed(self) -> None: self.search_info['search_type'], self.search_info['source'], self.search_info['page'] + 1) - worker.signals.result.connect(self.search_nextpage_result_slot) - worker.signals.error.connect(self.search_nextpage_error) + worker.signals.result.connect(self.search_nextpage_result_slot, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(self.search_nextpage_error, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) @@ -642,8 +642,8 @@ def get_list_lyrics_update(count: int | str, result: dict | None = None) -> None self.get_list_lyrics_box.show() self.get_list_lyrics_box.setEnabled(True) - worker.signals.result.connect(get_list_lyrics_update) - worker.signals.error.connect(get_list_lyrics_update) + worker.signals.result.connect(get_list_lyrics_update, Qt.ConnectionType.BlockingQueuedConnection) + worker.signals.error.connect(get_list_lyrics_update, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) @Slot() @@ -794,7 +794,7 @@ def dropEvent(self, event: QDropEvent) -> None: MsgBox.warning(self, "警告", "没有获取到歌曲标题,无法自动搜索") worker = AutoLyricsFetcher(song, taskid=tuple(self.taskid.values()), return_search_result=True) - worker.signals.result.connect(self.auto_fetch_slot) + worker.signals.result.connect(self.auto_fetch_slot, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker) self.preview_lyric_result = None self.preview_plainTextEdit.setPlainText(self.tr("正在自动获取 {0} 的歌词...").format( diff --git a/LDDC/view/setting.py b/LDDC/view/setting.py index 357b30f..2e1a859 100644 --- a/LDDC/view/setting.py +++ b/LDDC/view/setting.py @@ -225,7 +225,7 @@ def language_comboBox_changed(self, index: int) -> None: @Slot() def update_cache_size(self) -> None: - self.cache_size_label.setText(self.tr("缓存大小:") + f" {cache.volume() / 1000000 } MB") + self.cache_size_label.setText(self.tr("缓存大小:") + f" {cache.volume() / 1000000} MB") @Slot() def clear_cache(self) -> None: diff --git a/LDDC/view/update.py b/LDDC/view/update.py index 791e85f..a556c56 100644 --- a/LDDC/view/update.py +++ b/LDDC/view/update.py @@ -44,5 +44,5 @@ def show_new_version_dialog(name: str, repo: str, new_version: str, body: str) - def check_update(is_auto: bool, name: str, repo: str, version: str) -> None: worker = CheckUpdate(is_auto, name, repo, version) - worker.signals.show_new_version_dialog.connect(show_new_version_dialog) + worker.signals.show_new_version_dialog.connect(show_new_version_dialog, Qt.ConnectionType.BlockingQueuedConnection) threadpool.start(worker)