The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
feat(view): 独立添加任务窗口支持拖动宽度,高度随内容自适应
XiaoYouChR94e979ce3994
diff --git a/Ghost-Downloader-3.py b/Ghost-Downloader-3.pyindex f2ec48a2..879b8911 100644--- a/Ghost-Downloader-3.py+++ b/Ghost-Downloader-3.py@@ -40,7 +40,7 @@ def setupEnvironment() -> None:setupHiddenSubprocess()from app.view.qfw_patch import (- patchLinuxFrameless, patchMaskDialogAnimation, patchStackedWidgetAnimation,+ patchLinuxFrameless, patchMaskDialogAnimation, patchStackedWidgetAnimation, patchWindowsFrameless,)from app.view.components.labels import IconBodyLabelpatchStackedWidgetAnimation()@@ -49,6 +49,8 @@ def setupEnvironment() -> None:patchMaskDialogAnimation()else:patchLinuxFrameless()+ if sys.platform == "win32":+ patchWindowsFrameless()qconfig.themeChanged.connect(IconBodyLabel.clearCache)qconfig.load(f"{APP_DATA_DIR}/UserConfig.json", cfg)diff --git a/app/view/dialogs/task_draft.py b/app/view/dialogs/task_draft.pyindex 44efbf4d..4e96e3a4 100644--- a/app/view/dialogs/task_draft.py+++ b/app/view/dialogs/task_draft.py@@ -37,7 +37,6 @@ class StandaloneWrapper(FramelessDialog):self._initLayout()def _initWidget(self) -> None:- self.setResizeEnabled(False)titleBar = FluentTitleBar(self)self.setTitleBar(titleBar)self.titleBar.maxBtn.hide()@@ -57,6 +56,18 @@ class StandaloneWrapper(FramelessDialog):def takeContent(self, widget) -> None:self.contentLayout.removeWidget(widget)+ def event(self, e) -> bool:+ isHandled = super().event(e)+ if e.type() == QEvent.Type.LayoutRequest:+ self._refreshHeight()+ return isHandled++ def _refreshHeight(self) -> None:+ available = self.screen().availableGeometry()+ height = min(self.contentLayout.sizeHint().height(), available.height())+ self.setFixedHeight(height)+ self.move(self.x(), min(self.y(), available.bottom() - height + 1))+def closeEvent(self, event) -> None:event.ignore()self._dialog.reject()@@ -269,6 +280,7 @@ class TaskDraftDialog(MessageBoxBase):self._hBoxLayout.removeWidget(self.widget)self._standaloneWrapper.setContent(self.widget)self.widget.setStyleSheet("#centerWidget { border: none; border-radius: 0; }")+ self.widget.setMaximumWidth(16777215)self.widget.show()self._isStandalone = True@@ -276,6 +288,7 @@ class TaskDraftDialog(MessageBoxBase):self._standaloneWrapper.hide()self._standaloneWrapper.takeContent(self.widget)self.widget.setStyleSheet("")+ self.widget.setMaximumWidth(700)self._hBoxLayout.addWidget(self.widget, 1, Qt.AlignmentFlag.AlignCenter)self.widget.show()self._isStandalone = Falsediff --git a/app/view/qfw_patch.py b/app/view/qfw_patch.pyindex c155eae0..eba6e3cd 100644--- a/app/view/qfw_patch.py+++ b/app/view/qfw_patch.py@@ -2,8 +2,18 @@ from __future__ import annotationsfrom typing import TYPE_CHECKING+from PySide6.QtCore import Qt+if TYPE_CHECKING:- from PySide6.QtWidgets import QStackedWidget+ from PySide6.QtWidgets import QStackedWidget, QWidget+++def resizableEdges(window: QWidget, edges: Qt.Edge) -> Qt.Edge:+ if window.minimumWidth() == window.maximumWidth():+ edges &= ~(Qt.Edge.LeftEdge | Qt.Edge.RightEdge)+ if window.minimumHeight() == window.maximumHeight():+ edges &= ~(Qt.Edge.TopEdge | Qt.Edge.BottomEdge)+ return edgesdef patchStackedWidgetAnimation() -> None:@@ -108,6 +118,7 @@ def patchLinuxFrameless() -> None:edges |= Edge.TopEdgeelif pos.y() >= self.height() - border:edges |= Edge.BottomEdge+ edges = resizableEdges(self, edges)if eventType == QEvent.Type.MouseMove:self.setCursor(EDGE_CURSORS.get(edges, Qt.CursorShape.ArrowCursor))@@ -122,6 +133,34 @@ def patchLinuxFrameless() -> None:linux.LinuxFramelessWindowBase.eventFilter = eventFilter+def patchWindowsFrameless() -> None:+ import win32con+ from qframelesswindow import windows++ Edge = Qt.Edge+ HIT_EDGES = {+ win32con.HTTOPLEFT: Edge.LeftEdge | Edge.TopEdge,+ win32con.HTTOPRIGHT: Edge.RightEdge | Edge.TopEdge,+ win32con.HTBOTTOMLEFT: Edge.LeftEdge | Edge.BottomEdge,+ win32con.HTBOTTOMRIGHT: Edge.RightEdge | Edge.BottomEdge,+ win32con.HTTOP: Edge.TopEdge,+ win32con.HTBOTTOM: Edge.BottomEdge,+ win32con.HTLEFT: Edge.LeftEdge,+ win32con.HTRIGHT: Edge.RightEdge,+ }+ EDGE_HITS = {edges: hit for hit, edges in HIT_EDGES.items()} | {Edge(0): win32con.HTCLIENT}++ _originalNativeEvent = windows.WindowsFramelessWindowBase.nativeEvent++ def nativeEvent(self, eventType, message):+ isHandled, result = _originalNativeEvent(self, eventType, message)+ if result not in HIT_EDGES:+ return isHandled, result+ return True, EDGE_HITS[resizableEdges(self, HIT_EDGES[result])]++ windows.WindowsFramelessWindowBase.nativeEvent = nativeEvent++def unregisterRouter(stacked: QStackedWidget) -> None:from qfluentwidgets.common.router import qrouter