mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-23 19:15:56 +00:00
confirm daemon running on exit
This commit is contained in:
parent
988e299290
commit
bce496b8d1
6 changed files with 76 additions and 4 deletions
14
MainApp.cpp
Normal file
14
MainApp.cpp
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#include "MainApp.h"
|
||||||
|
#include <QCloseEvent>
|
||||||
|
|
||||||
|
bool MainApp::event (QEvent *event)
|
||||||
|
{
|
||||||
|
// Catch application exit event and signal to qml app to handle exit
|
||||||
|
if(event->type() == QEvent::Close) {
|
||||||
|
event->ignore();
|
||||||
|
emit closing();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
18
MainApp.h
Normal file
18
MainApp.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef MAINAPP_H
|
||||||
|
#define MAINAPP_H
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
class MainApp : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MainApp(int &argc, char** argv) : QApplication(argc, argv) {};
|
||||||
|
private:
|
||||||
|
bool event(QEvent *e);
|
||||||
|
signals:
|
||||||
|
void closing();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAINAPP_H
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ Window {
|
||||||
property alias cancelVisible: cancelButton.visible
|
property alias cancelVisible: cancelButton.visible
|
||||||
property alias okVisible: okButton.visible
|
property alias okVisible: okButton.visible
|
||||||
property alias textArea: dialogContent
|
property alias textArea: dialogContent
|
||||||
|
property alias okText: okButton.text
|
||||||
|
property alias cancelText: cancelButton.text
|
||||||
|
|
||||||
property var icon
|
property var icon
|
||||||
|
|
||||||
// same signals as Dialog has
|
// same signals as Dialog has
|
||||||
|
|
6
main.cpp
6
main.cpp
|
@ -50,6 +50,7 @@
|
||||||
#include "AddressBook.h"
|
#include "AddressBook.h"
|
||||||
#include "model/AddressBookModel.h"
|
#include "model/AddressBookModel.h"
|
||||||
#include "wallet/wallet2_api.h"
|
#include "wallet/wallet2_api.h"
|
||||||
|
#include "MainApp.h"
|
||||||
|
|
||||||
// IOS exclusions
|
// IOS exclusions
|
||||||
#ifndef Q_OS_IOS
|
#ifndef Q_OS_IOS
|
||||||
|
@ -74,7 +75,7 @@ int main(int argc, char *argv[])
|
||||||
Monero::Wallet::init(argv[0], "monero-wallet-gui");
|
Monero::Wallet::init(argv[0], "monero-wallet-gui");
|
||||||
qInstallMessageHandler(messageHandler);
|
qInstallMessageHandler(messageHandler);
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
MainApp app(argc, argv);
|
||||||
|
|
||||||
qDebug() << "app startd";
|
qDebug() << "app startd";
|
||||||
|
|
||||||
|
@ -146,6 +147,8 @@ int main(int argc, char *argv[])
|
||||||
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
engine.addImageProvider(QLatin1String("qrcode"), new QRCodeImageProvider());
|
||||||
const QStringList arguments = QCoreApplication::arguments();
|
const QStringList arguments = QCoreApplication::arguments();
|
||||||
|
|
||||||
|
engine.rootContext()->setContextProperty("mainApp", &app);
|
||||||
|
|
||||||
// Exclude daemon manager from IOS
|
// Exclude daemon manager from IOS
|
||||||
#ifndef Q_OS_IOS
|
#ifndef Q_OS_IOS
|
||||||
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
DaemonManager * daemonManager = DaemonManager::instance(&arguments);
|
||||||
|
@ -210,4 +213,3 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
33
main.qml
33
main.qml
|
@ -686,6 +686,7 @@ ApplicationWindow {
|
||||||
informationPopup.title = qsTr("Error") + translationManager.emptyString;
|
informationPopup.title = qsTr("Error") + translationManager.emptyString;
|
||||||
informationPopup.text = "internal error";
|
informationPopup.text = "internal error";
|
||||||
informationPopup.icon = StandardIcon.Critical
|
informationPopup.icon = StandardIcon.Critical
|
||||||
|
informationPopup.onCloseCallback = null
|
||||||
informationPopup.open()
|
informationPopup.open()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -792,6 +793,9 @@ ApplicationWindow {
|
||||||
daemonManager.daemonStartFailure.connect(onDaemonStartFailure);
|
daemonManager.daemonStartFailure.connect(onDaemonStartFailure);
|
||||||
daemonManager.daemonStopped.connect(onDaemonStopped);
|
daemonManager.daemonStopped.connect(onDaemonStopped);
|
||||||
|
|
||||||
|
// Connect app exit to qml window exit handling
|
||||||
|
mainApp.closing.connect(appWindow.close);
|
||||||
|
|
||||||
if(!walletsFound()) {
|
if(!walletsFound()) {
|
||||||
rootItem.state = "wizard"
|
rootItem.state = "wizard"
|
||||||
} else {
|
} else {
|
||||||
|
@ -1249,10 +1253,39 @@ ApplicationWindow {
|
||||||
id: notifier
|
id: notifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClosing: {
|
onClosing: {
|
||||||
|
|
||||||
|
// If daemon is running - prompt user before exiting
|
||||||
|
if(typeof daemonManager != undefined && daemonManager.running(persistentSettings.testnet)) {
|
||||||
|
close.accepted = false;
|
||||||
|
|
||||||
|
// Show confirmation dialog
|
||||||
|
confirmationDialog.title = qsTr("Daemon is running") + translationManager.emptyString;
|
||||||
|
confirmationDialog.text = qsTr("Daemon will still be running in background when GUI is closed.");
|
||||||
|
confirmationDialog.icon = StandardIcon.Question
|
||||||
|
confirmationDialog.cancelText = qsTr("Stop daemon")
|
||||||
|
confirmationDialog.onAcceptedCallback = function() {
|
||||||
|
closeAccepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmationDialog.onRejectedCallback = function() {
|
||||||
|
daemonManager.stop(persistentSettings.testnet);
|
||||||
|
closeAccepted();
|
||||||
|
};
|
||||||
|
|
||||||
|
confirmationDialog.open()
|
||||||
|
|
||||||
|
} else {
|
||||||
|
closeAccepted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeAccepted(){
|
||||||
// Close wallet non async on exit
|
// Close wallet non async on exit
|
||||||
daemonManager.exit();
|
daemonManager.exit();
|
||||||
walletManager.closeWallet();
|
walletManager.closeWallet();
|
||||||
|
Qt.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkUpdates() {
|
function checkUpdates() {
|
||||||
|
|
|
@ -38,7 +38,8 @@ HEADERS += \
|
||||||
src/libwalletqt/AddressBook.h \
|
src/libwalletqt/AddressBook.h \
|
||||||
src/zxcvbn-c/zxcvbn.h \
|
src/zxcvbn-c/zxcvbn.h \
|
||||||
src/libwalletqt/UnsignedTransaction.h \
|
src/libwalletqt/UnsignedTransaction.h \
|
||||||
src/QR-Code-scanner/QrCodeScanner.h
|
src/QR-Code-scanner/QrCodeScanner.h \
|
||||||
|
MainApp.h
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
filter.cpp \
|
filter.cpp \
|
||||||
|
@ -61,7 +62,8 @@ SOURCES += main.cpp \
|
||||||
src/libwalletqt/AddressBook.cpp \
|
src/libwalletqt/AddressBook.cpp \
|
||||||
src/zxcvbn-c/zxcvbn.c \
|
src/zxcvbn-c/zxcvbn.c \
|
||||||
src/libwalletqt/UnsignedTransaction.cpp \
|
src/libwalletqt/UnsignedTransaction.cpp \
|
||||||
src/QR-Code-scanner/QrCodeScanner.cpp
|
src/QR-Code-scanner/QrCodeScanner.cpp \
|
||||||
|
MainApp.cpp
|
||||||
|
|
||||||
!ios {
|
!ios {
|
||||||
HEADERS += src/daemon/DaemonManager.h
|
HEADERS += src/daemon/DaemonManager.h
|
||||||
|
|
Loading…
Reference in a new issue