2020-10-07 10:36:04 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-12-26 19:56:06 +00:00
|
|
|
// Copyright (c) 2020-2021, The Monero Project.
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-03-12 18:26:48 +00:00
|
|
|
#include "PageNetwork.h"
|
|
|
|
#include "ui_PageNetwork.h"
|
2021-05-02 18:22:38 +00:00
|
|
|
#include "WalletWizard.h"
|
2021-05-18 15:59:18 +00:00
|
|
|
#include "constants.h"
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
PageNetwork::PageNetwork(QWidget *parent)
|
2021-05-02 18:22:38 +00:00
|
|
|
: QWizardPage(parent)
|
|
|
|
, ui(new Ui::PageNetwork)
|
|
|
|
{
|
2020-10-07 10:36:04 +00:00
|
|
|
ui->setupUi(this);
|
2021-05-02 18:22:38 +00:00
|
|
|
this->setTitle("Welcome to Feather");
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-05-02 18:22:38 +00:00
|
|
|
ui->frame_customNode->hide();
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-05-02 18:22:38 +00:00
|
|
|
ui->btnGroup_network->setId(ui->radio_autoConnect, 0);
|
|
|
|
ui->btnGroup_network->setId(ui->radio_custom, 1);
|
2020-10-07 10:36:04 +00:00
|
|
|
|
2021-05-02 18:22:38 +00:00
|
|
|
connect(ui->btnGroup_network, &QButtonGroup::idClicked, [this](int id) {
|
|
|
|
ui->frame_customNode->setVisible(id == 1);
|
|
|
|
});
|
|
|
|
connect(ui->line_customNode, &QLineEdit::textEdited, [this]{
|
|
|
|
this->completeChanged();
|
2020-10-07 10:36:04 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-03-12 18:26:48 +00:00
|
|
|
int PageNetwork::nextId() const {
|
2021-05-02 18:22:38 +00:00
|
|
|
return WalletWizard::Page_NetworkTor;
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|
|
|
|
|
2021-03-12 18:26:48 +00:00
|
|
|
bool PageNetwork::validatePage() {
|
2021-05-02 18:22:38 +00:00
|
|
|
int id = ui->btnGroup_network->checkedId();
|
|
|
|
config()->set(Config::nodeSource, id);
|
|
|
|
|
|
|
|
if (id == 1) {
|
2021-05-18 15:59:18 +00:00
|
|
|
NodeList nodeList;
|
|
|
|
nodeList.addNode(ui->line_customNode->text(), constants::networkType, NodeList::Type::custom);
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|
2021-05-02 18:22:38 +00:00
|
|
|
|
2020-10-07 10:36:04 +00:00
|
|
|
return true;
|
2021-05-02 18:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PageNetwork::isComplete() const {
|
|
|
|
if (ui->btnGroup_network->checkedId() == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
FeatherNode node{ui->line_customNode->text()};
|
|
|
|
return node.isValid();
|
2020-10-07 10:36:04 +00:00
|
|
|
}
|