From d62da9416af057c9a4926ec5d2c3e6fd26a32985 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Sat, 4 Jan 2025 03:30:05 -0500 Subject: [PATCH] Update main.cpp to update Linux user's icon for AppImage deployments --- app/src/main.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/app/src/main.cpp b/app/src/main.cpp index d1b330eb..d09e4968 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -207,27 +207,23 @@ static void setupAppImageIcon(const QString &appExecutableName, const QString pixmapFile = pixmapPath + appExecutableName + ".png"; // clang-format on - // Check if the icon file already exists to avoid redundant copying - if (!QFileInfo::exists(pixmapFile)) + // Ensure the directory exists; create it if it doesn't + QDir dir; + if (!dir.exists(pixmapPath) && !dir.mkpath(pixmapPath)) + return; + + // Copy the icon from resources to the destination + QFile resourceFile(iconResourcePath); + if (resourceFile.open(QIODevice::ReadOnly)) { - // Ensure the directory exists; create it if it doesn't - QDir dir; - if (!dir.exists(pixmapPath) && !dir.mkpath(pixmapPath)) - return; - - // Copy the icon from resources to the destination - QFile resourceFile(iconResourcePath); - if (resourceFile.open(QIODevice::ReadOnly)) + QFile localFile(pixmapFile); + if (localFile.open(QIODevice::WriteOnly)) { - QFile localFile(pixmapFile); - if (localFile.open(QIODevice::WriteOnly)) - { - localFile.write(resourceFile.readAll()); - localFile.close(); - } - - resourceFile.close(); + localFile.write(resourceFile.readAll()); + localFile.close(); } + + resourceFile.close(); } } #endif