From faea53d6177d42a73e8b775a9bac2a85ac534027 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Thu, 27 May 2021 01:20:37 +0200 Subject: [PATCH] Move startupWarning to WindowManager --- src/WindowManager.cpp | 35 +++++++++++++++++++++++++++++++++++ src/WindowManager.h | 2 ++ src/mainwindow.cpp | 23 ----------------------- src/mainwindow.h | 1 - 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/src/WindowManager.cpp b/src/WindowManager.cpp index f77b098..553afd2 100644 --- a/src/WindowManager.cpp +++ b/src/WindowManager.cpp @@ -35,6 +35,8 @@ WindowManager::WindowManager() { this->onInitialNetworkConfigured(); } + this->startupWarning(); + if (!this->autoOpenWallet()) { this->initWizard(); } @@ -72,6 +74,39 @@ void WindowManager::restartApplication(const QString &binaryFilename) { this->close(); } +void WindowManager::startupWarning() { + // Stagenet / Testnet + auto worthlessWarning = QString("Feather wallet is currently running in %1 mode. This is meant " + "for developers only. Your coins are WORTHLESS."); + if (constants::networkType == NetworkType::STAGENET && config()->get(Config::warnOnStagenet).toBool()) { + this->showWarningMessageBox("Warning", worthlessWarning.arg("stagenet")); + config()->set(Config::warnOnStagenet, false); + } + else if (constants::networkType == NetworkType::TESTNET && config()->get(Config::warnOnTestnet).toBool()){ + this->showWarningMessageBox("Warning", worthlessWarning.arg("testnet")); + config()->set(Config::warnOnTestnet, false); + } + + // Beta + if (config()->get(Config::warnOnAlpha).toBool()) { + QString warning = "Feather Wallet is currently in beta.\n\nPlease report any bugs " + "you encounter on our Git repository, IRC or on /r/FeatherWallet."; + this->showWarningMessageBox("Beta warning", warning); + config()->set(Config::warnOnAlpha, false); + } +} + +void WindowManager::showWarningMessageBox(const QString &title, const QString &message) { + QMessageBox msgBox; + msgBox.setWindowIcon(icons()->icon("appicons/64x64.png")); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setText(message); + msgBox.setWindowTitle(title); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.exec(); +} + // ######################## WALLET OPEN ######################## void WindowManager::tryOpenWallet(const QString &path, const QString &password) { diff --git a/src/WindowManager.h b/src/WindowManager.h index 809d5c6..7c9c3d9 100644 --- a/src/WindowManager.h +++ b/src/WindowManager.h @@ -58,6 +58,8 @@ private: void initSkins(); QString loadStylesheet(const QString &resource); void buildTrayMenu(); + void startupWarning(); + void showWarningMessageBox(const QString &title, const QString &message); void quitAfterLastWindow(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3d2e3ac..1ec34dd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -50,7 +50,6 @@ MainWindow::MainWindow(WindowManager *windowManager, Wallet *wallet, QWidget *pa m_splashDialog = new SplashDialog(this); this->restoreGeo(); - this->startupWarning(); this->initStatusBar(); this->initWidgets(); @@ -370,28 +369,6 @@ void MainWindow::initWalletContext() { connect(m_ctx->wallet.get(), &Wallet::currentSubaddressAccountChanged, this, &MainWindow::updateTitle); } -void MainWindow::startupWarning() { - // Stagenet / Testnet - auto worthlessWarning = QString("Feather wallet is currently running in %1 mode. This is meant " - "for developers only. Your coins are WORTHLESS."); - if (constants::networkType == NetworkType::STAGENET && config()->get(Config::warnOnStagenet).toBool()) { - QMessageBox::warning(this, "Warning", worthlessWarning.arg("stagenet")); - config()->set(Config::warnOnStagenet, false); - } - else if (constants::networkType == NetworkType::TESTNET && config()->get(Config::warnOnTestnet).toBool()){ - QMessageBox::warning(this, "Warning", worthlessWarning.arg("testnet")); - config()->set(Config::warnOnTestnet, false); - } - - // Beta - if (config()->get(Config::warnOnAlpha).toBool()) { - QString warning = "Feather Wallet is currently in beta.\n\nPlease report any bugs " - "you encounter on our Git repository, IRC or on /r/FeatherWallet."; - QMessageBox::warning(this, "Beta Warning", warning); - config()->set(Config::warnOnAlpha, false); - } -} - void MainWindow::menuToggleTabVisible(const QString &key){ const auto toggleTab = m_tabShowHideMapper[key]; bool show = config()->get(toggleTab->configKey).toBool(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 56f2dc0..eaecad9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -183,7 +183,6 @@ private: void initMenu(); void initHome(); void initWalletContext(); - void startupWarning(); void closeEvent(QCloseEvent *event) override;