QIcon::fromTheme(): add support for absolute paths.
This allows methods that return an icon name, to sometimes also return an icon full path (e.g. because the icon was dynamically generated and stored into a local cache on disk) Change-Id: Ib01c3955f4b64236463846241d9814b2d0686634 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
e8ed29d679
commit
bbc830ce3e
@ -51,6 +51,7 @@
|
||||
#include "qvariant.h"
|
||||
#include "qcache.h"
|
||||
#include "qdebug.h"
|
||||
#include "qdir.h"
|
||||
#include "qpalette.h"
|
||||
#include "qmath.h"
|
||||
|
||||
@ -1171,6 +1172,8 @@ QIcon QIcon::fromTheme(const QString &name)
|
||||
|
||||
if (qtIconCache()->contains(name)) {
|
||||
icon = *qtIconCache()->object(name);
|
||||
} else if (QDir::isAbsolutePath(name)) {
|
||||
return QIcon(name);
|
||||
} else {
|
||||
QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme();
|
||||
bool hasUserTheme = QIconLoader::instance()->hasUserTheme();
|
||||
|
@ -642,6 +642,10 @@ void tst_QIcon::fromTheme()
|
||||
QIcon::setThemeName("");
|
||||
abIcon = QIcon::fromTheme("address-book-new");
|
||||
QVERIFY(abIcon.isNull());
|
||||
|
||||
// Passing a full path to fromTheme is not very useful, but should work anyway
|
||||
QIcon fullPathIcon = QIcon::fromTheme(m_pngImageFileName);
|
||||
QVERIFY(!fullPathIcon.isNull());
|
||||
}
|
||||
|
||||
void tst_QIcon::fromThemeCache()
|
||||
|
Loading…
Reference in New Issue
Block a user