From dfb8f9a160622b77775b98c93aaacb29d2621f05 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 9 Feb 2022 23:46:49 +0100 Subject: [PATCH] Fix application name on Wayland in flatpak fixes #903 --- CMakeLists.txt | 4 ++++ io.github.NhekoReborn.Nheko.yaml | 1 + src/main.cpp | 9 +++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ee7b972..f4706a2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ if(UNIX AND NOT APPLE) else() option(MAN "Build man page" OFF) endif() +option(FLATPAK "Set this only if Nheko is built as a flatpak" OFF) set( CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/toolchain.cmake" @@ -637,6 +638,9 @@ elseif(WIN32) endif() else() target_link_libraries (nheko PRIVATE Qt5::DBus) + if (FLATPAK) + target_compile_definitions(nheko PRIVATE NHEKO_FLATPAK) + endif() endif() target_include_directories(nheko PRIVATE src includes third_party/blurhash third_party/cpp-httplib-0.5.12) diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 57140108..dec13987 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -200,6 +200,7 @@ modules: - -DLMDBXX_INCLUDE_DIR=.deps/lmdbxx - -DCOMPILE_QML=ON - -DMAN=OFF + - -DFLATPAK=ON buildsystem: cmake-ninja name: nheko sources: diff --git a/src/main.cpp b/src/main.cpp index 24fc8415..47ebba27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -231,10 +231,11 @@ main(int argc, char *argv[]) #if !defined(Q_OS_MAC) app.setWindowIcon(QIcon::fromTheme(QStringLiteral("nheko"), QIcon{":/logos/nheko.png"})); #endif - if (userdata.isEmpty() || userdata == QLatin1String("default")) - app.setDesktopFileName(QStringLiteral("nheko")); - else - app.setDesktopFileName("nheko[" + userdata + "]"); +#ifdef NHEKO_FLATPAK + app.setDesktopFileName(QStringLiteral("io.github.NhekoReborn.Nheko")); +#else + app.setDesktopFileName(QStringLiteral("nheko")); +#endif http::init();