diff --git a/.gitmodules b/.gitmodules index d241dc4..6e4f896 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "monero"] path = monero url = https://github.com/feather-wallet/monero.git +[submodule "src/third-party/singleapplication"] + path = src/third-party/singleapplication + url = https://github.com/itay-grudev/SingleApplication.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d21d2f2..022d179 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -23,6 +23,9 @@ endif() find_package(Qt5 REQUIRED COMPONENTS ${QT5_COMPONENTS}) +set(QAPPLICATION_CLASS QApplication CACHE STRING "Inheritance class for SingleApplication") +add_subdirectory(third-party/singleapplication) + add_subdirectory(openpgp) qt5_add_resources(RESOURCES assets.qrc assets_tor.qrc) @@ -250,6 +253,7 @@ target_link_libraries(feather ${ZLIB_LIBRARIES} ${LIBZIP_LIBRARIES} ${ZBAR_LIBRARIES} + SingleApplication::SingleApplication ) if(DEVICE_TREZOR_READY) diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index 05a6d50..d0eb903 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -115,6 +115,21 @@ void WindowManager::showWarningMessageBox(const QString &title, const QString &m msgBox.exec(); } +void WindowManager::raise() { + if (!m_windows.isEmpty()) { + m_windows.first()->bringToFront(); + } + else if (m_wizard) { + m_wizard->show(); + m_wizard->raise(); + m_wizard->activateWindow(); + } + else { + // This shouldn't happen + this->close(); + } +} + // ######################## WALLET OPEN ######################## void WindowManager::tryOpenWallet(const QString &path, const QString &password) { diff --git a/src/WindowManager.h b/src/WindowManager.h index f835567..93bb9db 100644 --- a/src/WindowManager.h +++ b/src/WindowManager.h @@ -26,6 +26,7 @@ public: void showWizard(WalletWizard::Page startPage); void changeSkin(const QString &skinName); void restartApplication(const QString &binaryFilename); + void raise(); signals: void torSettingsChanged(); diff --git a/src/main.cpp b/src/main.cpp index a534ad1..29c262d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "cli.h" #include "config-feather.h" @@ -117,7 +118,7 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { QApplication::setDesktopSettingsAware(true); // use system font QApplication::setApplicationVersion(FEATHER_VERSION); - QApplication app(argc, argv); + SingleApplication app(argc, argv); QApplication::setQuitOnLastWindowClosed(false); QApplication::setApplicationName("FeatherWallet"); @@ -224,5 +225,9 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) { WindowManager windowManager; + QObject::connect(&app, &SingleApplication::instanceStarted, [&windowManager]() { + windowManager.raise(); + }); + return QApplication::exec(); } diff --git a/src/third-party/singleapplication b/src/third-party/singleapplication new file mode 160000 index 0000000..3e8e85d --- /dev/null +++ b/src/third-party/singleapplication @@ -0,0 +1 @@ +Subproject commit 3e8e85d1a487e433751711a8a090659684d42e3b