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"
|
2020-10-07 10:36:04 +00:00
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
2021-03-12 18:26:48 +00:00
|
|
|
// Unused for now
|
|
|
|
PageNetwork::PageNetwork(AppContext *ctx, QWidget *parent) :
|
2020-10-07 10:36:04 +00:00
|
|
|
QWizardPage(parent),
|
2021-03-12 18:26:48 +00:00
|
|
|
ui(new Ui::PageNetwork),
|
2020-10-07 10:36:04 +00:00
|
|
|
m_ctx(ctx) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
this->setTitle("Welcome to Feather!");
|
|
|
|
|
|
|
|
ui->customFrame->hide();
|
|
|
|
|
|
|
|
ui->label_eg->setText("Examples:\n- http://127.0.0.1:18089\n- my.node.com\n- my.node.com:18089\n- user:pass@my.node.com:18089");
|
|
|
|
|
|
|
|
auto nodeSourceUInt = config()->get(Config::nodeSource).toUInt();
|
|
|
|
auto nodeSource = static_cast<NodeSource>(nodeSourceUInt);
|
|
|
|
if(nodeSource == NodeSource::websocket){
|
|
|
|
ui->radioRemote->setChecked(true);
|
|
|
|
ui->customFrame->hide();
|
|
|
|
ui->remoteFrame->show();
|
|
|
|
} else if(nodeSource == NodeSource::custom) {
|
|
|
|
ui->radioCustom->setChecked(true);
|
|
|
|
ui->remoteFrame->hide();
|
|
|
|
ui->customFrame->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(ui->networkBtnGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [=](QAbstractButton *button) {
|
|
|
|
auto name = button->objectName();
|
|
|
|
if(name == "radioRemote") {
|
|
|
|
ui->customFrame->hide();
|
|
|
|
ui->remoteFrame->show();
|
|
|
|
} else if(name == "radioCustom") {
|
|
|
|
ui->remoteFrame->hide();
|
|
|
|
ui->customFrame->show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-03-12 18:26:48 +00:00
|
|
|
int PageNetwork::nextId() const {
|
2020-10-07 10:36:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-03-12 18:26:48 +00:00
|
|
|
bool PageNetwork::validatePage() {
|
2020-10-07 10:36:04 +00:00
|
|
|
auto cfg = config()->get(Config::nodeSource);
|
|
|
|
if(ui->radioRemote->isChecked()) {
|
|
|
|
if(cfg != NodeSource::websocket)
|
|
|
|
m_ctx->nodeSourceChanged(NodeSource::websocket);
|
|
|
|
} else if (ui->radioCustom->isChecked()) {
|
|
|
|
if(cfg != NodeSource::custom)
|
|
|
|
m_ctx->nodeSourceChanged(NodeSource::custom);
|
|
|
|
auto nodeText = ui->lineEdit_customNode->text().trimmed();
|
|
|
|
if(!nodeText.isEmpty()) {
|
|
|
|
auto customNodes = m_ctx->nodes->customNodes();
|
2020-11-14 21:42:41 +00:00
|
|
|
auto node = FeatherNode(nodeText);
|
2020-10-07 10:36:04 +00:00
|
|
|
customNodes.append(node);
|
|
|
|
m_ctx->setCustomNodes(customNodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|