SingleApplication

This commit is contained in:
tobtoht 2022-03-03 23:27:54 +01:00
parent a8d33099a2
commit df1eef8399
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
6 changed files with 30 additions and 1 deletions

3
.gitmodules vendored
View file

@ -1,3 +1,6 @@
[submodule "monero"] [submodule "monero"]
path = monero path = monero
url = https://github.com/feather-wallet/monero.git 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

View file

@ -23,6 +23,9 @@ endif()
find_package(Qt5 REQUIRED COMPONENTS ${QT5_COMPONENTS}) 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) add_subdirectory(openpgp)
qt5_add_resources(RESOURCES assets.qrc assets_tor.qrc) qt5_add_resources(RESOURCES assets.qrc assets_tor.qrc)
@ -250,6 +253,7 @@ target_link_libraries(feather
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${LIBZIP_LIBRARIES} ${LIBZIP_LIBRARIES}
${ZBAR_LIBRARIES} ${ZBAR_LIBRARIES}
SingleApplication::SingleApplication
) )
if(DEVICE_TREZOR_READY) if(DEVICE_TREZOR_READY)

View file

@ -115,6 +115,21 @@ void WindowManager::showWarningMessageBox(const QString &title, const QString &m
msgBox.exec(); 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 ######################## // ######################## WALLET OPEN ########################
void WindowManager::tryOpenWallet(const QString &path, const QString &password) { void WindowManager::tryOpenWallet(const QString &path, const QString &password) {

View file

@ -26,6 +26,7 @@ public:
void showWizard(WalletWizard::Page startPage); void showWizard(WalletWizard::Page startPage);
void changeSkin(const QString &skinName); void changeSkin(const QString &skinName);
void restartApplication(const QString &binaryFilename); void restartApplication(const QString &binaryFilename);
void raise();
signals: signals:
void torSettingsChanged(); void torSettingsChanged();

View file

@ -5,6 +5,7 @@
#include <QApplication> #include <QApplication>
#include <QtCore> #include <QtCore>
#include <QtGui> #include <QtGui>
#include <singleapplication.h>
#include "cli.h" #include "cli.h"
#include "config-feather.h" #include "config-feather.h"
@ -117,7 +118,7 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
QApplication::setDesktopSettingsAware(true); // use system font QApplication::setDesktopSettingsAware(true); // use system font
QApplication::setApplicationVersion(FEATHER_VERSION); QApplication::setApplicationVersion(FEATHER_VERSION);
QApplication app(argc, argv); SingleApplication app(argc, argv);
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
QApplication::setApplicationName("FeatherWallet"); QApplication::setApplicationName("FeatherWallet");
@ -224,5 +225,9 @@ if (AttachConsole(ATTACH_PARENT_PROCESS)) {
WindowManager windowManager; WindowManager windowManager;
QObject::connect(&app, &SingleApplication::instanceStarted, [&windowManager]() {
windowManager.raise();
});
return QApplication::exec(); return QApplication::exec();
} }

1
src/third-party/singleapplication vendored Submodule

@ -0,0 +1 @@
Subproject commit 3e8e85d1a487e433751711a8a090659684d42e3b