7 #include "ui_overviewpage.h" 22 #include <QAbstractItemDelegate> 24 #include <validation.h> 27 #define DECORATION_SIZE 54 32 #include <QGraphicsDropShadowEffect> 46 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
47 const QModelIndex &index )
const 52 QRect mainRect = option.rect;
56 int halfheight = (mainRect.height() - 2*ypad)/2;
57 QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight);
58 QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight);
64 icon.paint(painter, decorationRect);
67 QString address = index.data(Qt::DisplayRole).toString();
70 QVariant value = index.data(Qt::ForegroundRole);
72 if(value.canConvert<QBrush>())
74 QBrush brush = qvariant_cast<QBrush>(value);
75 foreground = brush.color();
81 amountText = QString(
"[") + amountText + QString(
"]");
86 GUIUtil::concatenate(painter, address, painter->fontMetrics().width(amountText), addressRect.left(), addressRect.right());
88 painter->setPen(foreground);
90 painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address, &boundingRect);
95 QRect watchonlyRect(boundingRect.right() + 5, mainRect.top()+ypad+halfheight, 16, halfheight);
96 iconWatchonly.paint(painter, watchonlyRect);
112 painter->setPen(foreground);
113 painter->drawText(addressRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
120 painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, assetName);
128 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const 149 inline void paint(QPainter *painter,
const QStyleOptionViewItem &option,
150 const QModelIndex &index )
const 155 QPixmap pixmap = qvariant_cast<QPixmap>(index.data(Qt::DecorationRole));
160 int nIconSize = admin ? pixmap.height() : 0;
161 int extraNameSpacing = 12;
163 extraNameSpacing = 0;
166 QRect mainRect = option.rect;
167 int xspace = nIconSize + 32;
171 QRect gradientRect = mainRect;
172 gradientRect.setTop(gradientRect.top() + 2);
173 gradientRect.setBottom(gradientRect.bottom() - 2);
174 gradientRect.setRight(gradientRect.right() - 20);
176 int halfheight = (gradientRect.height() - 2*ypad)/2;
179 QRect assetAdministratorRect(QPoint(20, gradientRect.top() + halfheight/2 - 3*ypad), QSize(nIconSize, nIconSize));
180 QRect assetNameRect(gradientRect.left() + xspace - extraNameSpacing, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace, halfheight + ypad);
181 QRect amountRect(gradientRect.left() + xspace, gradientRect.top()+ypad+(halfheight/2), gradientRect.width() - xspace - 16, halfheight);
184 QLinearGradient gradient(mainRect.topLeft(), mainRect.bottomRight());
207 path.addRoundedRect(gradientRect, 4, 4);
210 painter->setRenderHint(QPainter::Antialiasing);
211 painter->fillPath(path, gradient);
215 painter->drawPixmap(assetAdministratorRect, pixmap);
219 #if !defined(Q_OS_MAC) 220 nameFont.setFamily(
"Open Sans");
222 nameFont.setPixelSize(18);
223 nameFont.setWeight(QFont::Weight::Normal);
224 nameFont.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, -0.4);
228 #if !defined(Q_OS_MAC) 229 amountFont.setFamily(
"Open Sans");
231 amountFont.setPixelSize(14);
232 amountFont.setWeight(QFont::Weight::Normal);
233 amountFont.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, -0.3);
244 QPen penName(textColor);
249 painter->setFont(amountFont);
250 int amount_width = painter->fontMetrics().width(amountText);
253 painter->setFont(nameFont);
258 painter->setPen(penName);
259 painter->drawText(assetNameRect, Qt::AlignLeft|Qt::AlignVCenter, name);
263 painter->setFont(amountFont);
264 painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText);
269 inline QSize
sizeHint(
const QStyleOptionViewItem &option,
const QModelIndex &index)
const 271 return QSize(42, 42);
278 #include "overviewpage.moc" 280 #include <QFontDatabase> 288 currentUnconfirmedBalance(-1),
289 currentImmatureBalance(-1),
290 currentWatchOnlyBalance(-1),
291 currentWatchUnconfBalance(-1),
292 currentWatchImmatureBalance(-1),
300 icon.addPixmap(icon.pixmap(QSize(64,64), QIcon::Normal), QIcon::Disabled);
301 ui->labelTransactionsStatus->setIcon(icon);
302 ui->labelWalletStatus->setIcon(icon);
303 ui->labelAssetStatus->setIcon(icon);
309 ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect,
false);
313 ui->listAssets->setIconSize(QSize(42, 42));
314 ui->listAssets->setMinimumHeight(5 * (42 + 2));
315 ui->listAssets->viewport()->setAutoFillBackground(
false);
318 static const int input_filter_delay = 200;
320 QTimer *asset_typing_delay;
321 asset_typing_delay =
new QTimer(
this);
322 asset_typing_delay->setSingleShot(
true);
323 asset_typing_delay->setInterval(input_filter_delay);
324 connect(
ui->assetSearch, SIGNAL(textChanged(QString)), asset_typing_delay, SLOT(start()));
328 connect(
ui->listAssets, SIGNAL(clicked(QModelIndex)),
this, SLOT(
handleAssetClicked(QModelIndex)));
337 ui->assetFrame->setStyleSheet(QString(
".QFrame {background-color: %1; padding-top: 10px; padding-right: 5px;}").arg(platformStyle->
WidgetBackGroundColor().name()));
338 ui->frame->setStyleSheet(QString(
".QFrame {background-color: %1; padding-bottom: 10px; padding-right: 5px;}").arg(platformStyle->
WidgetBackGroundColor().name()));
339 ui->frame_2->setStyleSheet(QString(
".QFrame {background-color: %1; padding-left: 5px;}").arg(platformStyle->
WidgetBackGroundColor().name()));
379 ui->assetSearch->setAttribute(Qt::WA_MacShowFocusRect, 0);
380 ui->assetSearch->setStyleSheet(QString(
".QLineEdit {border: 1px solid %1; border-radius: 5px;}").arg(
COLOR_LABELS.name()));
381 ui->assetSearch->setAlignment(Qt::AlignVCenter);
382 QFont font =
ui->assetSearch->font();
383 font.setPointSize(12);
384 ui->assetSearch->setFont(font);
386 QFontMetrics fm = QFontMetrics(
ui->assetSearch->font());
387 ui->assetSearch->setFixedHeight(fm.height()+ 5);
394 sendAction =
new QAction(tr(
"Send Asset"),
this);
395 QAction *copyAmountAction =
new QAction(tr(
"Copy Amount"),
this);
396 QAction *copyNameAction =
new QAction(tr(
"Copy Name"),
this);
397 issueSub =
new QAction(tr(
"Issue Sub Asset"),
this);
398 issueUnique =
new QAction(tr(
"Issue Unique Asset"),
this);
399 reissue =
new QAction(tr(
"Reissue Asset"),
this);
405 reissue->setObjectName(
"Reissue");
406 copyNameAction->setObjectName(
"Copy Name");
407 copyAmountAction->setObjectName(
"Copy Amount");
436 name = name.left(name.size() - 1);
452 if (currentActiveAssetCache && currentActiveAssetCache->GetAssetMetaDataIfExists(name.toStdString(), asset))
458 QAction* action =
contextMenu->exec(QCursor::pos());
461 if (action->objectName() ==
"Send")
463 else if (action->objectName() ==
"Sub")
465 else if (action->objectName() ==
"Unique")
467 else if (action->objectName() ==
"Reissue")
469 else if (action->objectName() ==
"Copy Name")
471 else if (action->objectName() ==
"Copy Amount")
508 bool showImmature = immatureBalance != 0;
509 bool showWatchOnlyImmature = watchImmatureBalance != 0;
512 ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
513 ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
514 ui->labelWatchImmature->setVisible(showWatchOnlyImmature);
520 ui->labelSpendable->setVisible(showWatchOnly);
521 ui->labelWatchonly->setVisible(showWatchOnly);
522 ui->lineWatchBalance->setVisible(showWatchOnly);
523 ui->labelWatchAvailable->setVisible(showWatchOnly);
524 ui->labelWatchPending->setVisible(showWatchOnly);
525 ui->labelWatchTotal->setVisible(showWatchOnly);
528 ui->labelWatchImmature->hide();
537 connect(model, SIGNAL(alertsChanged(QString)),
this, SLOT(
updateAlerts(QString)));
551 filter->setDynamicSortFilter(
true);
552 filter->setSortRole(Qt::EditRole);
553 filter->setShowInactive(
false);
556 ui->listTransactions->setModel(
filter.get());
563 ui->listAssets->setAutoFillBackground(
false);
565 ui->assetVerticalSpaceWidget->setStyleSheet(
"background-color: transparent");
566 ui->assetVerticalSpaceWidget2->setStyleSheet(
"background-color: transparent");
572 connect(model, SIGNAL(balanceChanged(
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount)),
this, SLOT(
setBalance(
CAmount,
CAmount,
CAmount,
CAmount,
CAmount,
CAmount)));
595 ui->listTransactions->update();
601 this->
ui->labelAlerts->setVisible(!warnings.isEmpty());
602 this->
ui->labelAlerts->setText(warnings);
607 ui->labelWalletStatus->setVisible(fShow);
608 ui->labelTransactionsStatus->setVisible(fShow);
610 ui->labelAssetStatus->setVisible(fShow);
617 ui->assetFrame->show();
618 ui->assetBalanceLabel->show();
619 ui->labelAssetStatus->show();
622 ui->assetVerticalSpaceWidget->hide();
623 ui->assetVerticalSpaceWidget2->hide();
625 ui->assetFrame->hide();
626 ui->assetBalanceLabel->hide();
627 ui->labelAssetStatus->hide();
630 ui->assetVerticalSpaceWidget->show();
631 ui->assetVerticalSpaceWidget2->show();
void setWalletModel(WalletModel *walletModel)
void updateAlerts(const QString &warnings)
void assetReissueClicked(const QModelIndex &index)
QGraphicsDropShadowEffect * getShadowEffect()
void concatenate(QPainter *painter, QString &catString, int static_width, int left_side, int right_size)
void handleTransactionClicked(const QModelIndex &index)
std::unique_ptr< TransactionFilterProxy > filter
QString dateTimeStr(const QDateTime &date)
#define COLOR_REGULAR_CARD_LIGHT_BLUE_DARK_MODE
TxViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
CAmount currentWatchOnlyBalance
TxViewDelegate * txdelegate
WalletModel * walletModel
const PlatformStyle * platformStyle
CAmount currentUnconfirmedBalance
#define COLOR_REGULAR_CARD_DARK_BLUE_DARK_MODE
#define COLOR_ADMIN_CARD_DARK
bool haveWatchOnly() const
void outOfSyncWarningClicked()
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
QString getStatusBarWarnings() const
Return warnings to be displayed in status bar.
int getDisplayUnit() const
CAmount getBalance(const CCoinControl *coinControl=nullptr) const
void handleAssetClicked(const QModelIndex &index)
#define COLOR_DARK_ORANGE
QFont getTopLabelFontBolded()
int64_t CAmount
Amount in corbies (Can be negative)
CAmount getImmatureBalance() const
AssetViewDelegate * assetdelegate
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
CAmount currentWatchUnconfBalance
void assetSendClicked(const QModelIndex &index)
bool AreAssetsDeployed()
RVN START.
CAssetsCache * GetCurrentAssetCache()
void setClipboard(const QString &str)
#define STRING_LABEL_COLOR
void updateWatchOnlyLabels(bool showWatchOnly)
CAmount getWatchUnconfirmedBalance() const
Is transaction confirmed?
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Date and time this transaction was created.
TransactionTableModel * getTransactionTableModel()
#define COLOR_UNCONFIRMED
Model for Raven network client.
ClientModel * clientModel
#define COLOR_LIGHT_ORANGE
AssetTableModel * getAssetTableModel()
OverviewPage(const PlatformStyle *platformStyle, QWidget *parent=0)
void transactionClicked(const QModelIndex &index)
const PlatformStyle * platformStyle
#define COLOR_TOOLBAR_NOT_SELECTED_TEXT
void showOutOfSyncWarning(bool fShow)
Net amount of transaction.
void assetIssueUniqueClicked(const QModelIndex &index)
Filter the transaction list according to pre-specified rules.
void setBalance(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance)
Interface to Raven wallet from Qt view code.
CAmount getWatchBalance() const
CAmount getUnconfirmedBalance() const
void assetIssueSubClicked(const QModelIndex &index)
#define COLOR_TOOLBAR_SELECTED_TEXT_DARK_MODE
CAmount currentWatchImmatureBalance
CAmount currentImmatureBalance
AssetViewDelegate(const PlatformStyle *_platformStyle, QObject *parent=nullptr)
void setClientModel(ClientModel *clientModel)
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QFont getTopLabelFont(int weight, int pxsize)
std::unique_ptr< AssetFilterProxy > assetFilter
void handleOutOfSyncWarningClicks()
Formatted amount, without brackets when unconfirmed.
CAmount getWatchImmatureBalance() const
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
Formatted amount, without brackets when unconfirmed.
Overview ("home") page widget.
void assetSearchChanged()
OptionsModel * getOptionsModel()
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.