try singleapplication
This commit is contained in:
parent
5a3b6fff82
commit
ecc45811d8
4 changed files with 20 additions and 5 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
||||||
[submodule "3rdparty/nlohmann_json"]
|
[submodule "3rdparty/nlohmann_json"]
|
||||||
path = 3rdparty/nlohmann_json
|
path = 3rdparty/nlohmann_json
|
||||||
url = https://github.com/nlohmann/json.git
|
url = https://github.com/nlohmann/json.git
|
||||||
|
[submodule "3rdparty/singleapplication"]
|
||||||
|
path = 3rdparty/singleapplication
|
||||||
|
url = git@github.com:itay-grudev/SingleApplication.git
|
||||||
|
|
1
3rdparty/singleapplication
vendored
Submodule
1
3rdparty/singleapplication
vendored
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 7163d166a1fbce7917015293f8e139bd65604881
|
|
@ -11,6 +11,11 @@ set(CMAKE_AUTORCC ON)
|
||||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||||
find_package(Qt5PrintSupport CONFIG REQUIRED)
|
find_package(Qt5PrintSupport CONFIG REQUIRED)
|
||||||
|
|
||||||
|
# For SingleApplication:
|
||||||
|
find_package(Qt5Network CONFIG REQUIRED)
|
||||||
|
set(QAPPLICATION_CLASS QApplication)
|
||||||
|
add_compile_definitions(QAPPLICATION_CLASS=${QAPPLICATION_CLASS})
|
||||||
|
|
||||||
set(GUI_SOURCES
|
set(GUI_SOURCES
|
||||||
kima2.cpp
|
kima2.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
|
@ -28,11 +33,14 @@ set(GUI_SOURCES
|
||||||
settingsdialog.cpp
|
settingsdialog.cpp
|
||||||
settingsdialog.ui
|
settingsdialog.ui
|
||||||
../../kima2.qrc
|
../../kima2.qrc
|
||||||
|
${PROJECT_SOURCE_DIR}/3rdparty/singleapplication/singleapplication.cpp
|
||||||
|
${PROJECT_SOURCE_DIR}/3rdparty/singleapplication/singleapplication_p.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(kima2 ${GUI_SOURCES} kima2.rc)
|
add_executable(kima2 ${GUI_SOURCES} kima2.rc)
|
||||||
target_include_directories(kima2 PRIVATE ${PROJECT_BINARY_DIR})
|
target_include_directories(kima2 PRIVATE ${PROJECT_BINARY_DIR})
|
||||||
target_link_libraries(kima2 core printer Qt5::Widgets Qt5::PrintSupport stdc++fs)
|
target_include_directories(kima2 PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/singleapplication)
|
||||||
|
target_link_libraries(kima2 core printer Qt5::Widgets Qt5::PrintSupport Qt5::Network stdc++fs)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set_target_properties(kima2 PROPERTIES LINK_FLAGS "-mwindows")
|
set_target_properties(kima2 PROPERTIES LINK_FLAGS "-mwindows")
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
|
@ -6,12 +6,14 @@
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTranslator>
|
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include <singleapplication.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
QApplication kimaApp{argc, argv};
|
SingleApplication kimaApp(argc, argv);
|
||||||
|
|
||||||
// QCoreApplication::setOrganizationName("RustySoft");
|
// QCoreApplication::setOrganizationName("RustySoft");
|
||||||
QCoreApplication::setOrganizationDomain("rustysoft.de");
|
QCoreApplication::setOrganizationDomain("rustysoft.de");
|
||||||
|
@ -19,10 +21,11 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Make sure that only one instance of the application runs
|
// Make sure that only one instance of the application runs
|
||||||
// Of course the uuid used here is unique to this application
|
// Of course the uuid used here is unique to this application
|
||||||
QSharedMemory shared("26297455-946a-4607-bfb7-5025a5f1e136");
|
// (commented out in favour of SingleApplication)
|
||||||
|
/*QSharedMemory shared("26297455-946a-4607-bfb7-5025a5f1e136");
|
||||||
if (!shared.create(512, QSharedMemory::ReadWrite)) {
|
if (!shared.create(512, QSharedMemory::ReadWrite)) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
QTranslator qTranslator;
|
QTranslator qTranslator;
|
||||||
QLocale german(QLocale::German);
|
QLocale german(QLocale::German);
|
||||||
|
|
Loading…
Reference in a new issue