From c972177a4dffd339781cb1329fbc10d2fad3ce4a Mon Sep 17 00:00:00 2001 From: Jan Blackquill Date: Thu, 20 Jan 2022 23:59:06 -0500 Subject: [PATCH] feat: bundle icons on android --- app/App.qbs | 13 +++++++++++++ app/main.cpp | 9 +++++++++ app/setup.cpp | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/app/App.qbs b/app/App.qbs index 25fdcdd..529eab2 100644 --- a/app/App.qbs +++ b/app/App.qbs @@ -1,3 +1,5 @@ +import qbs.FileInfo + QtApplication { name: "Challah" @@ -8,14 +10,25 @@ QtApplication { cpp.enableExceptions: true cpp.enableReproducibleBuilds: true cpp.enableRtti: true + cpp.defines: iconsDir.length > 0 ? ["CHALLAH_BUNDLED_ICONS=1"] : [] debugInformationInstallDir: "bin" installDebugInformation: true + property string iconsDir: "" + files: [ "main.cpp", ] + Group { + condition: product.iconsDir.length > 0 + files: [product.iconsDir] + fileTags: "qt.core.resource_data" + Qt.core.resourceSourceBase: product.iconsDir.slice(0, -FileInfo.baseName(product.iconsDir).length) + Qt.core.resourcePrefix: "/" + } + Group { files: ["resources/**"] excludeFiles: ["resources/img/io.harmonyapp.Challah.svg"] diff --git a/app/main.cpp b/app/main.cpp index e487537..45c3a8f 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef Q_OS_ANDROID @@ -50,6 +51,14 @@ int main(int argc, char *argv[]) #if defined(Q_OS_ANDROID) QQuickStyle::setStyle(QStringLiteral("Material")); #endif +#if defined(CHALLAH_BUNDLED_ICONS) + if (!QResource::registerResource(":/breeze-icons.rcc", "/icons/bundled-breeze")) { + qWarning() << "failed to register icons resource!"; + } else { + qDebug() << "registered icons resource!"; + } + QIcon::setThemeName("bundled-breeze"); +#endif QQmlApplicationEngine engine; setupQML(&engine); diff --git a/app/setup.cpp b/app/setup.cpp index 87d52e1..4ee02f9 100644 --- a/app/setup.cpp +++ b/app/setup.cpp @@ -57,6 +57,8 @@ Q_IMPORT_PLUGIN(QQC2BreezeStylePlugin) #endif +#include + Q_DECLARE_METATYPE(Future) Q_DECLARE_METATYPE(Future) Q_DECLARE_METATYPE(Future) @@ -82,6 +84,9 @@ void setupQML(QQmlEngine* engine) Q_INIT_RESOURCE(kitemmodelsqml); #endif + QSvgRenderer rend; + (void) rend; + qRegisterMetaType(); qRegisterMetaType();