Skip to content

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

SplashScreen 渐变消失

XiaoYouChRf14e104e8b55
diff --git a/app/view/main_window.py b/app/view/main_window.py
index 9c703fe2..e8f7b3f7 100644
--- a/app/view/main_window.py
+++ b/app/view/main_window.py
@@ -3,9 +3,9 @@ import ctypes
from pathlib import Path
import darkdetect
-from PySide6.QtCore import QSize, QThread, Signal, QTimer
+from PySide6.QtCore import QSize, QThread, Signal, QTimer, QPropertyAnimation
from PySide6.QtGui import QIcon
-from PySide6.QtWidgets import QApplication
+from PySide6.QtWidgets import QApplication, QGraphicsOpacityEffect
from loguru import logger
from qfluentwidgets import FluentIcon as FIF, setTheme, Theme
from qfluentwidgets import NavigationItemPosition, MSFluentWindow, SplashScreen
@@ -19,6 +19,19 @@ from ..components.add_task_dialog import AddTaskOptionDialog
from ..components.custom_tray import CustomSystemTrayIcon
from ..components.update_dialog import checkUpdate
+class CustomSplashScreen(SplashScreen):
+
+ def finish(self):
+ """ fade out splash screen """
+ opacityEffect = QGraphicsOpacityEffect(self)
+ self.setGraphicsEffect(opacityEffect)
+ opacityAni = QPropertyAnimation(opacityEffect, b'opacity', self)
+ opacityAni.setStartValue(1)
+ opacityAni.setEndValue(0)
+ opacityAni.setDuration(200)
+ opacityAni.finished.connect(self.deleteLater)
+ opacityAni.start()
+
class ThemeChangedListener(QThread):
themeChanged = Signal(str)
@@ -126,7 +139,7 @@ class MainWindow(MSFluentWindow):
self.setWindowTitle('Ghost Downloader')
# create splash screen
- self.splashScreen = SplashScreen(self.windowIcon(), self)
+ self.splashScreen = CustomSplashScreen(self.windowIcon(), self)
self.splashScreen.setIconSize(QSize(106, 106))
self.splashScreen.raise_()