feather/src/dialog/LocalMoneroInfoDialog.cpp

49 lines
1.7 KiB
C++
Raw Normal View History

2021-05-02 18:22:38 +00:00
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2020-2021, The Monero Project.
#include "LocalMoneroInfoDialog.h"
#include "ui_LocalMoneroInfoDialog.h"
#include "utils/config.h"
2021-07-06 19:36:27 +00:00
#include "utils/Utils.h"
2021-05-02 18:22:38 +00:00
LocalMoneroInfoDialog::LocalMoneroInfoDialog(QWidget *parent, LocalMoneroModel *model, int row)
: QDialog(parent)
, ui(new Ui::LocalMoneroInfoDialog)
, m_model(model)
, m_row(row)
{
ui->setupUi(this);
setLabelText(ui->label_price, LocalMoneroModel::PriceXMR);
setLabelText(ui->label_seller, LocalMoneroModel::Seller);
setLabelText(ui->label_paymentMethod, LocalMoneroModel::PaymentMethod);
setLabelText(ui->label_paymentDetail, LocalMoneroModel::PaymentMethodDetail);
setLabelText(ui->label_tradeLimits, LocalMoneroModel::Limits);
QJsonObject offerData = model->getOffer(row);
QString details = offerData["data"].toObject()["msg"].toString();
details.remove("*");
if (details.isEmpty()) {
details = "No details.";
}
ui->info->setPlainText(details);
connect(ui->btn_goToOffer, &QPushButton::clicked, this, &LocalMoneroInfoDialog::onGoToOffer);
}
void LocalMoneroInfoDialog::setLabelText(QLabel *label, LocalMoneroModel::Column column) {
QString data = m_model->data(m_model->index(m_row, column)).toString();
label->setText(data);
}
void LocalMoneroInfoDialog::onGoToOffer() {
QJsonObject offerData = m_model->getOffer(m_row);
QString frontend = config()->get(Config::localMoneroFrontend).toString();
QString offerUrl = QString("%1/ad/%2").arg(frontend, offerData["data"].toObject()["ad_id"].toString());
Utils::externalLinkWarning(this, offerUrl);
}
2021-06-27 12:13:05 +00:00
LocalMoneroInfoDialog::~LocalMoneroInfoDialog() = default;