mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
Fix dock app icon is empty or size error
Change-Id: Ifb6a383ffcb11cc67c87e83cf952df124b4af452
This commit is contained in:
parent
90e102335b
commit
26f189d5a8
Notes:
Deepin Code Review
2017-02-21 15:00:01 +08:00
Code-Review+1: Felix Yan <yanran@deepin.com> Code-Review+2: 石博文 <sbw@sbw.so> Verified+1: Anonymous Coward #1000004 Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 21 Feb 2017 14:59:56 +0800 Reviewed-on: https://cr.deepin.io/20494 Project: dde/dde-dock Branch: refs/heads/master
@ -14,27 +14,41 @@ ThemeAppIcon::~ThemeAppIcon()
|
||||
|
||||
}
|
||||
|
||||
QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size)
|
||||
const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size)
|
||||
{
|
||||
QPixmap pixmap(size, size);
|
||||
QPixmap pixmap;
|
||||
|
||||
do {
|
||||
|
||||
if (iconName.startsWith("data:image/"))
|
||||
{
|
||||
const QStringList strs = iconName.split("base64,");
|
||||
if (strs.size() == 2)
|
||||
pixmap.loadFromData(QByteArray::fromBase64(strs.at(1).toLatin1()));
|
||||
|
||||
if (!pixmap.isNull())
|
||||
break;
|
||||
}
|
||||
|
||||
if (QFile::exists(iconName))
|
||||
{
|
||||
pixmap = QPixmap(iconName);
|
||||
if (!pixmap.isNull())
|
||||
break;
|
||||
}
|
||||
|
||||
if (QFile::exists(iconName)) {
|
||||
pixmap = QPixmap(iconName);
|
||||
if (!pixmap.isNull())
|
||||
return pixmap;
|
||||
}
|
||||
if (iconName.startsWith("data:image/"))
|
||||
{
|
||||
const QStringList strs = iconName.split("base64,");
|
||||
if (strs.size() == 2)
|
||||
pixmap.loadFromData(QByteArray::fromBase64(strs.at(1).toLatin1()));
|
||||
} else {
|
||||
const QIcon icon = QIcon::fromTheme(iconName, QIcon::fromTheme("application-x-desktop"));
|
||||
pixmap = icon.pixmap(QSize(size, size));
|
||||
}
|
||||
if (!pixmap.isNull())
|
||||
break;
|
||||
|
||||
if (pixmap.isNull())
|
||||
pixmap = QPixmap(":/icons/resources/application-x-desktop.svg");
|
||||
if (!pixmap.isNull())
|
||||
break;
|
||||
|
||||
Q_UNREACHABLE();
|
||||
|
||||
} while (false);
|
||||
|
||||
return pixmap.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
explicit ThemeAppIcon(QObject *parent = 0);
|
||||
~ThemeAppIcon();
|
||||
|
||||
static QPixmap getIcon(const QString iconName, const int size);
|
||||
static const QPixmap getIcon(const QString iconName, const int size);
|
||||
};
|
||||
|
||||
#endif // THEMEAPPICON_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user