fix(libsearch):解决加载svg(绝对路径的图片)图标失败的问题
This commit is contained in:
parent
7d36be89d9
commit
cf9e768b4b
|
@ -22,12 +22,21 @@
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <XdgIcon>
|
#include <XdgIcon>
|
||||||
|
#include <QFile>
|
||||||
namespace UkuiSearch {
|
namespace UkuiSearch {
|
||||||
static QMutex qtIconMutex;
|
static QMutex qtIconMutex;
|
||||||
static QMutex xdgIconMutex;
|
static QMutex xdgIconMutex;
|
||||||
QIcon IconLoader::loadIconQt(const QString &name, const QIcon &fallback)
|
QIcon IconLoader::loadIconQt(const QString &name, const QIcon &fallback)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&qtIconMutex);
|
QMutexLocker locker(&qtIconMutex);
|
||||||
|
if(QFile::exists(name)) {
|
||||||
|
QIcon icon(name);
|
||||||
|
if(!QIcon(name).isNull()) {
|
||||||
|
return icon;
|
||||||
|
} else {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
return QIcon::fromTheme(name,fallback);
|
return QIcon::fromTheme(name,fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue