diff --git a/CMakeLists.txt b/CMakeLists.txt index f90e62c16d..8ec5dd7724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,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_SINGLEAPPLICATION "Use SingleApplication library" ON) +option(USE_KDSINGLEAPPLICATION "Use KDSingleApplication 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) @@ -123,20 +123,18 @@ enable_sanitizers(project_options) # allow for static analysis options include(cmake/StaticAnalyzers.cmake) -if(USE_SINGLEAPPLICATION) - set(QAPPLICATION_CLASS - QApplication - CACHE STRING "Inheritance class for SingleApplication") +if (USE_KDSINGLEAPPLICATION) + set(KDSingleApplication_EXAMPLES OFF CACHE BOOL "Don't build the examples") + set(KDSingleApplication_STATIC ON CACHE BOOL "Build static versions of the libraries") FetchContent_Declare( - singleApplication - GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication.git - GIT_TAG v3.5.2 + kdsingleApplication + GIT_REPOSITORY https://github.com/KDAB/KDSingleApplication.git + GIT_TAG v1.2.0 ) - FetchContent_MakeAvailable(SingleApplication) + FetchContent_MakeAvailable(KDSingleApplication) endif() - option(BUILD_STATIC_LIBS ON) option(BUILD_SHARED_LIBS OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1ae2e26814..98ec922014 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -214,12 +214,13 @@ target_link_libraries( QtColorWidgets ) -if (USE_SINGLEAPPLICATION) - message(STATUS "SingleApplication is used!") - add_compile_definitions(USE_SINGLEAPPLICATION=1) +if (USE_KDSINGLEAPPLICATION) + message(STATUS "KDSingleApplication is used!") + add_compile_definitions(USE_KDSINGLEAPPLICATION=1) + target_link_libraries( flameshot - SingleApplication::SingleApplication + kdsingleapplication ) endif() diff --git a/src/main.cpp b/src/main.cpp index 0891807a8b..9c9fa7591d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors -#ifdef USE_SINGLEAPPLICATION -#include "singleapplication.h" +#ifdef USE_KDSINGLEAPPLICATION +#include "kdsingleapplication.h" #endif #include "abstractlogger.h" @@ -140,10 +140,16 @@ int main(int argc, char* argv[]) // no arguments, just launch Flameshot if (argc == 1) { -#ifdef USE_SINGLEAPPLICATION - SingleApplication app(argc, argv); -#else QApplication app(argc, argv); + +#ifdef USE_KDSINGLEAPPLICATION + KDSingleApplication kdsa(QStringLiteral("flameshot")); + + if (!kdsa.isPrimaryInstance()) { + // AbstractLogger::warning() + // << QStringLiteral("Closing second Flameshot instance!"); + return 0; // Quit + } #endif configureApp(true);