From 32e13486a3694a9c5758c6b3c24420afb2ec0b97 Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Fri, 22 Mar 2024 22:02:07 +1100 Subject: [PATCH] Make Android icon directory if it does not exist --- .../androidplatformicongenerator.cpp | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/cntp-appicontool/platformgenerators/androidplatformicongenerator.cpp b/cntp-appicontool/platformgenerators/androidplatformicongenerator.cpp index 508acf4..1bf429a 100644 --- a/cntp-appicontool/platformgenerators/androidplatformicongenerator.cpp +++ b/cntp-appicontool/platformgenerators/androidplatformicongenerator.cpp @@ -27,11 +27,24 @@ void AndroidPlatformIconGenerator::generateIcon() { QDir androidDir(outputFile()); QDir resDir(androidDir.absoluteFilePath("res")); + QMap icons = { + {"drawable-ldpi/icon.png", 0.75}, + {"drawable-mdpi/icon.png", 1 }, + {"drawable-hdpi/icon.png", 1.5 }, + {"drawable-xhdpi/icon.png", 2 }, + {"drawable-xxhdpi/icon.png", 3 }, + {"drawable-xxxhdpi/icon.png", 4 } + }; + QSizeF baseline{48, 48}; - renderPng(resDir.absoluteFilePath("drawable-ldpi/icon.png"), baseline * 0.75); - renderPng(resDir.absoluteFilePath("drawable-mdpi/icon.png"), baseline * 1); - renderPng(resDir.absoluteFilePath("drawable-hdpi/icon.png"), baseline * 1.5); - renderPng(resDir.absoluteFilePath("drawable-xhdpi/icon.png"), baseline * 2); - renderPng(resDir.absoluteFilePath("drawable-xxhdpi/icon.png"), baseline * 3); - renderPng(resDir.absoluteFilePath("drawable-xxxhdpi/icon.png"), baseline * 4); + + for (auto i = icons.constBegin(); i != icons.constEnd(); ++i) { + QFileInfo fileInfo(resDir.absoluteFilePath(i.key())); + + if (!fileInfo.dir().exists()) { + QDir::root().mkpath(fileInfo.dir().absolutePath()); + } + + renderPng(fileInfo.fileName(), baseline * i.value()); + } }