Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,13 @@
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()

Expand Down Expand Up @@ -265,7 +266,7 @@
endif ()

if (NOT USE_OPENSSL)
message(WARNING "OpenSSL is required to upload screenshots")

Check warning on line 269 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

OpenSSL is required to upload screenshots

Check warning on line 269 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

OpenSSL is required to upload screenshots

Check warning on line 269 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

OpenSSL is required to upload screenshots

Check warning on line 269 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

OpenSSL is required to upload screenshots
endif ()
endif ()

Expand Down Expand Up @@ -434,7 +435,7 @@
FILES_MATCHING
PATTERN "*.dll")
else ()
message(WARNING "Unable to find OpenSSL dlls.")

Check warning on line 438 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

Unable to find OpenSSL dlls.

Check warning on line 438 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

Unable to find OpenSSL dlls.

Check warning on line 438 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-installer

Unable to find OpenSSL dlls.

Check warning on line 438 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2022 x64-portable

Unable to find OpenSSL dlls.
endif ()
endif ()

Expand Down
16 changes: 11 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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);
Expand Down
Loading