feather/src/wizard/PageNetwork.cpp

52 lines
1.3 KiB
C++
Raw Normal View History

// SPDX-License-Identifier: BSD-3-Clause
2020-12-26 19:56:06 +00:00
// Copyright (c) 2020-2021, The Monero Project.
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"
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)
{
ui->setupUi(this);
2021-05-02 18:22:38 +00:00
this->setTitle("Welcome to Feather");
2021-05-02 18:22:38 +00:00
ui->frame_customNode->hide();
2021-05-02 18:22:38 +00:00
ui->btnGroup_network->setId(ui->radio_autoConnect, 0);
ui->btnGroup_network->setId(ui->radio_custom, 1);
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();
});
}
2021-03-12 18:26:48 +00:00
int PageNetwork::nextId() const {
2021-05-02 18:22:38 +00:00
return WalletWizard::Page_NetworkTor;
}
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);
}
2021-05-02 18:22:38 +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();
}