TorInfoDialog: allow setting initSyncThreshold

This commit is contained in:
tobtoht 2021-05-26 21:41:14 +02:00
parent 01df614daa
commit 8ec65d8f07
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
3 changed files with 33 additions and 0 deletions

View file

@ -7,9 +7,11 @@
#include <QPushButton>
#include <QDesktopServices>
#include <QMessageBox>
#include <QInputDialog>
#include "utils/TorManager.h"
#include "utils/os/tails.h"
#include "utils/Icons.h"
TorInfoDialog::TorInfoDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
: QDialog(parent)
@ -46,6 +48,9 @@ TorInfoDialog::TorInfoDialog(QSharedPointer<AppContext> ctx, QWidget *parent)
ui->label_changes->hide();
ui->btn_configureInitSync->setIcon(icons()->icon("preferences.svg"));
connect(ui->btn_configureInitSync, &QPushButton::clicked, this, &TorInfoDialog::onShowInitSyncConfigDialog);
#ifndef HAS_TOR_BIN
ui->check_useLocalTor->setChecked(true);
ui->check_useLocalTor->setEnabled(false);
@ -146,6 +151,20 @@ void TorInfoDialog::onStopTor() {
torManager()->stop();
}
void TorInfoDialog::onShowInitSyncConfigDialog() {
int threshold = config()->get(Config::initSyncThreshold).toInt();
bool ok;
int newThreshold = QInputDialog::getInt(this, "Sync threshold",
"Synchronize over clearnet if wallet is behind more than x blocks: ",
threshold, 0, 10000, 10, &ok);
if (ok) {
config()->set(Config::initSyncThreshold, newThreshold);
}
}
TorInfoDialog::~TorInfoDialog() {
delete ui;
}

View file

@ -29,6 +29,7 @@ private slots:
void onApplySettings();
void onSettingsChanged();
void onStopTor();
void onShowInitSyncConfigDialog();
signals:
void torSettingsChanged();

View file

@ -157,6 +157,19 @@
</attribute>
</widget>
</item>
<item>
<widget class="QPushButton" name="btn_configureInitSync">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>