RestoreHeightDialog: rework

This commit is contained in:
tobtoht
2021-05-25 02:26:28 +02:00
parent ba2b0ac550
commit 08d5fd26ff
12 changed files with 203 additions and 346 deletions
+40
View File
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include "RestoreHeightDialog.h"
#include <QLabel>
#include <QVBoxLayout>
#include <QDialogButtonBox>
RestoreHeightDialog::RestoreHeightDialog(QWidget *parent, quint64 currentRestoreHeight)
: QDialog(parent)
, m_restoreHeightWidget(new RestoreHeightWidget(this))
{
auto *layout = new QVBoxLayout(this);
auto *label = new QLabel(this);
label->setText("Enter a wallet creation date or restore height.");
auto *buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
layout->addWidget(label);
layout->addWidget(m_restoreHeightWidget);
layout->addWidget(buttonBox);
this->setLayout(layout);
if (currentRestoreHeight) {
m_restoreHeightWidget->setHeight(currentRestoreHeight);
}
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
this->adjustSize();
}
int RestoreHeightDialog::getHeight() {
return m_restoreHeightWidget->getHeight();
}
+23
View File
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#ifndef FEATHER_RESTOREHEIGHTDIALOG_H
#define FEATHER_RESTOREHEIGHTDIALOG_H
#include <QDialog>
#include "widgets/RestoreHeightWidget.h"
class RestoreHeightDialog : public QDialog
{
Q_OBJECT
public:
explicit RestoreHeightDialog(QWidget *parent = nullptr, quint64 currentRestoreHeight = 0);
int getHeight();
private:
RestoreHeightWidget *m_restoreHeightWidget;
};
#endif //FEATHER_RESTOREHEIGHTDIALOG_H
-38
View File
@@ -1,38 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include "restoredialog.h"
#include "ui_restoredialog.h"
#include "constants.h"
RestoreDialog::RestoreDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
: QDialog(parent)
, ui(new Ui::RestoreDialog)
, m_ctx(std::move(ctx))
{
ui->setupUi(this);
this->setWindowIcon(QIcon("://assets/images/appicons/64x64.png"));
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &RestoreDialog::accepted);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &RestoreDialog::rejected);
if(constants::networkType == NetworkType::Type::TESTNET) {
ui->restoreHeightWidget->hideSlider();
} else {
// load restoreHeight lookup db
ui->restoreHeightWidget->initRestoreHeights(appData()->restoreHeights[constants::networkType]);
}
}
int RestoreDialog::getHeight() {
return ui->restoreHeightWidget->getHeight();
}
void RestoreDialog::initRestoreHeights(RestoreHeightLookup *lookup) {
ui->restoreHeightWidget->initRestoreHeights(lookup);
}
RestoreDialog::~RestoreDialog() {
delete ui;
}
-39
View File
@@ -1,39 +0,0 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#ifndef RESTOREDIALOG_H
#define RESTOREDIALOG_H
#include <QPushButton>
#include <QDialogButtonBox>
#include <QDialog>
#include <QStandardItemModel>
#include <QAbstractButton>
#include "utils/RestoreHeightLookup.h"
#include "appcontext.h"
namespace Ui {
class RestoreDialog;
}
class RestoreDialog : public QDialog
{
Q_OBJECT
public:
explicit RestoreDialog(QSharedPointer<AppContext> ctx, QWidget *parent = nullptr);
void initRestoreHeights(RestoreHeightLookup *lookup);
int getHeight();
~RestoreDialog() override;
signals:
void accepted();
void rejected();
private:
Ui::RestoreDialog *ui;
QSharedPointer<AppContext> m_ctx;
};
#endif // RESTOREDIALOG_H
-56
View File
@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RestoreDialog</class>
<widget class="QDialog" name="RestoreDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>584</width>
<height>99</height>
</rect>
</property>
<property name="windowTitle">
<string>specify restore height</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="RestoreHeightWidget" name="restoreHeightWidget" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>RestoreHeightWidget</class>
<extends>QWidget</extends>
<header>widgets/restoreheightwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>