From cf46f1fe58e81934e9d999561a62e8be0cdbde7d Mon Sep 17 00:00:00 2001 From: tobtoht Date: Wed, 22 Jun 2022 23:00:03 +0200 Subject: [PATCH] Wizard: add websocket toggle page --- src/SettingsDialog.cpp | 13 +++-- src/SettingsDialog.ui | 6 +-- src/wizard/PageNetworkTor.cpp | 5 +- src/wizard/PageNetworkWebsocket.cpp | 29 +++++++++++ src/wizard/PageNetworkWebsocket.h | 31 ++++++++++++ src/wizard/PageNetworkWebsocket.ui | 74 +++++++++++++++++++++++++++++ src/wizard/WalletWizard.cpp | 5 +- src/wizard/WalletWizard.h | 3 +- 8 files changed, 153 insertions(+), 13 deletions(-) create mode 100644 src/wizard/PageNetworkWebsocket.cpp create mode 100644 src/wizard/PageNetworkWebsocket.h create mode 100644 src/wizard/PageNetworkWebsocket.ui diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index d4f2fec..6fb4c15 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -118,10 +118,15 @@ void Settings::setupPrivacyTab() { }); // [Disable websocket] - ui->checkBox_disableWebsocket->setChecked(config()->get(Config::disableWebsocket).toBool()); - connect(ui->checkBox_disableWebsocket, &QCheckBox::toggled, [this](bool checked){ - config()->set(Config::disableWebsocket, checked); - this->enableWebsocket(!checked); + ui->checkBox_enableWebsocket->setChecked(!config()->get(Config::disableWebsocket).toBool()); + connect(ui->checkBox_enableWebsocket, &QCheckBox::toggled, [this](bool checked){ + config()->set(Config::disableWebsocket, !checked); + this->enableWebsocket(checked); + }); + connect(ui->btn_enableWebsocket, &QPushButton::clicked, [this]{ + QMessageBox::information(this, "Obtain third-party information", "Feather can connect to an onion service hosted by the Feather developers to obtain pricing information, a curated list of remote nodes, Home feeds, the latest version of Feather Wallet and more.\n\n" + "This service is only used to fetch information and can only be reached over Tor. The wallet does not send information about its state or your transactions to the server. It is not used for any telemetry or crash reports.\n\n" + "If you opt to disable this connection some wallet functionality will be disabled. You can re-enable it at any time."); }); // [Do not write log files to disk] diff --git a/src/SettingsDialog.ui b/src/SettingsDialog.ui index 36c3cd7..d24f871 100644 --- a/src/SettingsDialog.ui +++ b/src/SettingsDialog.ui @@ -264,14 +264,14 @@ - + - Disable websocket + Obtain third-party data - + 0 diff --git a/src/wizard/PageNetworkTor.cpp b/src/wizard/PageNetworkTor.cpp index 9c9c965..31f06b8 100644 --- a/src/wizard/PageNetworkTor.cpp +++ b/src/wizard/PageNetworkTor.cpp @@ -11,9 +11,6 @@ PageNetworkTor::PageNetworkTor(QWidget *parent) { ui->setupUi(this); - this->setCommitPage(true); - this->setButtonText(QWizard::CommitButton, "Next"); - QPixmap iconAllTorExceptNode(":/assets/images/securityLevelStandard.png"); QPixmap iconAllTorExceptInitSync(":/assets/images/securityLevelSafer.png"); QPixmap iconAllTor(":/assets/images/securityLevelSafest.png"); @@ -46,7 +43,7 @@ void PageNetworkTor::initializePage() { } int PageNetworkTor::nextId() const { - return WalletWizard::Page_Menu; + return WalletWizard::Page_NetworkWebsocket; } bool PageNetworkTor::validatePage() { diff --git a/src/wizard/PageNetworkWebsocket.cpp b/src/wizard/PageNetworkWebsocket.cpp new file mode 100644 index 0000000..f2b8a8b --- /dev/null +++ b/src/wizard/PageNetworkWebsocket.cpp @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2022 The Monero Project + +#include "PageNetworkWebsocket.h" +#include "ui_PageNetworkWebsocket.h" +#include "WalletWizard.h" + +PageNetworkWebsocket::PageNetworkWebsocket(QWidget *parent) + : QWizardPage(parent) + , ui(new Ui::PageNetworkWebsocket) +{ + ui->setupUi(this); + + this->setCommitPage(true); + this->setButtonText(QWizard::CommitButton, "Next"); +} + +int PageNetworkWebsocket::nextId() const { + return WalletWizard::Page_Menu; +} + +bool PageNetworkWebsocket::validatePage() { + bool disabled = ui->btn_disable->isChecked(); + config()->set(Config::disableWebsocket, disabled); + + emit initialNetworkConfigured(); + + return true; +} \ No newline at end of file diff --git a/src/wizard/PageNetworkWebsocket.h b/src/wizard/PageNetworkWebsocket.h new file mode 100644 index 0000000..8428354 --- /dev/null +++ b/src/wizard/PageNetworkWebsocket.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: BSD-3-Clause +// SPDX-FileCopyrightText: 2020-2022 The Monero Project + +#ifndef FEATHER_PAGENETWORKWEBSOCKET_H +#define FEATHER_PAGENETWORKWEBSOCKET_H + +#include + +#include "appcontext.h" + +namespace Ui { + class PageNetworkWebsocket; +} + +class PageNetworkWebsocket : public QWizardPage +{ +Q_OBJECT + +public: + explicit PageNetworkWebsocket(QWidget *parent = nullptr); + bool validatePage() override; + int nextId() const override; + +signals: + void initialNetworkConfigured(); + +private: + Ui::PageNetworkWebsocket *ui; +}; + +#endif //FEATHER_PAGENETWORKWEBSOCKET_H diff --git a/src/wizard/PageNetworkWebsocket.ui b/src/wizard/PageNetworkWebsocket.ui new file mode 100644 index 0000000..f4bebb1 --- /dev/null +++ b/src/wizard/PageNetworkWebsocket.ui @@ -0,0 +1,74 @@ + + + PageNetworkWebsocket + + + + 0 + 0 + 709 + 432 + + + + WizardPage + + + + + + + 75 + true + + + + Do you want to obtain third-party data? + + + + + + + <html><head/><body><p>Feather can connect to an onion service hosted by the Feather developers to obtain pricing information, a curated list of remote nodes, Home feeds, the latest version of Feather Wallet and more.</p><p>This service is only used to fetch information and can only be reached over Tor. The wallet does not send information about its state or your transactions to the server. It is not used for any telemetry or crash reports.</p><p>If you opt to disable this connection some wallet functionality will be disabled. You can re-enable it at any time.</p></body></html> + + + true + + + + + + + Enable + + + true + + + + + + + Disable + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + diff --git a/src/wizard/WalletWizard.cpp b/src/wizard/WalletWizard.cpp index a5c22da..5abcb84 100644 --- a/src/wizard/WalletWizard.cpp +++ b/src/wizard/WalletWizard.cpp @@ -16,6 +16,7 @@ #include "PageSetSeedPassphrase.h" #include "PageHardwareDevice.h" #include "PageNetworkTor.h" +#include "PageNetworkWebsocket.h" #include "constants.h" #include @@ -33,6 +34,7 @@ WalletWizard::WalletWizard(QWidget *parent) auto networkPage = new PageNetwork(this); auto networkTorPage = new PageNetworkTor(this); + auto networkWebsocketPage = new PageNetworkWebsocket(this); auto menuPage = new PageMenu(&m_wizardFields, m_walletKeysFilesModel, this); auto openWalletPage = new PageOpenWallet(m_walletKeysFilesModel, this); auto createWallet = new PageWalletFile(&m_wizardFields , this); @@ -46,6 +48,7 @@ WalletWizard::WalletWizard(QWidget *parent) setPage(Page_SetPasswordPage, walletSetPasswordPage); setPage(Page_Network, networkPage); setPage(Page_NetworkTor, networkTorPage); + setPage(Page_NetworkWebsocket, networkWebsocketPage); setPage(Page_WalletRestoreSeed, new PageWalletRestoreSeed(&m_wizardFields, this)); setPage(Page_WalletRestoreKeys, new PageWalletRestoreKeys(&m_wizardFields, this)); setPage(Page_SetRestoreHeight, new PageSetRestoreHeight(&m_wizardFields, this)); @@ -59,7 +62,7 @@ WalletWizard::WalletWizard(QWidget *parent) setWizardStyle(WizardStyle::ModernStyle); setOption(QWizard::NoBackButtonOnStartPage); - connect(networkTorPage, &PageNetworkTor::initialNetworkConfigured, [this](){ + connect(networkWebsocketPage, &PageNetworkWebsocket::initialNetworkConfigured, [this](){ emit initialNetworkConfigured(); }); diff --git a/src/wizard/WalletWizard.h b/src/wizard/WalletWizard.h index 3e50c0b..c6da79e 100644 --- a/src/wizard/WalletWizard.h +++ b/src/wizard/WalletWizard.h @@ -65,7 +65,8 @@ public: Page_WalletRestoreKeys, Page_SetRestoreHeight, Page_HardwareDevice, - Page_NetworkTor + Page_NetworkTor, + Page_NetworkWebsocket }; explicit WalletWizard(QWidget *parent = nullptr);