From 5ff5c09c95926c0032fdb737d8d4c45b13459b8e Mon Sep 17 00:00:00 2001 From: redtide Date: Sun, 7 Jan 2024 21:16:13 +0100 Subject: [PATCH] Use AppStream id for autostart desktop filename and icon --- CMakeLists.txt | 5 +++-- src/application.cpp | 3 ++- src/qtilities.hpp | 6 ++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af6feb5..8bee747 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,8 +89,9 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE ORGANIZATION_DOMAIN="${PROJECT_ORGANIZATION_URL}" PROJECT_ID="${PROJECT_ID}" PROJECT_DATA_DIR="${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_ID}" - PROJECT_ICON_NAME="${PROJECT_ICON_FILE_NAME}" - PROJECT_ICON_SYSTEM_PATH="${PROJECT_ICON_FILE_PATH}/${PROJECT_ICON_FILE_NAME}" + PROJECT_APPSTREAM_ID="${PROJECT_APPSTREAM_ID}" + PROJECT_ICON_FORMAT="${PROJECT_ICON_FORMAT}" + PROJECT_ICON_SYSTEM_PATH="${PROJECT_ICON_FILE_PATH}/${PROJECT_APPSTREAM_ID}.${PROJECT_ICON_FORMAT}" PROJECT_TRANSLATION_TEST="${PROJECT_TRANSLATION_TEST}" PROJECT_TRANSLATION_TEST_ENABLED=${PROJECT_TRANSLATION_TEST_ENABLED} ) diff --git a/src/application.cpp b/src/application.cpp index 4ad162a..354d485 100755 --- a/src/application.cpp +++ b/src/application.cpp @@ -90,7 +90,8 @@ void Qtilities::Application::initUi() settings_.load(); QString icoLocalPath - = QCoreApplication::applicationDirPath() + '/' + QStringLiteral(PROJECT_ICON_NAME); + = QCoreApplication::applicationDirPath() + '/' + + QStringLiteral(PROJECT_APPSTREAM_ID) + '.' + QStringLiteral(PROJECT_ICON_FORMAT); QString icoSysPath = QStringLiteral(PROJECT_ICON_SYSTEM_PATH); // Try first to find the app icon in the current/build directory diff --git a/src/qtilities.hpp b/src/qtilities.hpp index 9d797b5..e4a5532 100644 --- a/src/qtilities.hpp +++ b/src/qtilities.hpp @@ -49,7 +49,7 @@ static void createAutostartFile() { QDir configDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); QString appName = QApplication::applicationName(); - QString filePath = configDir.filePath("autostart/" + appName + ".desktop"); + QString filePath = configDir.filePath("autostart/" + QStringLiteral(PROJECT_APPSTREAM_ID) + ".desktop"); QFile file(filePath); if (file.exists() || !file.open(QIODevice::WriteOnly | QIODevice::Text)) @@ -61,12 +61,14 @@ static void createAutostartFile() out << "Type=Application\n"; out << "Exec=" + appName + "\n"; out << "Terminal=false\n"; + out << "Icon=" << PROJECT_APPSTREAM_ID << '\n'; } static void deleteAutostartFile() { QDir configDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); - QString filePath(configDir.filePath("autostart/" + QApplication::applicationName() + ".desktop")); +// QString filePath(configDir.filePath("autostart/" + QApplication::applicationName() + ".desktop")); + QString filePath(configDir.filePath("autostart/" + QStringLiteral(PROJECT_APPSTREAM_ID) + ".desktop")); QFile file(filePath); if (!file.exists())