Skip to content

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

fix(UI): 修复切换到 TaskPage 时页面闪烁抖动

XiaoYouChRa82d67e99b5c
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.py
index 8f23f2e5..80d05ba2 100644
--- a/Ghost-Downloader-3.py
+++ b/Ghost-Downloader-3.py
@@ -42,9 +42,10 @@ def setupEnvironment():
mimetypes._db = mimetypes.MimeTypes()
import app.assets.resources # noqa: F401
- from app.view.qfw_patch import patchFluentLabelThemeChanged
+ from app.view.qfw_patch import patchFluentLabelThemeChanged, patchStackedWidgetAnimation
from app.view.components.labels import IconBodyLabel
patchFluentLabelThemeChanged()
+ patchStackedWidgetAnimation()
qconfig.themeChanged.connect(IconBodyLabel.clearCache)
qconfig.load(f"{APP_DATA_DIR}/UserConfig.json", cfg)
diff --git a/android/main.py b/android/main.py
index 43ceb194..af0608a5 100644
--- a/android/main.py
+++ b/android/main.py
@@ -26,9 +26,10 @@ def setupEnvironment():
from app.config.constants import VERSION
from app.platform.android import nativeLibraryDir
- from app.view.qfw_patch import patchFluentLabelThemeChanged
+ from app.view.qfw_patch import patchFluentLabelThemeChanged, patchStackedWidgetAnimation
from app.view.components.labels import IconBodyLabel
patchFluentLabelThemeChanged()
+ patchStackedWidgetAnimation()
qconfig.themeChanged.connect(IconBodyLabel.clearCache)
qconfig.load(f"{APP_DATA_DIR}/UserConfig.json", cfg)
logger.info("Ghost Downloader v{} (Android) launched", VERSION)
diff --git a/app/view/qfw_patch.py b/app/view/qfw_patch.py
index b329b675..61ee7364 100644
--- a/app/view/qfw_patch.py
+++ b/app/view/qfw_patch.py
@@ -6,6 +6,66 @@ if TYPE_CHECKING:
from PySide6.QtWidgets import QStackedWidget
+def patchStackedWidgetAnimation() -> None:
+ from PySide6.QtCore import QAbstractAnimation, QEasingCurve, QPoint
+ from PySide6.QtWidgets import QStackedWidget as _QStackedWidget
+ from qfluentwidgets.components.widgets.stacked_widget import PopUpAniStackedWidget
+
+ def setCurrentIndex(self, index, needPopOut=False, showNextWidgetDirectly=True,
+ duration=250, easingCurve=QEasingCurve.OutQuad):
+ if index < 0 or index >= self.count():
+ raise Exception(f'The index `{index}` is illegal')
+ if index == self.currentIndex():
+ return
+ if not self.isAnimationEnabled:
+ return _QStackedWidget.setCurrentIndex(self, index)
+
+ if self._ani and self._ani.state() == QAbstractAnimation.Running:
+ self._ani.stop()
+ self._ani.finished.disconnect()
+ _QStackedWidget.setCurrentIndex(self, self._nextIndex)
+ self.aniFinished.emit()
+
+ self._nextIndex = index
+ nextAniInfo = self.aniInfos[index]
+ currentAniInfo = self.aniInfos[self.currentIndex()]
+ currentWidget = self.currentWidget()
+ nextWidget = nextAniInfo.widget
+ ani = currentAniInfo.ani if needPopOut else nextAniInfo.ani
+ self._ani = ani
+
+ if needPopOut:
+ deltaX, deltaY = currentAniInfo.deltaX, currentAniInfo.deltaY
+ pos = currentWidget.pos() + QPoint(deltaX, deltaY)
+ ani.setEasingCurve(easingCurve)
+ ani.setStartValue(currentWidget.pos())
+ ani.setEndValue(pos)
+ ani.setDuration(duration)
+ nextWidget.setVisible(showNextWidgetDirectly)
+ else:
+ deltaX, deltaY = nextAniInfo.deltaX, nextAniInfo.deltaY
+ pos = nextWidget.pos() + QPoint(deltaX, deltaY)
+ ani.setEasingCurve(easingCurve)
+ ani.setStartValue(pos)
+ ani.setEndValue(QPoint(nextWidget.x(), 0))
+ ani.setDuration(duration)
+ currentWidget.hide()
+ nextWidget.resize(self.size())
+ nextWidget.move(pos)
+ nextWidget.setVisible(True)
+
+ def onFinished():
+ ani.finished.disconnect(onFinished)
+ _QStackedWidget.setCurrentIndex(self, self._nextIndex)
+ self.aniFinished.emit()
+
+ ani.finished.connect(onFinished)
+ ani.start()
+ self.aniStart.emit()
+
+ PopUpAniStackedWidget.setCurrentIndex = setCurrentIndex
+
+
def patchFluentLabelThemeChanged() -> None:
from qfluentwidgets.components.widgets import label