Skip to content

Commit

Permalink
Use AppStream id for autostart desktop filename and icon
Browse files Browse the repository at this point in the history
  • Loading branch information
redtide committed Jan 7, 2024
1 parent f686392 commit 5ff5c09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
3 changes: 2 additions & 1 deletion src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/qtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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())
Expand Down

0 comments on commit 5ff5c09

Please sign in to comment.