mirror of
https://github.com/feather-wallet/feather.git
synced 2025-03-21 22:48:44 +00:00
Swap tool auto downloader finished, browse finished, and ui updates
This commit is contained in:
parent
435a75d453
commit
e6aac4eb25
3 changed files with 77 additions and 100 deletions
|
@ -9,10 +9,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <archive.h>
|
#include <archive.h>
|
||||||
#include <zip.h>
|
#include <zip.h>
|
||||||
#include <zlib.h>
|
|
||||||
#include <archive_entry.h>
|
|
||||||
|
|
||||||
#include "utils/AppData.h"
|
#include <archive_entry.h>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
#include "utils/Networking.h"
|
#include "utils/Networking.h"
|
||||||
|
|
||||||
|
@ -22,10 +22,28 @@ AtomicConfigDialog::AtomicConfigDialog(QWidget *parent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
this->fillListWidgets();
|
ui->downloadLabel->setVisible(false);
|
||||||
|
connect(ui->btn_autoInstall,&QPushButton::clicked, this, [this] {
|
||||||
connect(ui->btn_autoInstall,&QPushButton::clicked, this, &AtomicConfigDialog::downloadBinary);
|
/*
|
||||||
connect(ui->btn_selectFile,&QPushButton::clicked, this, &AtomicConfigDialog::selectBinary);
|
QMessageBox downloadPopup = QMessageBox(this);
|
||||||
|
qDebug() << "opening popup";
|
||||||
|
downloadPopup.setText("Downloading swap tool, this usually takes about a minute or two, please wait");
|
||||||
|
downloadPopup.setWindowTitle("Swap tool download");
|
||||||
|
downloadPopup.show();
|
||||||
|
qApp->processEvents();
|
||||||
|
*/
|
||||||
|
AtomicConfigDialog::downloadBinary();
|
||||||
|
});
|
||||||
|
connect(ui->btn_selectFile,&QPushButton::clicked, this, [this] {
|
||||||
|
QString path = QFileDialog::getOpenFileName(this, "Select swap binary file",
|
||||||
|
Config::defaultConfigDir().absolutePath(),
|
||||||
|
"Binary Executable (*)");
|
||||||
|
Config::instance()->set(Config::swapPath, path);
|
||||||
|
if(path.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
close();
|
||||||
|
});
|
||||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this]{
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this]{
|
||||||
this->accept();
|
this->accept();
|
||||||
});
|
});
|
||||||
|
@ -33,56 +51,6 @@ AtomicConfigDialog::AtomicConfigDialog(QWidget *parent)
|
||||||
this->adjustSize();
|
this->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AtomicConfigDialog::setCheckState(QListWidget *widget, Qt::CheckState checkState) {
|
|
||||||
QListWidgetItem *item;
|
|
||||||
for (int i=0; i < widget->count(); i++) {
|
|
||||||
item = widget->item(i);
|
|
||||||
item->setCheckState(checkState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList AtomicConfigDialog::getChecked(QListWidget *widget) {
|
|
||||||
QStringList checked;
|
|
||||||
QListWidgetItem *item;
|
|
||||||
for (int i=0; i < widget->count(); i++) {
|
|
||||||
item = widget->item(i);
|
|
||||||
if (item->checkState() == Qt::Checked) {
|
|
||||||
checked.append(item->text());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return checked;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void AtomicConfigDialog::fillListWidgets() {
|
|
||||||
QStringList cryptoCurrencies = appData()->prices.markets.keys();
|
|
||||||
QStringList fiatCurrencies = appData()->prices.rates.keys();
|
|
||||||
|
|
||||||
QStringList checkedCryptoCurrencies = conf()->get(Config::cryptoSymbols).toStringList();
|
|
||||||
QStringList checkedFiatCurrencies = conf()->get(Config::fiatSymbols).toStringList();
|
|
||||||
|
|
||||||
|
|
||||||
auto setChecked = [](QListWidget *widget, const QStringList &checked){
|
|
||||||
QListWidgetItem *item;
|
|
||||||
for (int i=0; i < widget->count(); i++) {
|
|
||||||
item = widget->item(i);
|
|
||||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
|
||||||
if (checked.contains(item->text())) {
|
|
||||||
item->setCheckState(Qt::Checked);
|
|
||||||
} else {
|
|
||||||
item->setCheckState(Qt::Unchecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomicConfigDialog::downloadBinary() {
|
void AtomicConfigDialog::downloadBinary() {
|
||||||
auto* network = new Networking(this);
|
auto* network = new Networking(this);
|
||||||
download = new QTemporaryFile(this);
|
download = new QTemporaryFile(this);
|
||||||
|
@ -98,9 +66,11 @@ void AtomicConfigDialog::downloadBinary() {
|
||||||
} else {
|
} else {
|
||||||
url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.12.3/swap_0.12.3_Darwin_x86_64.tar");
|
url = QString("https://github.com/comit-network/xmr-btc-swap/releases/download/0.12.3/swap_0.12.3_Darwin_x86_64.tar");
|
||||||
}
|
}
|
||||||
|
|
||||||
archive = network->get(this, url);
|
archive = network->get(this, url);
|
||||||
|
ui->downloadLabel->setVisible(true);
|
||||||
QStringList answer;
|
QStringList answer;
|
||||||
connect(archive,&QNetworkReply::readyRead, this, [&]{
|
connect(archive,&QNetworkReply::readyRead, this, [this]{
|
||||||
QByteArray data= archive->readAll();
|
QByteArray data= archive->readAll();
|
||||||
qDebug() << "received data of size: " << data.size();
|
qDebug() << "received data of size: " << data.size();
|
||||||
download->write(data.constData(), data.size());
|
download->write(data.constData(), data.size());
|
||||||
|
@ -111,7 +81,7 @@ void AtomicConfigDialog::downloadBinary() {
|
||||||
|
|
||||||
void AtomicConfigDialog::extract() {
|
void AtomicConfigDialog::extract() {
|
||||||
|
|
||||||
|
ui->downloadLabel->setText("Download Successful, extracting binary to final destination");
|
||||||
qDebug() << "extracting";
|
qDebug() << "extracting";
|
||||||
download->close();
|
download->close();
|
||||||
archive->deleteLater();
|
archive->deleteLater();
|
||||||
|
@ -179,6 +149,8 @@ void AtomicConfigDialog::extract() {
|
||||||
}
|
}
|
||||||
qDebug() << "Finished";
|
qDebug() << "Finished";
|
||||||
binaryFile.close();
|
binaryFile.close();
|
||||||
|
ui->downloadLabel->setText("Swap tool installation complete, Atomic swaps are ready !");
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
int
|
int
|
||||||
|
@ -205,7 +177,5 @@ AtomicConfigDialog::copy_data(struct archive *ar, struct archive *aw)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void AtomicConfigDialog::selectBinary() {
|
|
||||||
|
|
||||||
};
|
|
||||||
AtomicConfigDialog::~AtomicConfigDialog() = default;
|
AtomicConfigDialog::~AtomicConfigDialog() = default;
|
|
@ -28,11 +28,7 @@ public slots:
|
||||||
void extract();
|
void extract();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setCheckState(QListWidget *widget, Qt::CheckState checkState);
|
|
||||||
QStringList getChecked(QListWidget *widget);
|
|
||||||
void fillListWidgets();
|
|
||||||
void downloadBinary();
|
void downloadBinary();
|
||||||
void selectBinary();
|
|
||||||
int copy_data(struct archive *ar, struct archive *aw);
|
int copy_data(struct archive *ar, struct archive *aw);
|
||||||
|
|
||||||
QScopedPointer<Ui::AtomicConfigDialog> ui;
|
QScopedPointer<Ui::AtomicConfigDialog> ui;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>509</width>
|
<width>514</width>
|
||||||
<height>574</height>
|
<height>574</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -17,10 +17,12 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line">
|
<widget class="Line" name="line">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Orientation::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
@ -40,7 +42,7 @@
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
|
@ -53,10 +55,19 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::StandardButton::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="downloadLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Downloading swap tool ... this usually takes await cause of tor routing</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue