Wizard: add websocket toggle page

This commit is contained in:
tobtoht 2022-06-22 23:00:03 +02:00
parent 1c14e9789a
commit cf46f1fe58
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
8 changed files with 153 additions and 13 deletions

View file

@ -118,10 +118,15 @@ void Settings::setupPrivacyTab() {
}); });
// [Disable websocket] // [Disable websocket]
ui->checkBox_disableWebsocket->setChecked(config()->get(Config::disableWebsocket).toBool()); ui->checkBox_enableWebsocket->setChecked(!config()->get(Config::disableWebsocket).toBool());
connect(ui->checkBox_disableWebsocket, &QCheckBox::toggled, [this](bool checked){ connect(ui->checkBox_enableWebsocket, &QCheckBox::toggled, [this](bool checked){
config()->set(Config::disableWebsocket, checked); config()->set(Config::disableWebsocket, !checked);
this->enableWebsocket(!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] // [Do not write log files to disk]

View file

@ -264,14 +264,14 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_10"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<item> <item>
<widget class="QCheckBox" name="checkBox_disableWebsocket"> <widget class="QCheckBox" name="checkBox_enableWebsocket">
<property name="text"> <property name="text">
<string>Disable websocket</string> <string>Obtain third-party data</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="btn_disableWebsocket"> <widget class="QPushButton" name="btn_enableWebsocket">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed"> <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>

View file

@ -11,9 +11,6 @@ PageNetworkTor::PageNetworkTor(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setCommitPage(true);
this->setButtonText(QWizard::CommitButton, "Next");
QPixmap iconAllTorExceptNode(":/assets/images/securityLevelStandard.png"); QPixmap iconAllTorExceptNode(":/assets/images/securityLevelStandard.png");
QPixmap iconAllTorExceptInitSync(":/assets/images/securityLevelSafer.png"); QPixmap iconAllTorExceptInitSync(":/assets/images/securityLevelSafer.png");
QPixmap iconAllTor(":/assets/images/securityLevelSafest.png"); QPixmap iconAllTor(":/assets/images/securityLevelSafest.png");
@ -46,7 +43,7 @@ void PageNetworkTor::initializePage() {
} }
int PageNetworkTor::nextId() const { int PageNetworkTor::nextId() const {
return WalletWizard::Page_Menu; return WalletWizard::Page_NetworkWebsocket;
} }
bool PageNetworkTor::validatePage() { bool PageNetworkTor::validatePage() {

View file

@ -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;
}

View file

@ -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 <QWizardPage>
#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

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PageNetworkWebsocket</class>
<widget class="QWizardPage" name="PageNetworkWebsocket">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>709</width>
<height>432</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Do you want to obtain third-party data?</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;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.&lt;/p&gt;&lt;p&gt;If you opt to disable this connection some wallet functionality will be disabled. You can re-enable it at any time.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="btn_enable">
<property name="text">
<string>Enable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="btn_disable">
<property name="text">
<string>Disable</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -16,6 +16,7 @@
#include "PageSetSeedPassphrase.h" #include "PageSetSeedPassphrase.h"
#include "PageHardwareDevice.h" #include "PageHardwareDevice.h"
#include "PageNetworkTor.h" #include "PageNetworkTor.h"
#include "PageNetworkWebsocket.h"
#include "constants.h" #include "constants.h"
#include <QLineEdit> #include <QLineEdit>
@ -33,6 +34,7 @@ WalletWizard::WalletWizard(QWidget *parent)
auto networkPage = new PageNetwork(this); auto networkPage = new PageNetwork(this);
auto networkTorPage = new PageNetworkTor(this); auto networkTorPage = new PageNetworkTor(this);
auto networkWebsocketPage = new PageNetworkWebsocket(this);
auto menuPage = new PageMenu(&m_wizardFields, m_walletKeysFilesModel, this); auto menuPage = new PageMenu(&m_wizardFields, m_walletKeysFilesModel, this);
auto openWalletPage = new PageOpenWallet(m_walletKeysFilesModel, this); auto openWalletPage = new PageOpenWallet(m_walletKeysFilesModel, this);
auto createWallet = new PageWalletFile(&m_wizardFields , this); auto createWallet = new PageWalletFile(&m_wizardFields , this);
@ -46,6 +48,7 @@ WalletWizard::WalletWizard(QWidget *parent)
setPage(Page_SetPasswordPage, walletSetPasswordPage); setPage(Page_SetPasswordPage, walletSetPasswordPage);
setPage(Page_Network, networkPage); setPage(Page_Network, networkPage);
setPage(Page_NetworkTor, networkTorPage); setPage(Page_NetworkTor, networkTorPage);
setPage(Page_NetworkWebsocket, networkWebsocketPage);
setPage(Page_WalletRestoreSeed, new PageWalletRestoreSeed(&m_wizardFields, this)); setPage(Page_WalletRestoreSeed, new PageWalletRestoreSeed(&m_wizardFields, this));
setPage(Page_WalletRestoreKeys, new PageWalletRestoreKeys(&m_wizardFields, this)); setPage(Page_WalletRestoreKeys, new PageWalletRestoreKeys(&m_wizardFields, this));
setPage(Page_SetRestoreHeight, new PageSetRestoreHeight(&m_wizardFields, this)); setPage(Page_SetRestoreHeight, new PageSetRestoreHeight(&m_wizardFields, this));
@ -59,7 +62,7 @@ WalletWizard::WalletWizard(QWidget *parent)
setWizardStyle(WizardStyle::ModernStyle); setWizardStyle(WizardStyle::ModernStyle);
setOption(QWizard::NoBackButtonOnStartPage); setOption(QWizard::NoBackButtonOnStartPage);
connect(networkTorPage, &PageNetworkTor::initialNetworkConfigured, [this](){ connect(networkWebsocketPage, &PageNetworkWebsocket::initialNetworkConfigured, [this](){
emit initialNetworkConfigured(); emit initialNetworkConfigured();
}); });

View file

@ -65,7 +65,8 @@ public:
Page_WalletRestoreKeys, Page_WalletRestoreKeys,
Page_SetRestoreHeight, Page_SetRestoreHeight,
Page_HardwareDevice, Page_HardwareDevice,
Page_NetworkTor Page_NetworkTor,
Page_NetworkWebsocket
}; };
explicit WalletWizard(QWidget *parent = nullptr); explicit WalletWizard(QWidget *parent = nullptr);