Commit 22b2c30a authored by Daniel Teske's avatar Daniel Teske

Android: Fix setting of icon

Task-number: QTCREATORBUG-9014
Change-Id: Ib155b09f5c57101cbacce1c2e9981a7d5b6be731
Reviewed-by: default avatarEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 616c55a2
......@@ -223,6 +223,16 @@ bool AndroidManager::setVersionName(ProjectExplorer::Target *target, const QStri
return saveManifest(target, doc);
}
bool AndroidManager::ensureIconAttribute(ProjectExplorer::Target *target)
{
QDomDocument doc;
if (!openManifest(target, doc))
return false;
QDomElement applicationElem = doc.documentElement().firstChildElement(QLatin1String("application"));
applicationElem.setAttribute(QLatin1String("android:icon"), QLatin1String("@drawable/icon"));
return saveManifest(target, doc);
}
QString AndroidManager::targetSDK(ProjectExplorer::Target *target)
{
if (!createAndroidTemplatesIfNecessary(target))
......@@ -251,7 +261,8 @@ QIcon AndroidManager::highDpiIcon(ProjectExplorer::Target *target)
bool AndroidManager::setHighDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath)
{
return setIcon(target, HighDPI, iconFilePath);
return ensureIconAttribute(target) &&
setIcon(target, HighDPI, iconFilePath);
}
QIcon AndroidManager::mediumDpiIcon(ProjectExplorer::Target *target)
......@@ -261,7 +272,8 @@ QIcon AndroidManager::mediumDpiIcon(ProjectExplorer::Target *target)
bool AndroidManager::setMediumDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath)
{
return setIcon(target, MediumDPI, iconFilePath);
return ensureIconAttribute(target) &&
setIcon(target, MediumDPI, iconFilePath);
}
QIcon AndroidManager::lowDpiIcon(ProjectExplorer::Target *target)
......@@ -271,7 +283,8 @@ QIcon AndroidManager::lowDpiIcon(ProjectExplorer::Target *target)
bool AndroidManager::setLowDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath)
{
return setIcon(target, LowDPI, iconFilePath);
return ensureIconAttribute(target) &&
setIcon(target, LowDPI, iconFilePath);
}
Utils::FileName AndroidManager::dirPath(ProjectExplorer::Target *target)
......@@ -957,6 +970,8 @@ bool AndroidManager::setIcon(ProjectExplorer::Target *target, IconType type, con
const QString path = iconPath(target, type);
QFile::remove(path);
QDir dir;
dir.mkpath(QFileInfo(path).absolutePath());
return QFile::copy(iconFileName, path);
}
......
......@@ -78,6 +78,7 @@ public:
static bool setMediumDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath);
static QIcon lowDpiIcon(ProjectExplorer::Target *target);
static bool setLowDpiIcon(ProjectExplorer::Target *target, const QString &iconFilePath);
static bool ensureIconAttribute(ProjectExplorer::Target *target);
static QStringList availableTargetApplications(ProjectExplorer::Target *target);
static QString targetApplication(ProjectExplorer::Target *target);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment