]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
SingleApplication
authortobtoht <thotbot@protonmail.com>
Thu, 3 Mar 2022 22:27:54 +0000 (23:27 +0100)
committertobtoht <thotbot@protonmail.com>
Thu, 3 Mar 2022 22:27:54 +0000 (23:27 +0100)
.gitmodules
src/CMakeLists.txt
src/WindowManager.cpp
src/WindowManager.h
src/main.cpp
src/third-party/singleapplication [new submodule]

index d241dc439a80d974fc005c7fe7bd2545806d8f81..6e4f89618908c9e917973b3778cb37f2f0e8bbd9 100644 (file)
@@ -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
index d21d2f20087747e4bb4a01b23ff53b7eaba379c6..022d179f221bf1788c5a8d626f40bb1c985e3ae6 100644 (file)
@@ -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)
index 05a6d5097117b13f498f32d95f245ce4d0da5dfd..d0eb903e24f727ab5bb4e863e630ebbd61e576ea 100644 (file)
@@ -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) {
index f8355679d13ae9c56a8260c5d7c5742bd7f387f7..93bb9db6ed8b900687feeacbe95081500be4d861 100644 (file)
@@ -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();
index a534ad1a044f211f192bdc8c42cbc846037ec57d..29c262d53d27a189d74e452df081ef8277dcab6d 100644 (file)
@@ -5,6 +5,7 @@
 #include <QApplication>
 #include <QtCore>
 #include <QtGui>
+#include <singleapplication.h>
 
 #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 (submodule)
index 0000000..3e8e85d
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 3e8e85d1a487e433751711a8a090659684d42e3b