mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-23 12:57:45 +00:00
Use KDSingleApplication to force single instance
This commit is contained in:
parent
489c1a2110
commit
f75fb70ac9
5 changed files with 15 additions and 1 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
|||
[submodule "external/libphysis"]
|
||||
path = external/libphysis
|
||||
url = https://git.sr.ht/~redstrate/libphysis
|
||||
[submodule "external/kdsingleapplication"]
|
||||
path = external/kdsingleapplication
|
||||
url = git@github.com:KDAB/KDSingleApplication.git
|
||||
|
|
5
external/CMakeLists.txt
vendored
5
external/CMakeLists.txt
vendored
|
@ -11,7 +11,7 @@ find_package(Corrosion REQUIRED)
|
|||
corrosion_import_crate(MANIFEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libphysis/Cargo.toml
|
||||
NO_DEFAULT_FEATURES
|
||||
FEATURES game_install)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libphysis/logger)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libphysis/logger EXCLUDE_FROM_ALL)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(UNSHIELD REQUIRED IMPORTED_TARGET libunshield)
|
||||
|
@ -19,3 +19,6 @@ pkg_check_modules(UNSHIELD REQUIRED IMPORTED_TARGET libunshield)
|
|||
target_include_directories(physis INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libphysis/target/public)
|
||||
target_link_libraries(physis INTERFACE ${UNSHIELD_LIBRARIES} z)
|
||||
target_link_directories(physis INTERFACE ${UNSHIELD_LIBRARY_DIRS})
|
||||
|
||||
set(KDSingleApplication_QT6 ON)
|
||||
add_subdirectory(kdsingleapplication EXCLUDE_FROM_ALL)
|
1
external/kdsingleapplication
vendored
Submodule
1
external/kdsingleapplication
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 4ef5fbc0c8aa46252781d5d57b16546f28e447ac
|
|
@ -129,6 +129,7 @@ target_link_libraries(astra PRIVATE
|
|||
physis
|
||||
physis-logger
|
||||
cotp
|
||||
KDAB::kdsingleapplication
|
||||
Qt6Keychain::Qt6Keychain
|
||||
Qt6::Core
|
||||
Qt6::Network
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QQuickStyle>
|
||||
#include <QtWebView>
|
||||
#include <kdsingleapplication.h>
|
||||
#include <qcoroqml.h>
|
||||
|
||||
#include "astra-version.h"
|
||||
|
@ -27,6 +28,11 @@ int main(int argc, char *argv[])
|
|||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
KDSingleApplication singleApplication;
|
||||
if (!singleApplication.isPrimaryInstance()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Default to a sensible message pattern
|
||||
if (qEnvironmentVariableIsEmpty("QT_MESSAGE_PATTERN")) {
|
||||
qputenv("QT_MESSAGE_PATTERN", "[%{time yyyy-MM-dd h:mm:ss.zzz}] %{if-category}[%{category}] %{endif}[%{type}] %{message}");
|
||||
|
|
Loading…
Add table
Reference in a new issue