diff --git a/src/plugins/atomic/AtomicConfigDialog.cpp b/src/plugins/atomic/AtomicConfigDialog.cpp index 6e13216..6b36de5 100644 --- a/src/plugins/atomic/AtomicConfigDialog.cpp +++ b/src/plugins/atomic/AtomicConfigDialog.cpp @@ -9,10 +9,10 @@ #include #include #include -#include -#include -#include "utils/AppData.h" +#include +#include + #include "utils/config.h" #include "utils/Networking.h" @@ -22,10 +22,28 @@ AtomicConfigDialog::AtomicConfigDialog(QWidget *parent) { ui->setupUi(this); - this->fillListWidgets(); - - connect(ui->btn_autoInstall,&QPushButton::clicked, this, &AtomicConfigDialog::downloadBinary); - connect(ui->btn_selectFile,&QPushButton::clicked, this, &AtomicConfigDialog::selectBinary); + ui->downloadLabel->setVisible(false); + connect(ui->btn_autoInstall,&QPushButton::clicked, this, [this] { + /* + 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]{ this->accept(); }); @@ -33,56 +51,6 @@ AtomicConfigDialog::AtomicConfigDialog(QWidget *parent) 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() { auto* network = new Networking(this); download = new QTemporaryFile(this); @@ -98,9 +66,11 @@ void AtomicConfigDialog::downloadBinary() { } else { 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); + ui->downloadLabel->setVisible(true); QStringList answer; - connect(archive,&QNetworkReply::readyRead, this, [&]{ + connect(archive,&QNetworkReply::readyRead, this, [this]{ QByteArray data= archive->readAll(); qDebug() << "received data of size: " << data.size(); download->write(data.constData(), data.size()); @@ -111,7 +81,7 @@ void AtomicConfigDialog::downloadBinary() { void AtomicConfigDialog::extract() { - + ui->downloadLabel->setText("Download Successful, extracting binary to final destination"); qDebug() << "extracting"; download->close(); archive->deleteLater(); @@ -179,6 +149,8 @@ void AtomicConfigDialog::extract() { } qDebug() << "Finished"; binaryFile.close(); + ui->downloadLabel->setText("Swap tool installation complete, Atomic swaps are ready !"); + }; int @@ -205,7 +177,5 @@ AtomicConfigDialog::copy_data(struct archive *ar, struct archive *aw) } } } -void AtomicConfigDialog::selectBinary() { -}; AtomicConfigDialog::~AtomicConfigDialog() = default; \ No newline at end of file diff --git a/src/plugins/atomic/AtomicConfigDialog.h b/src/plugins/atomic/AtomicConfigDialog.h index 0d22aae..6902367 100644 --- a/src/plugins/atomic/AtomicConfigDialog.h +++ b/src/plugins/atomic/AtomicConfigDialog.h @@ -28,11 +28,7 @@ public slots: void extract(); private: - void setCheckState(QListWidget *widget, Qt::CheckState checkState); - QStringList getChecked(QListWidget *widget); - void fillListWidgets(); void downloadBinary(); - void selectBinary(); int copy_data(struct archive *ar, struct archive *aw); QScopedPointer ui; diff --git a/src/plugins/atomic/AtomicConfigDialog.ui b/src/plugins/atomic/AtomicConfigDialog.ui index dfe1990..e4b0ec1 100644 --- a/src/plugins/atomic/AtomicConfigDialog.ui +++ b/src/plugins/atomic/AtomicConfigDialog.ui @@ -6,7 +6,7 @@ 0 0 - 509 + 514 574 @@ -17,46 +17,57 @@ - Qt::Vertical + Qt::Orientation::Vertical - + - + + + + + Auto Install Swap Tool + + + + + + + Select Path to Binary + + + + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Orientation::Horizontal + + + QDialogButtonBox::StandardButton::Close + + + + + + + - Auto Install Swap Tool - - - - - - - Select Path to Binary - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + Downloading swap tool ... this usually takes await cause of tor routing