2021-05-02 18:22:38 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2023-01-02 19:30:11 +00:00
|
|
|
// SPDX-FileCopyrightText: 2020-2023 The Monero Project
|
2021-05-02 18:22:38 +00:00
|
|
|
|
|
|
|
#include "PageHardwareDevice.h"
|
|
|
|
#include "ui_PageHardwareDevice.h"
|
|
|
|
#include "WalletWizard.h"
|
|
|
|
|
2023-01-24 21:35:47 +00:00
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QDialogButtonBox>
|
2021-05-02 18:22:38 +00:00
|
|
|
#include <QMessageBox>
|
2023-01-24 21:35:47 +00:00
|
|
|
#include <QPushButton>
|
2021-05-02 18:22:38 +00:00
|
|
|
|
2021-05-18 15:59:18 +00:00
|
|
|
PageHardwareDevice::PageHardwareDevice(WizardFields *fields, QWidget *parent)
|
2021-05-02 18:22:38 +00:00
|
|
|
: QWizardPage(parent)
|
|
|
|
, ui(new Ui::PageHardwareDevice)
|
|
|
|
, m_fields(fields)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2021-07-01 21:00:47 +00:00
|
|
|
|
2022-05-23 08:56:11 +00:00
|
|
|
ui->combo_deviceType->addItem("Ledger Nano S (PLUS) / X", DeviceType::LEDGER);
|
|
|
|
ui->combo_deviceType->addItem("Trezor Model T", DeviceType::TREZOR);
|
2023-01-24 21:35:47 +00:00
|
|
|
|
|
|
|
connect(ui->btnOptions, &QPushButton::clicked, this, &PageHardwareDevice::onOptionsClicked);
|
2021-05-02 18:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageHardwareDevice::initializePage() {
|
|
|
|
ui->radioNewWallet->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
int PageHardwareDevice::nextId() const {
|
2023-01-24 21:35:47 +00:00
|
|
|
if (m_fields->showSetRestoreHeightPage) {
|
2021-05-02 18:22:38 +00:00
|
|
|
return WalletWizard::Page_SetRestoreHeight;
|
2023-01-24 21:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return WalletWizard::Page_WalletFile;
|
2021-05-02 18:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool PageHardwareDevice::validatePage() {
|
2021-07-01 21:00:47 +00:00
|
|
|
m_fields->deviceType = static_cast<DeviceType>(ui->combo_deviceType->currentData().toInt());
|
2023-01-24 21:35:47 +00:00
|
|
|
m_fields->showSetRestoreHeightPage = ui->radioRestoreWallet->isChecked();
|
2021-05-02 18:22:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PageHardwareDevice::isComplete() const {
|
|
|
|
return true;
|
2023-01-24 21:35:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PageHardwareDevice::onOptionsClicked() {
|
|
|
|
QDialog dialog(this);
|
|
|
|
dialog.setWindowTitle("Options");
|
|
|
|
|
|
|
|
QVBoxLayout layout;
|
|
|
|
QCheckBox check_subaddressLookahead("Set subaddress lookahead");
|
|
|
|
check_subaddressLookahead.setChecked(m_fields->showSetSubaddressLookaheadPage);
|
|
|
|
|
|
|
|
layout.addWidget(&check_subaddressLookahead);
|
|
|
|
QDialogButtonBox buttons(QDialogButtonBox::Ok);
|
|
|
|
layout.addWidget(&buttons);
|
|
|
|
dialog.setLayout(&layout);
|
|
|
|
connect(&buttons, &QDialogButtonBox::accepted, [&dialog]{
|
|
|
|
dialog.close();
|
|
|
|
});
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_fields->showSetSubaddressLookaheadPage = check_subaddressLookahead.isChecked();
|
2021-05-02 18:22:38 +00:00
|
|
|
}
|