diff --git a/config-kmymoney.h.cmake b/config-kmymoney.h.cmake --- a/config-kmymoney.h.cmake +++ b/config-kmymoney.h.cmake @@ -20,3 +20,5 @@ #cmakedefine ENABLE_SQLCIPHER 1 #cmakedefine ENABLE_GPG 1 + +#cmakedefine IS_APPIMAGE 1 diff --git a/kmymoney/kmymoney.cpp b/kmymoney/kmymoney.cpp --- a/kmymoney/kmymoney.cpp +++ b/kmymoney/kmymoney.cpp @@ -1160,21 +1160,34 @@ layout->setSpacing(6); { +#ifndef IS_APPIMAGE // find where our custom icons were installed based on an custom icon that we know should exist after installation const auto customIconRelativePath = QString(QStringLiteral("icons/hicolor/16x16/actions/account-add.png")); auto customIconAbsolutePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, customIconRelativePath); + if (customIconAbsolutePath.isEmpty()) { + qWarning("Custom icons were not found in any of the following QStandardPaths::AppDataLocation:"); + for (const auto &standardPath : QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)) + qWarning() << standardPath; + } +#else + // according to https://docs.appimage.org/packaging-guide/ingredients.html#open-source-applications + // QStandardPaths::AppDataLocation is unreliable on AppImages, so apply workaround here in case we fail to find icons + const auto appImageAppDataLocation = QCoreApplication::applicationDirPath() + QLatin1String("/../share/kmymoney/") + customIconRelativePath; + if (QFile::exists(appImageAppDataLocation )) { + customIconAbsolutePath = appImageAppDataLocation ; + } else { + qWarning("Custom icons were not found in the following location:"); + qWarning() << appImageAppDataLocation ; + } +#endif // add our custom icons path to icons search path if (!customIconAbsolutePath.isEmpty()) { customIconAbsolutePath.chop(customIconRelativePath.length()); customIconAbsolutePath.append(QLatin1String("icons")); auto paths = QIcon::themeSearchPaths(); paths.append(customIconAbsolutePath); QIcon::setThemeSearchPaths(paths); - } else { - qWarning("Custom icons were not found in any of the following QStandardPaths::AppDataLocation:"); - for (const auto &standardPath : QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)) - qWarning() << standardPath; } #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) @@ -2921,9 +2934,21 @@ void KMyMoneyApp::Private::setThemedCSS() { const QStringList CSSnames {QStringLiteral("kmymoney.css"), QStringLiteral("welcome.css")}; - const QString rcDir("/html/"); - const QStringList defaultCSSDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, rcDir, QStandardPaths::LocateDirectory); + QStringList defaultCSSDirs; +#ifndef IS_APPIMAGE + defaultCSSDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, rcDir, QStandardPaths::LocateDirectory); +#else + // according to https://docs.appimage.org/packaging-guide/ingredients.html#open-source-applications + // QStandardPaths::AppDataLocation is unreliable on AppImages, so apply workaround here in case we fail to find icons + const auto appImageAppDataLocation = QCoreApplication::applicationDirPath() + QLatin1String("/../share/kmymoney") + rcDir; + if (QFile::exists(appImageAppDataLocation + CSSnames.first())) { + defaultCSSDirs.append(appImageAppDataLocation); + } else { + qWarning("CSS file was not found in the following location:"); + qWarning() << appImageAppDataLocation; + } +#endif // scan the list of directories to find the ones that really // contains all files we look for diff --git a/packaging/linux/appimage/build-image.sh b/packaging/linux/appimage/build-image.sh --- a/packaging/linux/appimage/build-image.sh +++ b/packaging/linux/appimage/build-image.sh @@ -49,18 +49,22 @@ mv $APPDIR/usr/lib/x86_64-linux-gnu/* $APPDIR/usr/lib rm -rf $APPDIR/usr/lib/x86_64-linux-gnu/ -# Step 3: Update the rpath in the various plugins we have to make sure they'll be loadable in an Appimage context -for lib in $PLUGINS/*.so*; do +# Step 3: Move plugins to loadable location +mv $PLUGINS $APPDIR/usr/plugins + +# Step 4: Update the rpath in the various plugins we have to make sure they'll be loadable in an Appimage context +for lib in $APPDIR/usr/plugins/kmymoney/*.so*; do patchelf --set-rpath '$ORIGIN/..' $lib; done -# Step 4: Build the image!!! +# Step 5: Build the image!!! linuxdeployqt $APPDIR/usr/share/applications/org.kde.kmymoney.desktop \ -executable=$APPDIR/usr/bin/kmymoney \ -qmldir=$DEPS_INSTALL_PREFIX/qml \ -verbose=2 \ -bundle-non-qt-libs \ - -appimage + -appimage \ + -exclude-libs=libnss3.so,libnssutil3.so # Step 5: Find out what version of KMyMoney we built and give the Appimage a proper name cd $BUILD_PREFIX/kmymoney-build diff --git a/packaging/linux/appimage/build-kmymoney.sh b/packaging/linux/appimage/build-kmymoney.sh --- a/packaging/linux/appimage/build-kmymoney.sh +++ b/packaging/linux/appimage/build-kmymoney.sh @@ -40,18 +40,7 @@ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING=FALSE \ -DENABLE_WEBENGINE=TRUE \ - -DENABLE_SQLCIPHER=FALSE \ - -DENABLE_SQLSTORAGE=FALSE \ - -DENABLE_KBANKING=FALSE \ - -DENABLE_ONLINEJOBOUTBOXVIEW=FALSE \ - -DENABLE_OFXIMPORTER=FALSE \ - -DENABLE_ADDRESSBOOK=FALSE \ - -DENABLE_HOLIDAYS=FALSE \ - -DENABLE_ACTIVITIES=FALSE \ - -DENABLE_FORECASTVIEW=FALSE \ - -DENABLE_REPORTSVIEW=FALSE \ - -DENABLE_BUDGETVIEW=FALSE \ - -DENABLE_GPG=FALSE + -DIS_APPIMAGE=TRUE # Build and Install KMyMoney (ready for the next phase) make -j$CPU_COUNT install