diff --git a/src/appcontext.cpp b/src/appcontext.cpp
index b5f878f..4b23c0a 100644
--- a/src/appcontext.cpp
+++ b/src/appcontext.cpp
@@ -184,6 +184,11 @@ AppContext::AppContext(QCommandLineParser *cmdargs) {
// libwallet connects
connect(this->walletManager, &WalletManager::walletOpened, this, &AppContext::onWalletOpened);
+
+ // hideOnClose
+ auto hideOnClose = config()->get(Config::hideOnClose).toBool();
+ if(hideOnClose)
+ QApplication::setQuitOnLastWindowClosed(false);
}
void AppContext::initTor() {
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 431caef..1b5050b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -108,11 +108,14 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
m_trayIcon = new QSystemTrayIcon(QIcon(":/assets/images/appicons/64x64.png"));
m_trayIcon->show();
+ m_trayActionHome = new QAction("Show", this);
+ m_trayActionHome->setStatusTip("Show");
+
m_trayActionCalc = new QAction("Calc", this);
m_trayActionCalc->setStatusTip("Calculator");
m_trayActionSend = new QAction("Send", this);
- m_trayActionSend->setStatusTip("Send WOW payment");
+ m_trayActionSend->setStatusTip("Send a WOW payment");
m_trayActionHistory = new QAction("History", this);
m_trayActionHistory->setStatusTip("View incoming transfers");
@@ -120,6 +123,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
m_trayActionExit = new QAction("Quit", this);
m_trayActionExit->setStatusTip("Exit application");
+ m_trayMenu.addAction(m_trayActionHome);
m_trayMenu.addAction(m_trayActionSend);
m_trayMenu.addAction(m_trayActionHistory);
m_trayMenu.addAction(m_trayActionCalc);
@@ -127,6 +131,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
m_trayIcon->setContextMenu(&m_trayMenu);
// @TODO: only init tray *after* boot
+ connect(m_trayActionHome, &QAction::triggered, this, &MainWindow::showHomeWindow);
connect(m_trayActionCalc, &QAction::triggered, this, &MainWindow::showCalcWindow);
connect(m_trayActionSend, &QAction::triggered, this, &MainWindow::showSendTab);
connect(m_trayActionHistory, &QAction::triggered, this, &MainWindow::showHistoryTab);
@@ -968,7 +973,6 @@ void MainWindow::menuNewRestoreClicked() {
void MainWindow::menuQuitClicked() {
cleanupBeforeClose();
-
QCoreApplication::quit();
}
@@ -1038,9 +1042,16 @@ void MainWindow::skinChanged(const QString &skinName) {
}
void MainWindow::closeEvent(QCloseEvent *event) {
- cleanupBeforeClose();
+ auto hideOnClose = config()->get(Config::hideOnClose).toBool();
+ if(hideOnClose && !this->isHidden()) {
+ this->hide();
+ event->ignore();
+ return;
+ }
+ cleanupBeforeClose();
QWidget::closeEvent(event);
+ QApplication::exit();
}
void MainWindow::donateButtonClicked() {
@@ -1054,15 +1065,25 @@ void MainWindow::donateButtonClicked() {
void MainWindow::showHistoryTab() {
this->raise();
+ this->show();
ui->tabWidget->setCurrentIndex(Tabs::HISTORY);
}
void MainWindow::showSendTab() {
this->raise();
+ this->show();
ui->tabWidget->setCurrentIndex(Tabs::SEND);
}
+void MainWindow::showHomeWindow() {
+ this->raise();
+ this->show();
+ ui->tabWidget->setCurrentIndex(Tabs::HOME);
+}
+
void MainWindow::showCalcWindow() {
+ this->raise();
+ this->show();
m_windowCalc->show();
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 3e22fac..39d5df0 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -109,6 +109,7 @@ public slots:
void showViewOnlyDialog();
void donateButtonClicked();
void showCalcWindow();
+ void showHomeWindow();
void payToMany();
void showWalletCacheDebugDialog();
void showSendTab();
@@ -200,6 +201,7 @@ private:
QSystemTrayIcon *m_trayIcon;
QMenu m_trayMenu;
+ QAction *m_trayActionHome;
QAction *m_trayActionCalc;
QAction *m_trayActionExit;
QAction *m_trayActionSend;
diff --git a/src/settings.cpp b/src/settings.cpp
index 025e74a..ed0cfc8 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -30,6 +30,11 @@ Settings::Settings(QWidget *parent) :
m_ctx->updateBalance();
});
+ connect(ui->checkBox_hideOnClose, &QCheckBox::toggled, [this](bool toggled){
+ config()->set(Config::hideOnClose, toggled);
+ QApplication::setQuitOnLastWindowClosed(toggled);
+ });
+
connect(ui->closeButton, &QDialogButtonBox::accepted, this, &Settings::close);
// nodes
@@ -40,6 +45,7 @@ Settings::Settings(QWidget *parent) :
// setup checkboxes
ui->checkBox_externalLink->setChecked(config()->get(Config::warnOnExternalLink).toBool());
ui->checkBox_hideBalance->setChecked(config()->get(Config::hideBalance).toBool());
+ ui->checkBox_hideOnClose->setChecked(config()->get(Config::hideOnClose).toBool());
// setup comboboxes
this->setupSkinCombobox();
diff --git a/src/settings.ui b/src/settings.ui
index 41993d5..79f34b2 100644
--- a/src/settings.ui
+++ b/src/settings.ui
@@ -198,6 +198,13 @@
+ -
+
+
+ Hide application on close
+
+
+
diff --git a/src/utils/config.cpp b/src/utils/config.cpp
index 49f0bb0..6cd65ba 100644
--- a/src/utils/config.cpp
+++ b/src/utils/config.cpp
@@ -46,6 +46,7 @@ static const QHash configStrings = {
{Config::windowState, {QS("windowState"), {}}},
{Config::firstRun,{QS("firstRun"), false}},
{Config::hideBalance, {QS("hideBalance"), false}},
+ {Config::hideOnClose, {QS("hideOnClose"), false}},
{Config::hideFiatBalance, {QS("hideFiatBalance"), false}},
{Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
{Config::showHistorySyncNotice, {QS("showHistorySyncNotice"), true}},
diff --git a/src/utils/config.h b/src/utils/config.h
index c8d4882..98732fb 100644
--- a/src/utils/config.h
+++ b/src/utils/config.h
@@ -49,6 +49,7 @@ public:
firstRun,
hideBalance,
hideFiatBalance,
+ hideOnClose,
redditFrontend,
showHistorySyncNotice,
ignoreUpdateWarning,