From 0607df0967067b539d04038bedccbf798b46d110 Mon Sep 17 00:00:00 2001 From: momen Date: Wed, 18 Jun 2025 21:14:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9B=B4=E6=AD=A3=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=90=8E=E5=86=8D=E6=AC=A1=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=97=B6=E9=87=8D=E6=96=B0=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownloadButton.jsx | 0 src/appdelegate.cpp | 7 +++++++ 2 files changed, 7 insertions(+) create mode 100644 DownloadButton.jsx diff --git a/DownloadButton.jsx b/DownloadButton.jsx new file mode 100644 index 0000000..e69de29 diff --git a/src/appdelegate.cpp b/src/appdelegate.cpp index 315dcdf..1a1c3e9 100644 --- a/src/appdelegate.cpp +++ b/src/appdelegate.cpp @@ -131,10 +131,12 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c painter->setPen(Qt::white); painter->drawText(buttonRect, Qt::AlignCenter, "已安装"); } else if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + // 下载完成,按钮绿色,样式不变 painter->setBrush(QColor("#10B981")); painter->drawRoundedRect(buttonRect, 4, 4); painter->setPen(Qt::white); painter->drawText(buttonRect, Qt::AlignCenter, "下载完成"); + // 不需要特殊处理样式,交互在 editorEvent 控制 } else { painter->setBrush(QColor("#e9effd")); painter->drawRoundedRect(buttonRect, 4, 4); @@ -168,6 +170,11 @@ bool AppDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, } else { QRect buttonRect(rect.right() - 80, rect.top() + (rect.height() - 30) / 2, 70, 30); if (buttonRect.contains(mouseEvent->pos())) { + // 判断是否为“下载完成”状态,如果是则不响应点击 + if (m_downloads.contains(packageName) && !m_downloads[packageName].isDownloading) { + // “下载完成”状态,按钮失效,点击无效 + return false; + } QString downloadUrl = index.data(Qt::UserRole + 7).toString(); QString outputPath = QString("%1/%2.metalink").arg(QDir::tempPath(), packageName);