9 #include "ui_overviewpage.h"
22 #include <QAbstractItemDelegate>
25 #include <QJsonObject>
27 #include <QJsonDocument>
29 #define DECORATION_SIZE 48
30 #define ICON_OFFSET 16
43 inline void paint(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index)
const
47 QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
48 QRect mainRect = option.rect;
53 int halfheight = (mainRect.height() - 2 * ypad) / 2;
54 QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad, mainRect.width() - xspace -
ICON_OFFSET, halfheight);
55 QRect addressRect(mainRect.left() + xspace, mainRect.top() + ypad + halfheight, mainRect.width() - xspace, halfheight);
56 icon.paint(painter, decorationRect);
59 QString address = index.data(Qt::DisplayRole).toString();
62 QVariant value = index.data(Qt::ForegroundRole);
64 if (value.canConvert<QBrush>()) {
65 QBrush brush = qvariant_cast<QBrush>(value);
66 foreground = brush.color();
69 painter->setPen(foreground);
71 painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, address, &boundingRect);
75 QRect watchonlyRect(boundingRect.right() + 5, mainRect.top() + ypad + halfheight, 16, halfheight);
76 iconWatchonly.paint(painter, watchonlyRect);
82 painter->setPen(foreground);
85 amountText = QString(
"[") + amountText + QString(
"]");
87 painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter, amountText);
95 inline QSize
sizeHint(
const QStyleOptionViewItem& option,
const QModelIndex& index)
const
102 #include "overviewpage.moc"
109 currentUnconfirmedBalance(-1),
110 currentImmatureBalance(-1),
111 currentWatchOnlyBalance(-1),
112 currentWatchUnconfBalance(-1),
113 currentWatchImmatureBalance(-1),
129 manager =
new QNetworkAccessManager(
this);
145 connect(
ui->btnLockUnlock, SIGNAL(clicked()),
this, SLOT(
on_lockUnlock()));
165 double dPercentage = 100.0;
167 sPRCYPercentage =
"(" + QLocale(QLocale::system()).toString(dPercentage,
'f', nPrecision) +
" %)";
170 const CAmount& watchOnlyBalance,
const CAmount& watchUnconfBalance,
const CAmount& watchImmatureBalance)
184 CAmount nSpendableDisplayed = nSpendableBalance;
192 ui->labelBalance_2->setText(
"Locked; Hidden");
193 ui->labelBalance->setText(
"Locked; Hidden");
194 ui->labelUnconfirmed->setText(
"Locked; Hidden");
195 ui->btnLockUnlock->setStyleSheet(
"border-image: url(:/images/lock) 0 0 0 0 stretch stretch; width: 20px;");
196 }
else if (
settings.value(
"fHideBalance",
false).toBool()) {
197 ui->labelBalance_2->setText(
"Hidden");
198 ui->labelBalance->setText(
"Hidden");
199 ui->labelUnconfirmed->setText(
"Hidden");
202 ui->labelBalance_2->setToolTip(
"Your current balance");
205 ui->btnLockUnlock->setStyleSheet(
"border-image: url(:/images/unlock) 0 0 0 0 stretch stretch; width: 30px;");
207 QFont font =
ui->labelBalance_2->font();
208 font.setPointSize(15);
210 ui->labelBalance_2->setFont(font);
219 ui->labelBalance->setIndent(20);
220 ui->labelUnconfirmed->setIndent(20);
228 connect(model, SIGNAL(alertsChanged(QString)),
this, SLOT(
updateAlerts(QString)));
260 filter->setDynamicSortFilter(
true);
261 filter->setSortRole(Qt::EditRole);
270 connect(model, SIGNAL(stakingStatusChanged(
bool)),
this,
272 connect(model, SIGNAL(WalletUnlocked()),
this,
274 connect(model, SIGNAL(encryptionStatusChanged(
int)),
this,
319 this->
ui->labelAlerts->setVisible(!warnings.isEmpty());
320 this->
ui->labelAlerts->setText(warnings);
324 ui->labelWalletStatus->setVisible(fShow);
325 ui->labelPendingText->setVisible(
true);
326 ui->labelUnconfirmed->setVisible(
true);
327 ui->labelBalanceText->setVisible(
true);
330 QString tooltip =
"The displayed information may be out of date. Your wallet automatically synchronizes with the PRCY network after a connection is established, but this process has not completed yet.";
331 ui->labelUnconfirmed->setToolTip(tooltip);
332 ui->labelBalance->setToolTip(tooltip);
334 ui->labelUnconfirmed->setToolTip(
"Your pending balance");
335 ui->labelBalance->setToolTip(
"Your current balance");
341 ui->labelBlockOf->setVisible(fShow);
342 ui->labelBlocksTotal->setVisible(fShow);
347 ui->labelBlockCurrent->setText(QString::number(count));
350 ui->labelBlockStatus->setText(
"(syncing)");
351 ui->labelBlockStatus->setToolTip(
"The displayed information may be out of date. Your wallet automatically synchronizes with the PRCY network after a connection is established, but this process has not completed yet.");
352 ui->labelBlockCurrent->setAlignment((Qt::AlignRight|Qt::AlignVCenter));
354 ui->labelBlockStatus->setText(
"(synced)");
355 ui->labelBlockStatus->setToolTip(
"Your wallet is fully synchronized with the PRCY network.");
356 ui->labelBlockCurrent->setAlignment((Qt::AlignHCenter|Qt::AlignVCenter));
362 ui->labelBlockCurrent->setText(QString::number(count));
404 ui->lblHelp->setText(
ui->lblHelp->text().remove(
"It is advised not to send or receive coins until your current sync is complete."));
419 auto centerX = anchor->parentWidget()->width()/10;
420 auto centerY = anchor->parentWidget()->height()/10;
421 auto angle = float(
animClock->elapsed())*degreesPerSecond/1000;
422 angle = qDegreesToRadians(angle+angleOffset);
423 auto newX = centerX+deltaRadius*qCos(angle);
424 auto newY = centerY+deltaRadius*qSin(angle);
426 animated->setGeometry(newX, newY, anchor->width(), anchor->height());
431 auto width = parent->width()*ratioToParent;
432 auto height = parent->height()*ratioToParent;
433 auto x = (parent->width()-width)/2;
434 auto y = (parent->height()-height)/2;
435 return QRect(x,y,width,height);
446 int highestCount = 0;
448 if (node->nStartingHeight>highestCount)
449 highestCount = node->nStartingHeight;
450 if (highestCount>550){
468 while ( ( item =
ui->verticalLayoutRecent->takeAt( 0 ) ) != NULL )
470 delete item->widget();
475 std::vector<std::map<QString, QString>> txs;
478 std::vector<CWalletTx> latestTxes;
479 for (std::map<uint256, CWalletTx>::iterator tx = txMap.begin(); tx != txMap.end(); ++tx) {
480 if (tx->second.GetDepthInMainChain() > 0) {
481 int64_t txTime = tx->second.GetComputedTxTime();
483 for (
int i = 0; i < (int)latestTxes.size(); i++) {
484 if (txTime >= latestTxes[i].GetComputedTxTime()) {
490 latestTxes.push_back(tx->second);
492 latestTxes.insert(latestTxes.begin() + idx, tx->second);
497 for (
int i = 0; i < (int)latestTxes.size(); i++) {
503 for (
int i = 0; i< length; i++){
505 txHash.
SetHex(txs[i][
"id"].toStdString());
507 ui->verticalLayoutRecent->addWidget(entry);
511 entry->
setData(txTime,
"Locked; Hidden",
"Locked; Hidden",
"Locked; Hidden",
"Locked; Hidden");
512 }
else if (
settings.value(
"fHideBalance",
false).toBool()) {
513 entry->
setData(txTime,
"Hidden",
"Hidden",
"Hidden",
"Hidden");
515 entry->
setData(txTime, txs[i][
"address"] , txs[i][
"amount"], txs[i][
"id"], txs[i][
"type"]);
519 entry->setObjectName(
"secondaryTxEntry");
522 if (latestTxes.size() >= 10000) {
523 QString txWarning =
"Your wallet has more than 10,000 Transactions. It may run slowly. It's recommended to send your funds to a new wallet.";
524 txWarning.append(
" <a href=\"https://prcycoin.com/knowledge-base/wallets/sluggish-large-wallet-dat-solution/\">Need Help?</a>");
525 if (!
ui->lblHelp->text().contains(txWarning)) {
526 ui->lblHelp->setText(
ui->lblHelp->text() +
"<br>" + txWarning);
530 ui->lblRecentTransaction->setVisible(
true);
533 LogPrintf(
"pwalletMain has not been initialized\n");
542 ui->btnLockUnlock->setStyleSheet(
"border-image: url(:/images/unlock) 0 0 0 0 stretch stretch; width: 30px;");
551 QMessageBox::StandardButton msgReply;
552 msgReply = QMessageBox::question(
this,
"Lock Wallet",
"Would you like to lock your wallet now?\n\n(Staking will also be stopped)", QMessageBox::Yes|QMessageBox::No);
553 if (msgReply == QMessageBox::Yes) {
555 ui->btnLockUnlock->setStyleSheet(
"border-image: url(:/images/lock) 0 0 0 0 stretch stretch; width: 20px;");
556 ui->labelBalance_2->setText(
"Locked; Hidden");
557 ui->labelBalance->setText(
"Locked; Hidden");
558 ui->labelUnconfirmed->setText(
"Locked; Hidden");
570 ui->btnLockUnlock->setStyleSheet(
"border-image: url(:/images/lock) 0 0 0 0 stretch stretch; width: 20px;");
572 ui->btnLockUnlock->setStyleSheet(
"border-image: url(:/images/unlock) 0 0 0 0 stretch stretch; width: 30px;");
578 bool fDisplayCurrencyValue =
settings.value(
"fDisplayCurrencyValue").toBool();
579 QString defaultCurrency =
settings.value(
"strDefaultCurrency").toString();
583 ui->labelCurrencyValue->setText(
"");
586 getHttpsJson(
"https://api.coingecko.com/api/v3/simple/price?ids=prcy-coin&vs_currencies=" + defaultCurrency.toStdString() +
"&include_market_cap=false&include_24hr_vol=false&include_24hr_change=false&include_last_updated_at=false");
592 QString defaultCurrency =
settings.value(
"strDefaultCurrency").toString();
593 QString defaultCurrencySymbol;
596 if (defaultCurrency ==
"USD" || defaultCurrency ==
"CAD") {
597 defaultCurrencySymbol =
"$";
598 }
else if (defaultCurrency ==
"EUR") {
599 defaultCurrencySymbol =
"€";
600 }
else if (defaultCurrency ==
"GBP") {
601 defaultCurrencySymbol =
"£";
602 }
else if (defaultCurrency ==
"BTC") {
603 defaultCurrencySymbol =
"₿";
604 }
else if (defaultCurrency ==
"ETH") {
605 defaultCurrencySymbol =
"Ξ";
606 }
else if (defaultCurrency ==
"XAU") {
607 defaultCurrencySymbol =
"XAU";
608 }
else if (defaultCurrency ==
"XAG") {
609 defaultCurrencySymbol =
"XAG";
616 const QJsonObject item = jsonDocument.object();
617 const QJsonObject currency = item[
"prcy-coin"].toObject();
618 auto currencyValue = currency[defaultCurrency.toLower()].toDouble();
624 ui->labelCurrencyValue->setText(defaultCurrency +
" Value: " + defaultCurrencySymbol + QString::number(currentValue,
'f', 2));
626 LogPrintf(
"%s: Error parsing CoinGecko API JSON\n", __func__);