Skip to content

Commit

Permalink
Updates for issue navcoin#247
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed May 6, 2019
1 parent f0e6411 commit a721da4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/qt/guiconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#ifndef NAVCOIN_QT_GUICONSTANTS_H
#define NAVCOIN_QT_GUICONSTANTS_H

/* Milliseconds between price updates */
static const int PRICE_UPDATE_DELAY = 300000;

/* Milliseconds between model updates */
static const int MODEL_UPDATE_DELAY = 250;

Expand Down
17 changes: 14 additions & 3 deletions src/qt/navcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,20 @@ NavCoinGUI::NavCoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addStretch();

if (GetArg("-updatefiatperiod",0) > 120000)
updatePrice(); // First price update

int updateFiatPeriod = GetArg("-updatefiatperiod", PRICE_UPDATE_DELAY);
if (updateFiatPeriod >= PRICE_UPDATE_DELAY)
{
QTimer *timerPrice = new QTimer(labelPrice);
connect(timerPrice, SIGNAL(timeout()), this, SLOT(updatePrice()));
timerPrice->start(GetArg("-updatefiatperiod",0));
timerPrice->start(updateFiatPeriod);
info("Automatic price update set to" + std::to_string(updateFiatPeriod) + "ms");
}
else
{
info("Automatic price update turned OFF");
}
updatePrice();

QTimer *timerStakingIcon = new QTimer(labelStakingIcon);
connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingStatus()));
Expand Down Expand Up @@ -1704,6 +1711,8 @@ void NavCoinGUI::updateWeight()

void NavCoinGUI::updatePrice()
{
info("Updating prices");

QNetworkAccessManager *manager = new QNetworkAccessManager();
QNetworkRequest request;
QNetworkReply *reply = NULL;
Expand Down Expand Up @@ -1804,6 +1813,8 @@ void NavCoinGUI::replyFinished(QNetworkReply *reply)
clientModel->getOptionsModel()->setDisplayUnit(clientModel->getOptionsModel()->getDisplayUnit());

reply->deleteLater();

info("Updated prices");
}

void NavCoinGUI::replyVotingFinished(QNetworkReply *reply)
Expand Down
9 changes: 9 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ static inline bool error(std::string s)
{
return error(s.c_str());
}
static inline bool info(const char* s)
{
LogPrintStr(std::string("INFO: ") + s + "\n");
return false;
}
static inline bool info(std::string s)
{
return error(s.c_str());
}
void PrintExceptionContinue(const std::exception *pex, const char* pszThread);
void ParseParameters(int argc, const char*const argv[]);
void FileCommit(FILE *fileout);
Expand Down

0 comments on commit a721da4

Please sign in to comment.