From 67042f2836c2d33dd32d813e68f91763a53a3c29 Mon Sep 17 00:00:00 2001 From: El Thoro Date: Sun, 22 Jun 2025 19:32:02 +0200 Subject: [PATCH] Enable Singleapplication again (#4030) * Enable SingleApplication again (compile flag; enabled by default) * Enable SingleApplication again (compile flag; enabled by default) * Cleanup: Removed /external/ subfolder --- CMakeLists.txt | 17 +++++------------ src/CMakeLists.txt | 24 +++++++++--------------- src/main.cpp | 14 ++++++-------- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c9d86b8..d152d6c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,7 +91,7 @@ set(RUN_IN_PLACE option(FLAMESHOT_DEBUG_CAPTURE "Enable mode to make debugging easier" OFF) option(USE_MONOCHROME_ICON "Build using monochrome icon as default" OFF) option(GENERATE_TS "Regenerate translation source files" OFF) -option(USE_EXTERNAL_SINGLEAPPLICATION "Use external QtSingleApplication library" OFF) +option(USE_SINGLEAPPLICATION "Use SingleApplication library" ON) option(USE_LAUNCHER_ABSOLUTE_PATH "Use absolute path for the desktop launcher" ON) option(USE_WAYLAND_CLIPBOARD "USE KF Gui Wayland Clipboard" OFF) option(DISABLE_UPDATE_CHECKER "Disable check for updates" OFF) @@ -119,24 +119,17 @@ enable_sanitizers(project_options) # allow for static analysis options include(cmake/StaticAnalyzers.cmake) -set(QAPPLICATION_CLASS - QApplication - CACHE STRING "Inheritance class for SingleApplication") +if(USE_SINGLEAPPLICATION) + set(QAPPLICATION_CLASS + QApplication + CACHE STRING "Inheritance class for SingleApplication") -if(USE_EXTERNAL_SINGLEAPPLICATION) - # look for external QtSingleApplication - # package dev-qt/qtsingleapplication provides no symlink to current version - set(qtsingleapplication_libs libQt5Solutions_SingleApplication-2.6 Qt5Solutions_SingleApplication-2.6) - find_library(QTSINGLEAPPLICATION_LIBRARY NAMES ${qtsingleapplication_libs}) - message(STATUS "Using external QtSingleApplication library") -else() FetchContent_Declare( singleApplication GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git GIT_TAG v3.5.2 ) FetchContent_MakeAvailable(SingleApplication) - set(QTSINGLEAPPLICATION_LIBRARY SingleApplication::SingleApplication) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 012fcfad..b0a3b7d7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -153,9 +153,6 @@ endif () target_sources( flameshot PRIVATE - # ${CMAKE_CURRENT_SOURCE_DIR}/../external/Qt-Color-Widgets/src/QtColorWidgets/color_utils.cpp - # ${CMAKE_CURRENT_SOURCE_DIR}/../external/Qt-Color-Widgets/src/QtColorWidgets/color_wheel.cpp - # ${CMAKE_CURRENT_SOURCE_DIR}/../external/Qt-Color-Widgets/include/QtColorWidgets/color_wheel.hpp ${CMAKE_CURRENT_SOURCE_DIR}/../data/graphics.qrc ${CMAKE_CURRENT_SOURCE_DIR}/../data/flameshot.rc # windows binary icon resource file ${QM_FILES} @@ -165,7 +162,6 @@ target_include_directories( flameshot PUBLIC $ $ - $ $ $ $ @@ -205,16 +201,6 @@ target_include_directories( $ ) - -if (USE_EXTERNAL_SINGLEAPPLICATION) - add_compile_definitions(USE_EXTERNAL_SINGLEAPPLICATION=1) -else () - target_include_directories( - flameshot - PUBLIC - $) -endif() - target_link_libraries( flameshot project_warnings @@ -223,10 +209,18 @@ target_link_libraries( Qt${QT_VERSION_MAJOR}::DBus Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Widgets - ${QTSINGLEAPPLICATION_LIBRARY} QtColorWidgets ) +if (USE_SINGLEAPPLICATION) + message(STATUS "SingleApplication is used!") + add_compile_definitions(USE_SINGLEAPPLICATION=1) + target_link_libraries( + flameshot + SingleApplication::SingleApplication + ) +endif() + if (USE_WAYLAND_CLIPBOARD) target_compile_definitions(flameshot PRIVATE USE_WAYLAND_CLIPBOARD=1) target_link_libraries(flameshot KF6::GuiAddons) diff --git a/src/main.cpp b/src/main.cpp index 61787811..060eb0bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors -#ifndef USE_EXTERNAL_SINGLEAPPLICATION +#ifdef USE_SINGLEAPPLICATION #include "singleapplication.h" -#else -#include "QtSolutions/qtsingleapplication.h" #endif #include "abstractlogger.h" @@ -129,12 +127,12 @@ int main(int argc, char* argv[]) // no arguments, just launch Flameshot if (argc == 1) { - // #ifndef USE_EXTERNAL_SINGLEAPPLICATION - // SingleApplication app(argc, argv); - // #else - // QtSingleApplication app(argc, argv); - // #endif +#ifdef USE_SINGLEAPPLICATION + SingleApplication app(argc, argv); +#else QApplication app(argc, argv); +#endif + configureApp(true); auto c = Flameshot::instance(); FlameshotDaemon::start();