Skip to content

Commit

Permalink
优化 TaskCard UI
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoYouChR committed Dec 1, 2024
1 parent 1e0795d commit 5bcb957
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
37 changes: 20 additions & 17 deletions app/components/Ui_TaskCard.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ class Ui_TaskCard(object):
def setupUi(self, TaskCard):
if not TaskCard.objectName():
TaskCard.setObjectName(u"TaskCard")
TaskCard.resize(793, 119)
TaskCard.setMinimumSize(QSize(793, 119))
TaskCard.setMaximumSize(QSize(16777215, 119))
TaskCard.resize(793, 100)
TaskCard.setMinimumSize(QSize(793, 90))
TaskCard.setMaximumSize(QSize(16777215, 90))
self.cardHorizontalLayout = QHBoxLayout(TaskCard)
self.cardHorizontalLayout.setObjectName(u"cardHorizontalLayout")
self.cardHorizontalLayout.setContentsMargins(18, 8, 18, 8)
self.cardHorizontalLayout.setSpacing(18)
self.LogoPixmapLabel = PixmapLabel(TaskCard)
self.LogoPixmapLabel.setObjectName(u"LogoPixmapLabel")
self.LogoPixmapLabel.setMinimumSize(QSize(91, 91))
self.LogoPixmapLabel.setMaximumSize(QSize(91, 91))
self.LogoPixmapLabel.setMinimumSize(QSize(70, 70))
self.LogoPixmapLabel.setMaximumSize(QSize(70, 70))
self.LogoPixmapLabel.setScaledContents(True)
self.LogoPixmapLabel.setAlignment(Qt.AlignCenter)

Expand All @@ -37,6 +39,17 @@ def setupUi(self, TaskCard):
self.verticalLayout = QVBoxLayout()
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName(u"verticalLayout")

self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setSpacing(6)

# self.verticalLayout.addSpacing(15) # 把整体往下撑

self.verticalLayout_2 = QVBoxLayout()
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName(u"verticalLayout_2")

self.TitleLabel = TitleLabel(TaskCard)
self.TitleLabel.setObjectName(u"TitleLabel")
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
Expand All @@ -47,20 +60,10 @@ def setupUi(self, TaskCard):
self.TitleLabel.setMinimumSize(QSize(0, 38))
self.TitleLabel.setMaximumSize(QSize(16777215, 38))

self.verticalLayout.addWidget(self.TitleLabel)

self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalLayout.setSpacing(6)

self.verticalLayout.addSpacing(15) # 把整体往下撑
self.verticalLayout_2.addWidget(self.TitleLabel)

# 还需要把 statusHorizonLayout 在 horizonLayout 里面往下撑, 要不然非常难看!
self.verticalLayout_2 = QVBoxLayout()
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName(u"verticalLayout_2")

self.verticalLayout_2.addSpacing(15)
self.verticalLayout_2.addSpacing(8)

self.statusHorizonLayout = QHBoxLayout()
self.statusHorizonLayout.setObjectName(u"statusHorizonLayout")
Expand Down
10 changes: 5 additions & 5 deletions app/components/task_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, url, path, maxBlockNum: int, name: str = None, status: str =
self.TitleLabel.setText("正在初始化任务...")

self.LogoPixmapLabel.setPixmap(QPixmap(":/image/logo.png"))
self.LogoPixmapLabel.setFixedSize(91, 91)
self.LogoPixmapLabel.setFixedSize(70, 70)

self.progressBar = TaskProgressBar(maxBlockNum, self)
self.progressBar.setObjectName(u"progressBar")
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(self, url, path, maxBlockNum: int, name: str = None, status: str =

self.TitleLabel.setText(self.fileName)
self.LogoPixmapLabel.setPixmap(pixmap)
self.LogoPixmapLabel.setFixedSize(91, 91)
self.LogoPixmapLabel.setFixedSize(70, 70)

self.__onTaskFinished()

Expand Down Expand Up @@ -110,7 +110,7 @@ def __onTaskInited(self):
self.autoCreated = True

# TODO 因为Windows会返回已经处理过的只有左上角一点点的图像,所以需要超分辨率触发条件
# _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(48, 48).scaled(91, 91, aspectMode=Qt.AspectRatioMode.KeepAspectRatio,
# _ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(48, 48).scaled(70, 70, aspectMode=Qt.AspectRatioMode.KeepAspectRatio,
# mode=Qt.TransformationMode.SmoothTransformation) # 自动获取图标
_ = QFileIconProvider().icon(QFileInfo(f"{self.filePath}/{self.fileName}")).pixmap(128, 128) # 自动获取图标

Expand All @@ -122,7 +122,7 @@ def __onTaskInited(self):
# 显示信息
self.TitleLabel.setText(self.fileName)
self.LogoPixmapLabel.setPixmap(pixmap)
self.LogoPixmapLabel.setFixedSize(91, 91)
self.LogoPixmapLabel.setFixedSize(70, 70)

self.pauseButton.setEnabled(True)
# self.processLabel.setText(f"0B/{getReadableSize(self.task.fileSize)}")
Expand Down Expand Up @@ -318,7 +318,7 @@ def __onTaskFinished(self):
else:
_ = QPixmap(":/image/logo.png")
self.LogoPixmapLabel.setPixmap(_)
self.LogoPixmapLabel.setFixedSize(91, 91)
self.LogoPixmapLabel.setFixedSize(70, 70)

self.status = "finished"

Expand Down

0 comments on commit 5bcb957

Please sign in to comment.