mirror of
				https://git.wownero.com/wowlet/wowlet.git
				synced 2024-08-15 01:03:14 +00:00 
			
		
		
		
	Merge pull request 'Wizard: reset restore page on initialize' (#260) from tobtoht/feather:wizard_reset_restore_page into master
Reviewed-on: https://git.wownero.com/feather/feather/pulls/260
This commit is contained in:
		
						commit
						bc2cac672a
					
				
					 4 changed files with 35 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -17,15 +17,10 @@ RestoreHeightWidget::RestoreHeightWidget(QWidget *parent) :
 | 
			
		|||
{
 | 
			
		||||
    ui->setupUi(this);
 | 
			
		||||
    ui->lineEdit_restoreHeight->setValidator(new QIntValidator(0, 2147483647, this));
 | 
			
		||||
    connect(ui->lineEdit_restoreHeight, &QLineEdit::textEdited, [=](const QString &val){
 | 
			
		||||
        // update slider on lineEdit change
 | 
			
		||||
        if(val.isEmpty()) return;
 | 
			
		||||
        auto height = val.toUInt();
 | 
			
		||||
        if(height <= 1) return;
 | 
			
		||||
        auto timestamp = m_restoreHeightLookup->restoreHeightToDate(height);
 | 
			
		||||
        ui->restoreSlider->blockSignals(true);
 | 
			
		||||
        ui->restoreSlider->setValue(timestamp);
 | 
			
		||||
        ui->restoreSlider->blockSignals(false);
 | 
			
		||||
 | 
			
		||||
    connect(ui->lineEdit_restoreHeight, &QLineEdit::textEdited, [this](const QString &val){
 | 
			
		||||
        if (val.isEmpty()) return;
 | 
			
		||||
        this->setHeight(val.toInt());
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -33,6 +28,20 @@ void RestoreHeightWidget::hideSlider(){
 | 
			
		|||
    ui->restoreGrid->hide();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RestoreHeightWidget::setHeight(int height) {
 | 
			
		||||
    if (height < 0)
 | 
			
		||||
        height = 0;
 | 
			
		||||
 | 
			
		||||
    // Update lineEdit
 | 
			
		||||
    ui->lineEdit_restoreHeight->setText(QString::number(height));
 | 
			
		||||
 | 
			
		||||
    // Update slider
 | 
			
		||||
    int date = m_restoreHeightLookup->restoreHeightToDate(height);
 | 
			
		||||
    ui->restoreSlider->setValue(date);
 | 
			
		||||
 | 
			
		||||
    this->updateTimestamp(date);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RestoreHeightWidget::initRestoreHeights(RestoreHeightLookup *lookup) {
 | 
			
		||||
    // init slider
 | 
			
		||||
    m_restoreHeightLookup = lookup;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,15 +49,20 @@ void RestoreHeightWidget::initRestoreHeights(RestoreHeightLookup *lookup) {
 | 
			
		|||
    QList<int> blockDates = m_restoreHeightLookup->data.keys();
 | 
			
		||||
    ui->restoreSlider->setMinimum(blockDates[0]);
 | 
			
		||||
    ui->restoreSlider->setMaximum(now);
 | 
			
		||||
    connect(ui->restoreSlider, &QSlider::valueChanged, this, &RestoreHeightWidget::onValueChanged);
 | 
			
		||||
 | 
			
		||||
    connect(ui->restoreSlider, &QSlider::sliderMoved, [this](int date){
 | 
			
		||||
        // Update lineEdit
 | 
			
		||||
        int blockHeight = m_restoreHeightLookup->dateToRestoreHeight(date);
 | 
			
		||||
        ui->lineEdit_restoreHeight->setText(QString::number(blockHeight));
 | 
			
		||||
 | 
			
		||||
        this->updateTimestamp(date);
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RestoreHeightWidget::onValueChanged(int date) {
 | 
			
		||||
void RestoreHeightWidget::updateTimestamp(int date) {
 | 
			
		||||
    QDateTime timestamp;
 | 
			
		||||
    timestamp.setTime_t(date);
 | 
			
		||||
    ui->label_restoreHeightDate->setText(timestamp.toString("yyyy-MM-dd"));
 | 
			
		||||
    auto blockHeight = m_restoreHeightLookup->dateToRestoreHeight(date);
 | 
			
		||||
    ui->lineEdit_restoreHeight->setText(QString::number(blockHeight));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int RestoreHeightWidget::getHeight() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,14 +20,14 @@ class RestoreHeightWidget : public QWidget
 | 
			
		|||
public:
 | 
			
		||||
    explicit RestoreHeightWidget(QWidget *parent = nullptr);
 | 
			
		||||
    void initRestoreHeights(RestoreHeightLookup *lookup);
 | 
			
		||||
    void setHeight(int height);
 | 
			
		||||
    int getHeight();
 | 
			
		||||
    void hideSlider();
 | 
			
		||||
    ~RestoreHeightWidget() override;
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    void onValueChanged(int date);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void updateTimestamp(int date);
 | 
			
		||||
 | 
			
		||||
    RestoreHeightLookup *m_restoreHeightLookup = nullptr;
 | 
			
		||||
    Ui::RestoreHeightWidget *ui;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,7 +104,10 @@ int RestorePage::nextId() const {
 | 
			
		|||
    return WalletWizard::Page_CreateWallet;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RestorePage::cleanupPage() const {}
 | 
			
		||||
void RestorePage::initializePage() {
 | 
			
		||||
    ui->seedEdit->setText("");
 | 
			
		||||
    ui->restoreHeightWidget->setHeight(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool RestorePage::validatePage() {
 | 
			
		||||
    ui->label_errorString->hide();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,12 +25,11 @@ class RestorePage : public QWizardPage
 | 
			
		|||
public:
 | 
			
		||||
    explicit RestorePage(AppContext *ctx, QWidget *parent = nullptr);
 | 
			
		||||
    bool validatePage() override;
 | 
			
		||||
    void initializePage() override;
 | 
			
		||||
    int nextId() const override;
 | 
			
		||||
    void cleanupPage() const;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    AppContext *m_ctx;
 | 
			
		||||
    QLabel *topLabel;
 | 
			
		||||
    Ui::RestorePage *ui;
 | 
			
		||||
 | 
			
		||||
    int m_mode = 14;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue