mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 21:32:05 +08:00
update:修复调用默认svg出错
This commit is contained in:
@@ -94,7 +94,7 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
|
|||||||
QString finalIconPath = iconPath;
|
QString finalIconPath = iconPath;
|
||||||
qDebug() << "原始图标路径:" << iconPath;
|
qDebug() << "原始图标路径:" << iconPath;
|
||||||
if (iconPath.isEmpty() || !QFile::exists(iconPath)) {
|
if (iconPath.isEmpty() || !QFile::exists(iconPath)) {
|
||||||
finalIconPath = ":/resources/default_icon.svg";
|
finalIconPath = ":/resources/default_icon.png";
|
||||||
qDebug() << "图标文件不存在,使用默认图标:" << finalIconPath;
|
qDebug() << "图标文件不存在,使用默认图标:" << finalIconPath;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "使用图标文件:" << finalIconPath;
|
qDebug() << "使用图标文件:" << finalIconPath;
|
||||||
@@ -103,7 +103,7 @@ void AppDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, c
|
|||||||
// 额外检查资源文件是否存在
|
// 额外检查资源文件是否存在
|
||||||
if (finalIconPath.startsWith(":/") && QIcon(finalIconPath).isNull()) {
|
if (finalIconPath.startsWith(":/") && QIcon(finalIconPath).isNull()) {
|
||||||
qDebug() << "资源图标无法加载,使用备用默认图标";
|
qDebug() << "资源图标无法加载,使用备用默认图标";
|
||||||
finalIconPath = ":/resources/default_icon.svg";
|
finalIconPath = ":/resources/default_icon.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果是忽略状态,绘制灰色图标
|
// 如果是忽略状态,绘制灰色图标
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ QStringList aptssUpdater::getPackageIcons()
|
|||||||
QProcess dpkgProcess; // 在循环内部创建新的QProcess实例
|
QProcess dpkgProcess; // 在循环内部创建新的QProcess实例
|
||||||
|
|
||||||
QString packageName = package.split(":")[0];
|
QString packageName = package.split(":")[0];
|
||||||
QString iconPath = ":/resources/default_icon.svg"; // 默认图标
|
QString iconPath = ":/resources/default_icon.png"; // 默认图标
|
||||||
|
|
||||||
// 获取包文件列表
|
// 获取包文件列表
|
||||||
dpkgProcess.start("dpkg", QStringList() << "-L" << packageName);
|
dpkgProcess.start("dpkg", QStringList() << "-L" << packageName);
|
||||||
@@ -298,7 +298,7 @@ QStringList aptssUpdater::getPackageIcons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果.desktop中没有找到图标,尝试直接查找包中的图标文件
|
// 如果.desktop中没有找到图标,尝试直接查找包中的图标文件
|
||||||
if (iconPath == ":/resources/default_icon.svg") {
|
if (iconPath == ":/resources/default_icon.png") {
|
||||||
qDebug() << "未在.desktop文件中找到图标,尝试直接查找包中的图标文件";
|
qDebug() << "未在.desktop文件中找到图标,尝试直接查找包中的图标文件";
|
||||||
QStringList iconFiles = files.filter(QRegularExpression("/(usr/share/pixmaps|usr/share/icons|opt/apps/.*/entries/icons)/.*\\.(png|svg)$"));
|
QStringList iconFiles = files.filter(QRegularExpression("/(usr/share/pixmaps|usr/share/icons|opt/apps/.*/entries/icons)/.*\\.(png|svg)$"));
|
||||||
if (!iconFiles.isEmpty()) {
|
if (!iconFiles.isEmpty()) {
|
||||||
|
|||||||
@@ -4,5 +4,6 @@
|
|||||||
<file>../resources/default_icon.svg</file>
|
<file>../resources/default_icon.svg</file>
|
||||||
<file>../resources/spark-update-tool.svg</file>
|
<file>../resources/spark-update-tool.svg</file>
|
||||||
<file>../resources/128*128/spark-update-tool.png</file>
|
<file>../resources/128*128/spark-update-tool.png</file>
|
||||||
|
<file>../resources/default_icon.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Reference in New Issue
Block a user