macos: disable SingleApplication

This commit is contained in:
tobtoht 2024-09-22 13:37:06 +02:00
parent 60dde9b9ee
commit 26f303ea47
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
2 changed files with 21 additions and 4 deletions

View file

@ -20,8 +20,10 @@ endif()
find_package(Qt6 REQUIRED COMPONENTS ${QT_COMPONENTS}) find_package(Qt6 REQUIRED COMPONENTS ${QT_COMPONENTS})
set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") if (NOT APPLE)
add_subdirectory(third-party/singleapplication) set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication")
add_subdirectory(third-party/singleapplication)
endif()
if (CHECK_UPDATES) if (CHECK_UPDATES)
add_subdirectory(openpgp) add_subdirectory(openpgp)
@ -272,13 +274,16 @@ target_link_libraries(feather PRIVATE
Threads::Threads Threads::Threads
${QRENCODE_LIBRARY} ${QRENCODE_LIBRARY}
${POLYSEED_LIBRARY} ${POLYSEED_LIBRARY}
SingleApplication::SingleApplication
${ICU_LIBRARIES} ${ICU_LIBRARIES}
${LIBZIP_LIBRARIES} ${LIBZIP_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${BCUR_LIBRARY} ${BCUR_LIBRARY}
) )
if(NOT APPLE)
target_link_libraries(feather PRIVATE SingleApplication::SingleApplication)
endif()
if(CHECK_UPDATES) if(CHECK_UPDATES)
target_link_libraries(feather PRIVATE openpgp) target_link_libraries(feather PRIVATE openpgp)
endif() endif()

View file

@ -5,7 +5,9 @@
#include <QApplication> #include <QApplication>
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
#if !defined(Q_OS_MAC)
#include <singleapplication.h> #include <singleapplication.h>
#endif
#include "config-feather.h" #include "config-feather.h"
#include "constants.h" #include "constants.h"
@ -64,6 +66,8 @@ void signal_handler(int signum) {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
qDebug() << "Reached main";
Q_INIT_RESOURCE(assets); Q_INIT_RESOURCE(assets);
#if defined(Q_OS_LINUX) && defined(STACK_TRACE) #if defined(Q_OS_LINUX) && defined(STACK_TRACE)
@ -131,12 +135,18 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
#endif #endif
qDebug() << "Setting up QApplication";
#if defined(Q_OS_MAC)
// https://github.com/itay-grudev/SingleApplication/issues/136#issuecomment-1925441403
QApplication app(argc, argv);
#else
SingleApplication app(argc, argv); SingleApplication app(argc, argv);
#endif
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
QApplication::setApplicationName("FeatherWallet"); QApplication::setApplicationName("FeatherWallet");
// Setup config directories // Setup config directories
QString configDir = Config::defaultConfigDir().path(); QString configDir = Config::defaultConfigDir().path();
QString config_dir_tor = QString("%1/%2").arg(configDir, "tor"); QString config_dir_tor = QString("%1/%2").arg(configDir, "tor");
@ -238,9 +248,11 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
auto wm = windowManager(); auto wm = windowManager();
wm->setEventFilter(&filter); wm->setEventFilter(&filter);
#if !defined(Q_OS_MAC)
QObject::connect(&app, &SingleApplication::instanceStarted, [&wm]() { QObject::connect(&app, &SingleApplication::instanceStarted, [&wm]() {
wm->raise(); wm->raise();
}); });
#endif
return QApplication::exec(); return QApplication::exec();
} }