Skip to content

The only downloader you need. 下载器的集大成者。

修复PopUpWindow 导致的闪退问题

XiaoYouChR6dd96d88b633
diff --git a/app/view/pop_up_window.py b/app/view/pop_up_window.py
index 3c7a1d00..5da29e8c 100644
--- a/app/view/pop_up_window.py
+++ b/app/view/pop_up_window.py
@@ -33,8 +33,6 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):
self.globalPath.lineTo(0, self.height())
self.globalPath.lineTo(0, 0)
- self.geometryAnimation = QPropertyAnimation(self, b"geometry")
-
# 设置界面图标和文字
self.setStyleSheet(
"""
@@ -105,7 +103,7 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):
def showEvent(self, event):
self.raise_()
- QTimer.singleShot(50, self.__moveIn)
+ self.__moveIn()
self.closeTimer = QTimer()
self.closeTimer.setSingleShot(True)
self.closeTimer.timeout.connect(self.__moveOut)
@@ -189,7 +187,9 @@ class PopUpWindowBase(QWidget, Ui_PopUpWindow):
@classmethod
def showPopUpWindow(cls, mainWindow=None):
- return cls(mainWindow)
+ w = PopUpWindowBase(mainWindow) # 若用 cls 编译后百分百闪退
+ w.show()
+ return w
class FinishedPopUpWindow(PopUpWindowBase):
@@ -226,11 +226,11 @@ class FinishedPopUpWindow(PopUpWindowBase):
self.openFileBtn.clicked.connect(lambda: openFile(fileResolvePath))
self.openPathBtn.clicked.connect(lambda: openFile(dirname(fileResolvePath)))
- self.show()
-
@classmethod
def showPopUpWindow(cls, fileResolvePath:str, mainWindow=None):
- return cls(fileResolvePath, mainWindow)
+ w = FinishedPopUpWindow(fileResolvePath, mainWindow)
+ w.show()
+ return w
class ReceivedPopUpWindow(PopUpWindowBase):
@@ -242,8 +242,6 @@ class ReceivedPopUpWindow(PopUpWindowBase):
self.captionLabel.setText("接收到来自浏览器的下载任务:")
self.contentLabel.setText(receiveContent)
- self.show()
-
def _playSound(self):
# 设置音效
self.soundEffect = QSoundEffect(self)
@@ -253,7 +251,9 @@ class ReceivedPopUpWindow(PopUpWindowBase):
@classmethod
def showPopUpWindow(cls, receiveContent:str, mainWindow=None):
- return cls(receiveContent, mainWindow)
+ w = ReceivedPopUpWindow(receiveContent, mainWindow)
+ w.show()
+ return w
class PopUpWindowManager(QObject):
@@ -275,7 +275,7 @@ class PopUpWindowManager(QObject):
PopUpWindowManager._initialized = True
def add(self, popUpWindow: PopUpWindowBase):
- # print("PopUpWindow Added")
+ print("PopUpWindow Added", popUpWindow)
if popUpWindow not in self.popUpWindows:
self.popUpWindows.append(popUpWindow)
# 按照 PopUpWindow 的数量移动 PopUpWindow 的 y 坐标
diff --git a/deploy.py b/deploy.py
index b5379e73..eed81675 100644
--- a/deploy.py
+++ b/deploy.py
@@ -6,7 +6,7 @@ from app.common.config import VERSION, YEAR, AUTHOR
if sys.platform == "win32":
args = [
'nuitka',
- '--standalone',
+ '--standalone', # Following all imports is the default for standalone mode and need not be specified.
'--windows-console-mode=disable',
'--plugin-enable=pyside6' ,
'--assume-yes-for-downloads',
@@ -22,7 +22,7 @@ if sys.platform == "win32":
'--file-description="Ghost Downloader"',
f'--copyright="Copyright(C) {YEAR} {AUTHOR}"',
'--output-dir=dist',
- 'Ghost-Downloader-3.py',
+ 'tests/test_pop_up_window.py',
]
elif sys.platform == "darwin":
args = [