feather/src/wizard/PageHardwareDevice.cpp

66 lines
1.9 KiB
C++
Raw Normal View History

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"
#include <QCheckBox>
#include <QDialogButtonBox>
2021-05-02 18:22:38 +00:00
#include <QMessageBox>
#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);
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 {
if (m_fields->showSetRestoreHeightPage) {
2021-05-02 18:22:38 +00:00
return WalletWizard::Page_SetRestoreHeight;
}
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());
m_fields->showSetRestoreHeightPage = ui->radioRestoreWallet->isChecked();
2021-05-02 18:22:38 +00:00
return true;
}
bool PageHardwareDevice::isComplete() const {
return true;
}
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
}