update:修复调用默认svg出错

This commit is contained in:
2025-11-10 10:55:44 +08:00
parent 1b722e78a5
commit c3cd29bb66
3 changed files with 5 additions and 4 deletions

View File

@@ -94,7 +94,7 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
QString finalIconPath = iconPath;
qDebug() << "原始图标路径:" << iconPath;
if (iconPath.isEmpty() || !QFile::exists(iconPath)) {
finalIconPath = ":/resources/default_icon.svg";
finalIconPath = ":/resources/default_icon.png";
qDebug() << "图标文件不存在,使用默认图标:" << finalIconPath;
} else {
qDebug() << "使用图标文件:" << finalIconPath;
@@ -103,7 +103,7 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
// 额外检查资源文件是否存在
if (finalIconPath.startsWith(":/") && QIcon(finalIconPath).isNull()) {
qDebug() << "资源图标无法加载,使用备用默认图标";
finalIconPath = ":/resources/default_icon.svg";
finalIconPath = ":/resources/default_icon.png";
}
// 如果是忽略状态,绘制灰色图标

View File

@@ -241,7 +241,7 @@ QStringList aptssUpdater::getPackageIcons()
QProcess dpkgProcess; // 在循环内部创建新的QProcess实例
QString packageName = package.split(":")[0];
QString iconPath = ":/resources/default_icon.svg"; // 默认图标
QString iconPath = ":/resources/default_icon.png"; // 默认图标
// 获取包文件列表
dpkgProcess.start("dpkg", QStringList() << "-L" << packageName);
@@ -298,7 +298,7 @@ QStringList aptssUpdater::getPackageIcons()
}
// 如果.desktop中没有找到图标尝试直接查找包中的图标文件
if (iconPath == ":/resources/default_icon.svg") {
if (iconPath == ":/resources/default_icon.png") {
qDebug() << "未在.desktop文件中找到图标尝试直接查找包中的图标文件";
QStringList iconFiles = files.filter(QRegularExpression("/(usr/share/pixmaps|usr/share/icons|opt/apps/.*/entries/icons)/.*\\.(png|svg)$"));
if (!iconFiles.isEmpty()) {

View File

@@ -4,5 +4,6 @@
<file>../resources/default_icon.svg</file>
<file>../resources/spark-update-tool.svg</file>
<file>../resources/128*128/spark-update-tool.png</file>
<file>../resources/default_icon.png</file>
</qresource>
</RCC>