Skip to content

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

feat(AddTaskDialog): 为 AddTaskDialog 加入滚动效果

XiaoYouChR4608b21510d0
diff --git a/app/components/Ui_AddTaskOptionDialog.py b/app/components/Ui_AddTaskOptionDialog.py
index ab365bb7..f0edf0c9 100644
--- a/app/components/Ui_AddTaskOptionDialog.py
+++ b/app/components/Ui_AddTaskOptionDialog.py
@@ -1,40 +1,48 @@
# -*- coding: utf-8 -*-
-
-################################################################################
-## Form generated from reading UI file 'Ui_AddTaskOptionDialog.ui'
-##
-## Created by: Qt User Interface Compiler version 6.7.2
-##
-## WARNING! All changes made in this file will be lost when recompiling UI file!
-################################################################################
-
-from PySide6.QtCore import (QSize)
-from PySide6.QtWidgets import (QHBoxLayout, QSizePolicy, QTableWidgetItem, QVBoxLayout, QHeaderView)
+import sys
+
+from PySide6.QtCore import QSize
+from PySide6.QtWidgets import (
+ QHBoxLayout,
+ QSizePolicy,
+ QTableWidgetItem,
+ QVBoxLayout,
+ QHeaderView,
+ QWidget,
+)
from qfluentwidgets import FluentIcon as FIF, PlainTextEdit
-from qfluentwidgets import (PushButton, SubtitleLabel,
- TableWidget, RoundMenu, Action)
+from qfluentwidgets import PushButton, SubtitleLabel, TableWidget, RoundMenu, Action
from qfluentwidgets.components.widgets.button import PrimarySplitPushButton
+if sys.platform != "darwin":
+ from qfluentwidgets import SmoothScrollArea as ScrollArea
+else:
+ from qfluentwidgets import ScrollArea
+
class Ui_AddTaskOptionDialog(object):
def setupUi(self, AddTaskOptionDialog):
if not AddTaskOptionDialog.objectName():
- AddTaskOptionDialog.setObjectName(u"AddTaskOptionDialog")
- AddTaskOptionDialog.resize(680, 800)
- AddTaskOptionDialog.setMinimumSize(QSize(510, 620))
- AddTaskOptionDialog.setMaximumSize(QSize(680, 680))
- self.verticalLayout = QVBoxLayout(AddTaskOptionDialog)
- self.verticalLayout.setObjectName(u"verticalLayout")
- self.label = SubtitleLabel(AddTaskOptionDialog)
- self.label.setObjectName(u"label")
+ AddTaskOptionDialog.setObjectName("AddTaskOptionDialog")
+ self.scrollWidget = QWidget()
+ self.scrollWidget.setMinimumSize(QSize(510, 510))
+ self.verticalLayout = QVBoxLayout(self.scrollWidget)
+ self.verticalLayout.setObjectName("verticalLayout")
+ self.scrollWidget.setLayout(self.verticalLayout)
+ self.label = SubtitleLabel(self.scrollWidget)
+ self.label.setObjectName("label")
self.verticalLayout.addWidget(self.label)
- self.linkTextEdit = PlainTextEdit(AddTaskOptionDialog)
- self.linkTextEdit.setObjectName(u"linkTextEdit")
- self.linkTextEdit.setLineWrapMode(PlainTextEdit.LineWrapMode.NoWrap) # 禁用自动换行
+ self.linkTextEdit = PlainTextEdit(self.scrollWidget)
+ self.linkTextEdit.setObjectName("linkTextEdit")
+ self.linkTextEdit.setLineWrapMode(
+ PlainTextEdit.LineWrapMode.NoWrap
+ ) # 禁用自动换行
- sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
+ sizePolicy = QSizePolicy(
+ QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding
+ )
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.linkTextEdit.sizePolicy().hasHeightForWidth())
@@ -42,16 +50,18 @@ class Ui_AddTaskOptionDialog(object):
self.verticalLayout.addWidget(self.linkTextEdit)
- self.taskTableWidget = TableWidget(AddTaskOptionDialog)
- if (self.taskTableWidget.columnCount() < 2):
+ self.taskTableWidget = TableWidget(self.scrollWidget)
+ if self.taskTableWidget.columnCount() < 2:
self.taskTableWidget.setColumnCount(2)
__qtablewidgetitem = QTableWidgetItem()
self.taskTableWidget.setHorizontalHeaderItem(0, __qtablewidgetitem)
__qtablewidgetitem1 = QTableWidgetItem()
self.taskTableWidget.setHorizontalHeaderItem(1, __qtablewidgetitem1)
- self.taskTableWidget.setObjectName(u"taskTableWidget")
+ self.taskTableWidget.setObjectName("taskTableWidget")
self.taskTableWidget.verticalHeader().setVisible(False) # 隐藏垂直表头
- self.taskTableWidget.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch) # 第一列拉伸
+ self.taskTableWidget.horizontalHeader().setSectionResizeMode(
+ 0, QHeaderView.Stretch
+ ) # 第一列拉伸
self.verticalLayout.addWidget(self.taskTableWidget)
@@ -60,25 +70,25 @@ class Ui_AddTaskOptionDialog(object):
#
# self.verticalLayout.addWidget(self.statisticLabel)
- self.label_2 = SubtitleLabel(AddTaskOptionDialog)
- self.label_2.setObjectName(u"label_2")
+ self.label_2 = SubtitleLabel(self.scrollWidget)
+ self.label_2.setObjectName("label_2")
self.verticalLayout.addWidget(self.label_2)
self.buttonLayout = QHBoxLayout()
- self.buttonLayout.setObjectName(u"buttonLayout")
- self.noButton = PushButton(AddTaskOptionDialog)
- self.noButton.setObjectName(u"noButton")
+ self.buttonLayout.setObjectName("buttonLayout")
+ self.noButton = PushButton(self.scrollWidget)
+ self.noButton.setObjectName("noButton")
self.buttonLayout.addWidget(self.noButton, stretch=1)
- self.laterMenu = RoundMenu(parent=AddTaskOptionDialog)
- self.laterMenu.setObjectName(u"laterMenu")
+ self.laterMenu = RoundMenu(parent=self.scrollWidget)
+ self.laterMenu.setObjectName("laterMenu")
self.laterAction = Action(FIF.STOP_WATCH, self.tr("稍后下载"))
self.laterMenu.addAction(self.laterAction)
- self.yesButton = PrimarySplitPushButton(AddTaskOptionDialog)
- self.yesButton.setObjectName(u"yesButton")
+ self.yesButton = PrimarySplitPushButton(self.scrollWidget)
+ self.yesButton.setObjectName("yesButton")
# Fix PyQt-Fluent-Widgets Bug
self.yesButton.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
@@ -99,14 +109,16 @@ class Ui_AddTaskOptionDialog(object):
def retranslateUi(self):
self.label.setText(self.tr("新建任务"))
- self.linkTextEdit.setPlaceholderText(self.tr("添加多个下载链接时,请确保每行只有一个下载链接"))
+ self.linkTextEdit.setPlaceholderText(
+ self.tr("添加多个下载链接时,请确保每行只有一个下载链接")
+ )
___qtablewidgetitem = self.taskTableWidget.horizontalHeaderItem(0)
- ___qtablewidgetitem.setText(self.tr("文件名"));
+ ___qtablewidgetitem.setText(self.tr("文件名"))
___qtablewidgetitem1 = self.taskTableWidget.horizontalHeaderItem(1)
- ___qtablewidgetitem1.setText(self.tr("大小"));
+ ___qtablewidgetitem1.setText(self.tr("大小"))
# self.statisticLabel.setText(self.tr("共 0 个文件"))
self.label_2.setText(self.tr("下载设置"))
self.noButton.setText(self.tr("取消下载"))
self.yesButton.setText(self.tr("开始下载"))
- # retranslateUi
+ # retranslateUi
diff --git a/app/components/add_task_dialog.py b/app/components/add_task_dialog.py
index 4a9e2801..aece7dc5 100644
--- a/app/components/add_task_dialog.py
+++ b/app/components/add_task_dialog.py
@@ -6,7 +6,14 @@ from threading import Thread
from PySide6.QtCore import Signal, Qt, QTimer, QEvent
from PySide6.QtGui import QColor, QResizeEvent
from PySide6.QtWidgets import QFileDialog, QTableWidgetItem
-from qfluentwidgets import PushSettingCard, RangeSettingCard, MessageBox, InfoBar, InfoBarPosition, FluentStyleSheet
+from qfluentwidgets import (
+ PushSettingCard,
+ RangeSettingCard,
+ MessageBox,
+ InfoBar,
+ InfoBarPosition,
+ FluentStyleSheet,
+)
from qfluentwidgets.common.icon import FluentIcon as FIF
from app.components.custom_mask_dialog_base import MaskDialogBase
@@ -16,7 +23,8 @@ from .select_folder_setting_card import SelectFolderSettingCard
from ..common.config import cfg, Headers
from ..common.methods import getReadableSize, getLinkInfo, addDownloadTask
-urlRe = re.compile(r"""
+urlRe = re.compile(
+ r"""
^
(https?://) # 协议
(?:
@@ -59,16 +67,19 @@ urlRe = re.compile(r"""
(?::\d{2,5})? # 端口
(?:/ \S*)? # 路径
$
- """, re.VERBOSE | re.IGNORECASE)
+ """,
+ re.VERBOSE | re.IGNORECASE,
+)
class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
-
- _instance = None # type: 'AddTaskOptionDialog'
- _initialized:bool = False # 记录是否被 close
- __addTableRowSignal = Signal(str, str, str) # fileName, fileSize, Url, 同理因为int最大值仅支持到2^31 PyQt无法定义int64 故只能使用str代替
- __gotWrong = Signal(str, int) # error, index
+ _instance = None # type: 'AddTaskOptionDialog'
+ _initialized: bool = False # 记录是否被 close
+ __addTableRowSignal = Signal(
+ str, str, str
+ ) # fileName, fileSize, Url, 同理因为int最大值仅支持到2^31 PyQt无法定义int64 故只能使用str代替
+ __gotWrong = Signal(str, int) # error, index
def __init__(self, parent=None):
super().__init__(parent=parent)
@@ -76,6 +87,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
self.customHeaders = Headers.copy()
FluentStyleSheet.DIALOG.apply(self.widget)
+ self._hBoxLayout.setContentsMargins(100, 75, 100, 75)
self.widget.setContentsMargins(11, 11, 11, 11)
self.setShadowEffect(60, (0, 10), QColor(0, 0, 0, 50))
@@ -85,17 +97,16 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
self.setupUi(self.widget)
self.verticalLayout.setSpacing(8)
- self.widget.setLayout(self.verticalLayout)
+ self.widget.setWidget(self.scrollWidget)
+ self.widget.setWidgetResizable(True)
# Choose Folder Card
- self.downloadFolderCard = SelectFolderSettingCard(cfg.downloadFolder, cfg.historyDownloadFolder, self.widget)
+ self.downloadFolderCard = SelectFolderSettingCard(
+ cfg.downloadFolder, cfg.historyDownloadFolder, self.widget
+ )
self.blockNumCard = RangeSettingCard(
- cfg.preBlockNum,
- FIF.CLOUD,
- self.tr("下载线程数"),
- '',
- self.widget
+ cfg.preBlockNum, FIF.CLOUD, self.tr("下载线程数"), "", self.widget
)
# Edit customHeaders Card
@@ -104,7 +115,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
FIF.EDIT,
self.tr("自定义请求标头"),
"",
- self.widget
+ self.widget,
)
self.verticalLayout.insertWidget(4, self.downloadFolderCard)
@@ -119,25 +130,34 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
re = QResizeEvent(e)
self.resize(re.size())
elif obj is self.windowMask:
- if e.type() == QEvent.MouseButtonRelease and e.button() == Qt.LeftButton \
- and self.isClosableOnMaskClicked():
+ if (
+ e.type() == QEvent.MouseButtonRelease
+ and e.button() == Qt.LeftButton
+ and self.isClosableOnMaskClicked()
+ ):
self.close()
return super().eventFilter(obj, e)
@classmethod
- def showAddTaskOptionDialog(cls, urlContent:str = "", parent:"QWidget"= None, headers:dict = None):
+ def showAddTaskOptionDialog(
+ cls, urlContent: str = "", parent: "QWidget" = None, headers: dict = None
+ ):
if cls._initialized:
_ = cls._instance.linkTextEdit.toPlainText()
- if urlContent and not urlContent in _.split('\n'):
+ if urlContent and not urlContent in _.split("\n"):
_ += "\n" + urlContent
cls._instance.linkTextEdit.setPlainText(_)
else:
- cls._instance = AddTaskOptionDialog(parent=parent) # 防止 nuitka 打包时因 cls 未定义而报错
+ cls._instance = AddTaskOptionDialog(
+ parent=parent
+ ) # 防止 nuitka 打包时因 cls 未定义而报错
cls._initialized = True
cls._instance.linkTextEdit.setPlainText(urlContent)
- if headers: # TODO headers 处理不合理, 应该每个 Item 都有自己的 headers, 要不然容易下不了
+ if (
+ headers
+ ): # TODO headers 处理不合理, 应该每个 Item 都有自己的 headers, 要不然容易下不了
cls._instance.customHeaders = headers
cls._instance.exec()
@@ -167,17 +187,19 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
def __handleWrong(self, error: str, index: int):
InfoBar.error(
- title=self.tr('错误'),
+ title=self.tr("错误"),
content=self.tr("解析第 {} 个链接时遇到错误: {}").format(index, error),
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=10000,
- parent=self.parent()
+ parent=self.parent(),
)
def __onEditHeadersCardClicked(self):
- newHeaders, ok = EditHeadersDialog(self, initialHeaders=self.customHeaders).getHeaders()
+ newHeaders, ok = EditHeadersDialog(
+ self, initialHeaders=self.customHeaders
+ ).getHeaders()
if newHeaders and ok:
self.customHeaders = newHeaders
@@ -192,13 +214,21 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
MessageBox(self.tr("错误"), repr(e), self)
else:
if not os.access(path, os.W_OK):
- MessageBox(self.tr("错误"), self.tr("似乎是没有权限向此目录写入文件"), self)
+ MessageBox(
+ self.tr("错误"), self.tr("似乎是没有权限向此目录写入文件"), self
+ )
for i in range(self.taskTableWidget.rowCount()):
item = self.taskTableWidget.item(i, 0)
fileName = item.text() if item.text() != item.data(1) else None
- addDownloadTask(item.data(1), fileName, str(path), self.customHeaders, preBlockNum=self.blockNumCard.configItem.value)
+ addDownloadTask(
+ item.data(1),
+ fileName,
+ str(path),
+ self.customHeaders,
+ preBlockNum=self.blockNumCard.configItem.value,
+ )
self.close()
@@ -213,27 +243,35 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
MessageBox(self.tr("错误"), repr(e), self)
else:
if not os.access(path, os.W_OK):
- MessageBox(self.tr("错误"), self.tr("似乎是没有权限向此目录写入文件"), self)
+ MessageBox(
+ self.tr("错误"), self.tr("似乎是没有权限向此目录写入文件"), self
+ )
for i in range(self.taskTableWidget.rowCount()):
item = self.taskTableWidget.item(i, 0)
fileName = item.text() if item.text() != item.data(1) else None
- addDownloadTask(item.data(1), fileName, str(path), self.customHeaders, "paused", self.blockNumCard.configItem.value)
+ addDownloadTask(
+ item.data(1),
+ fileName,
+ str(path),
+ self.customHeaders,
+ "paused",
+ self.blockNumCard.configItem.value,
+ )
self.close()
def __onDownloadFolderCardClicked(self):
- """ download folder card clicked slot """
- folder = QFileDialog.getExistingDirectory(
- self, self.tr("选择文件夹"), "./")
+ """download folder card clicked slot"""
+ folder = QFileDialog.getExistingDirectory(self, self.tr("选择文件夹"), "./")
if not folder or self.downloadFolderCard.contentLabel.text() == folder:
return
self.downloadFolderCard.setContent(folder)
def __onLinkTextChanged(self):
- if hasattr(self, '_timer'):
+ if hasattr(self, "_timer"):
self._timer.stop()
self._timer = QTimer()
@@ -249,7 +287,9 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
if self.taskTableWidget.item(i, 0).data(1) == url:
# 更新文件名和文件大小
self.taskTableWidget.item(i, 0).setText(fileName)
- self.taskTableWidget.item(i, 1).setText(getReadableSize(int(fileSize)))
+ self.taskTableWidget.item(i, 1).setText(
+ getReadableSize(int(fileSize))
+ )
return
# 如果不存在则添加新行
self.__addTableRowSignal.emit(fileName, str(fileSize), url)
@@ -257,11 +297,11 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
self.__gotWrong.emit(repr(e), index)
def __addTableRow(self, fileName: str, fileSize: str, url: str):
- """ add table row slot """
+ """add table row slot"""
self.taskTableWidget.insertRow(self.taskTableWidget.rowCount())
_ = QTableWidgetItem(fileName)
- _.setData(1, url) # 记录 Url
- _.setData(2, fileName) # 设置默认值, 当用户修改后的内容为空是,使用默认值替换
+ _.setData(1, url) # 记录 Url
+ _.setData(2, fileName) # 设置默认值, 当用户修改后的内容为空是,使用默认值替换
self.taskTableWidget.setItem(self.taskTableWidget.rowCount() - 1, 0, _)
_ = QTableWidgetItem(getReadableSize(int(fileSize)))
_.setFlags(Qt.ItemIsEnabled) # 禁止编辑
@@ -270,14 +310,14 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
# self.taskTableWidget.resizeColumnsToContents()
def __onTaskTableWidgetItemChanged(self, item: QTableWidgetItem):
- """ task table widget item changed slot """
- if item.text() == '':
+ """task table widget item changed slot"""
+ if item.text() == "":
item.setText(item.data(2))
def __progressTextChange(self):
- """ link text changed slot """
+ """link text changed slot"""
self.threads = []
-
+
self.yesButton.setEnabled(False)
text: list = self.linkTextEdit.toPlainText().split("\n")
@@ -285,7 +325,10 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
# 获取当前输入的URL列表
currentUrls = [url.strip() for url in text if url.strip()]
# 获取之前的URL列表
- previousUrls = [self.taskTableWidget.item(i, 0).data(1) for i in range(self.taskTableWidget.rowCount())]
+ previousUrls = [
+ self.taskTableWidget.item(i, 0).data(1)
+ for i in range(self.taskTableWidget.rowCount())
+ ]
# 找出新增、删除和修改的URL
addedUrls = set(currentUrls) - set(previousUrls)
@@ -313,17 +356,21 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
if url in addedUrls:
_ = urlRe.search(url)
if _:
- self.__addTableRow(url, "0", url) # 新增卡片并设置文件名和文件大小为“正在获取...”
- self.threads.append(Thread(target=self.__handleUrl, args=(url, index), daemon=True))
+ self.__addTableRow(
+ url, "0", url
+ ) # 新增卡片并设置文件名和文件大小为“正在获取...”
+ self.threads.append(
+ Thread(target=self.__handleUrl, args=(url, index), daemon=True)
+ )
else:
InfoBar.warning(
- title=self.tr('警告'),
+ title=self.tr("警告"),
content=self.tr("第{}个链接无效!").format(index),
orient=Qt.Horizontal,
isClosable=True,
position=InfoBarPosition.TOP,
duration=1000,
- parent=self.parent()
+ parent=self.parent(),
)
self.yesButton.setEnabled(True)
@@ -333,7 +380,7 @@ class AddTaskOptionDialog(MaskDialogBase, Ui_AddTaskOptionDialog):
thread.start()
Thread(target=self.__waitForThreads, daemon=True).start()
-
+
def __waitForThreads(self):
for thread in self.threads:
thread.join()
diff --git a/app/components/custom_mask_dialog_base.py b/app/components/custom_mask_dialog_base.py
index 2348270d..3d6527e3 100644
--- a/app/components/custom_mask_dialog_base.py
+++ b/app/components/custom_mask_dialog_base.py
@@ -1,13 +1,19 @@
# coding:utf-8
from PySide6.QtCore import QEasingCurve, QPropertyAnimation, Qt, QEvent
from PySide6.QtGui import QColor, QResizeEvent
-from PySide6.QtWidgets import (QDialog, QGraphicsDropShadowEffect,
- QGraphicsOpacityEffect, QHBoxLayout, QWidget, QFrame)
-from qfluentwidgets import isDarkTheme
+from PySide6.QtWidgets import (
+ QDialog,
+ QGraphicsDropShadowEffect,
+ QGraphicsOpacityEffect,
+ QHBoxLayout,
+ QWidget,
+ QFrame,
+)
+from qfluentwidgets import ScrollArea, isDarkTheme
class MaskDialogBase(QDialog):
- """ Dialog box base class with a mask """
+ """Dialog box base class with a mask"""
def __init__(self, parent=None):
super().__init__(parent=parent)
@@ -16,22 +22,25 @@ class MaskDialogBase(QDialog):
self.windowMask = QWidget(self)
# dialog box in the center of mask, all widgets take it as parent
- self.widget = QFrame(self, objectName='centerWidget')
+ self.widget = ScrollArea(self)
+ self.widget.setObjectName("centerWidget")
self.setWindowFlags(Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setGeometry(0, 0, parent.width(), parent.height())
c = 0 if isDarkTheme() else 255
self.windowMask.resize(self.size())
- self.windowMask.setStyleSheet(f'background:rgba({c}, {c}, {c}, 0.6)')
+ self.windowMask.setStyleSheet(f"background:rgba({c}, {c}, {c}, 0.6)")
self._hBoxLayout.addWidget(self.widget)
self.setShadowEffect()
self.window().installEventFilter(self)
self.windowMask.installEventFilter(self)
- def setShadowEffect(self, blurRadius=60, offset=(0, 10), color=QColor(0, 0, 0, 100)):
- """ add shadow to dialog """
+ def setShadowEffect(
+ self, blurRadius=60, offset=(0, 10), color=QColor(0, 0, 0, 100)
+ ):
+ """add shadow to dialog"""
shadowEffect = QGraphicsDropShadowEffect(self.widget)
shadowEffect.setBlurRadius(blurRadius)
shadowEffect.setOffset(*offset)
@@ -40,16 +49,18 @@ class MaskDialogBase(QDialog):
self.widget.setGraphicsEffect(shadowEffect)
def setMaskColor(self, color: QColor):
- """ set the color of mask """
- self.windowMask.setStyleSheet(f"""
+ """set the color of mask"""
+ self.windowMask.setStyleSheet(
+ f"""
background: rgba({color.red()}, {color.green()}, {color.blue()}, {color.alpha()})
- """)
+ """
+ )
def showEvent(self, e):
- """ fade in """
+ """fade in"""
opacityEffect = QGraphicsOpacityEffect(self)
self.setGraphicsEffect(opacityEffect)
- opacityAni = QPropertyAnimation(opacityEffect, b'opacity', self)
+ opacityAni = QPropertyAnimation(opacityEffect, b"opacity", self)
opacityAni.setStartValue(0)
opacityAni.setEndValue(1)
opacityAni.setDuration(200)
@@ -59,11 +70,11 @@ class MaskDialogBase(QDialog):
super().showEvent(e)
def done(self, code):
- """ fade out """
+ """fade out"""
self.widget.setGraphicsEffect(None)
opacityEffect = QGraphicsOpacityEffect(self)
self.setGraphicsEffect(opacityEffect)
- opacityAni = QPropertyAnimation(opacityEffect, b'opacity', self)
+ opacityAni = QPropertyAnimation(opacityEffect, b"opacity", self)
opacityAni.setStartValue(1)
opacityAni.setEndValue(0)
opacityAni.setDuration(100)
@@ -91,8 +102,11 @@ class MaskDialogBase(QDialog):
re = QResizeEvent(e)
self.resize(re.size())
elif obj is self.windowMask:
- if e.type() == QEvent.MouseButtonRelease and e.button() == Qt.LeftButton \
- and self.isClosableOnMaskClicked():
+ if (
+ e.type() == QEvent.MouseButtonRelease
+ and e.button() == Qt.LeftButton
+ and self.isClosableOnMaskClicked()
+ ):
self.reject()
return super().eventFilter(obj, e)