Browse Source

Actually change currency slot, better exception debugging

pull/140/head
Duke Leto 4 years ago
parent
commit
dafdd90976
  1. 12
      src/mainwindow.cpp
  2. 11
      src/rpc.cpp

12
src/mainwindow.cpp

@ -279,7 +279,8 @@ void MainWindow::setupSettingsModal() {
std::string currency_name;
try {
currency_name = Settings::getInstance()->get_currency_name();
} catch (...) {
} catch (const std::exception& e) {
qDebug() << QString("Currency name exception! : ") << e.what();
currency_name = "USD";
}
@ -305,12 +306,13 @@ void MainWindow::setupSettingsModal() {
QMessageBox::information(this, tr("Theme Change"), tr("This change can take a few seconds."), QMessageBox::Ok);
});
// Get Currency Data
// Set local currency
QString ticker = QString::fromStdString( Settings::getInstance()->get_currency_name() );
int currency_index = settings.comboBoxCurrency->findText(ticker, Qt::MatchExactly);
settings.comboBoxCurrency->setCurrentIndex(currency_index);
QObject::connect(settings.comboBoxCurrency, SIGNAL(currentIndexChanged(QString)), this, SLOT(slot_change_currency(QString)));
QObject::connect(settings.comboBoxCurrency, &QComboBox::currentTextChanged, [=] (QString ticker) {
this->slot_change_currency(currency_name);
this->slot_change_currency(ticker.toStdString());
rpc->refresh(true);
QMessageBox::information(this, tr("Currency Change"), tr("This change can take a few seconds."), QMessageBox::Ok);
});
@ -392,6 +394,7 @@ void MainWindow::setupSettingsModal() {
}
if (settingsDialog.exec() == QDialog::Accepted) {
qDebug() << "Setting dialog box accepted";
// Custom fees
bool customFees = settings.chkCustomFees->isChecked();
Settings::getInstance()->setAllowCustomFees(customFees);
@ -610,7 +613,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event) {
}
// Pay the Zcash URI by showing a confirmation window. If the URI parameter is empty, the UI
// Pay the Hush URI by showing a confirmation window. If the URI parameter is empty, the UI
// will prompt for one. If the myAddr is empty, then the default from address is used to send
// the transaction.
void MainWindow::payZcashURI(QString uri, QString myAddr) {
@ -1338,6 +1341,7 @@ void MainWindow::updateLabels() {
void MainWindow::slot_change_currency(const std::string& currency_name)
{
qDebug() << "slot_change_currency"; //<< ": " << currency_name;
Settings::getInstance()->set_currency_name(currency_name);
// Include currency

11
src/rpc.cpp

@ -1129,17 +1129,20 @@ void RPC::refreshPrice() {
const json& item = parsed.get<json::object_t>();
const json& hush = item["hush"].get<json::object_t>();
auto ticker = s->get_currency_name();
std::string ticker = s->get_currency_name();
std::for_each(ticker.begin(), ticker.end(), [](char & c){ c = ::tolower(c); });
fprintf(stderr,"ticker=%s\n", ticker.c_str());
//qDebug() << "Ticker = " + ticker;
//TODO: better check for valid json response
if (hush["usd"] >= 0) {
if (hush[ticker] >= 0) {
qDebug() << "Found hush key in price json";
//QString price = QString::fromStdString(hush["usd"].get<json::string_t>());
qDebug() << "HUSH = $" << QString::number((double)hush["usd"]);
qDebug() << "HUSH = $" << QString::number((double)hush["usd"]) << " USD";
qDebug() << "HUSH = " << QString::number((double)hush["eur"]) << " EUR";
qDebug() << "HUSH = " << QString::number((int) 100000000 * (double) hush["btc"]) << " sat ";
s->setZECPrice( hush["usd"] );
s->setZECPrice( hush[ticker] );
s->setBTCPrice( (unsigned int) 100000000 * (double)hush["btc"] );
std::for_each(ticker.begin(), ticker.end(), [](char & c){ c = ::tolower(c); });

Loading…
Cancel
Save