PIVX Core  5.6.99
P2P Digital Currency
txrow.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 The PIVX Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include "txrow.h"
6 #include "ui_txrow.h"
7 
8 #include "guiutil.h"
9 #include "qtutils.h"
10 
11 TxRow::TxRow(QWidget *parent) :
12  QWidget(parent),
13  ui(new Ui::TxRow)
14 {
15  ui->setupUi(this);
16  ui->lblAmountBottom->setVisible(false);
17 }
18 
20 {
21  setConfirmStatus(true);
22  updateStatus(isLightTheme, false, false);
23 }
24 
25 void TxRow::showHideSecondAmount(bool show) {
26  if (show != isDoubleAmount) {
27  isDoubleAmount = show;
28  ui->lblAmountBottom->setVisible(show);
29  }
30 }
31 
32 void TxRow::setConfirmStatus(bool isConfirm){
33  if(isConfirm){
34  setCssProperty(ui->lblAddress, "text-list-body1");
35  setCssProperty(ui->lblDate, "text-list-caption");
36  } else {
37  setCssProperty(ui->lblAddress, "text-list-body-unconfirmed");
38  setCssProperty(ui->lblDate,"text-list-caption-unconfirmed");
39  }
40 }
41 
42 void TxRow::updateStatus(bool isLightTheme, bool isHover, bool isSelected)
43 {
44  if (isLightTheme)
45  ui->lblDivisory->setStyleSheet("background-color:#bababa");
46  else
47  ui->lblDivisory->setStyleSheet("background-color:#40ffffff");
48 }
49 
50 void TxRow::setDate(QDateTime date)
51 {
52  ui->lblDate->setText(GUIUtil::dateTimeStr(date));
53 }
54 
55 void TxRow::setLabel(QString str)
56 {
57  ui->lblAddress->setText(str);
58 }
59 
60 void TxRow::setAmount(QString top, QString bottom)
61 {
62  ui->lblAmountTop->setText(top);
63  ui->lblAmountBottom->setText(bottom);
64 }
65 
66 void TxRow::setType(bool isLightTheme, int type, bool isConfirmed)
67 {
68  QString path;
69  QString css;
70  QString cssAmountBottom;
71  bool sameIcon = false;
72  switch (type) {
74  path = "://ic-transaction-mint";
75  css = "text-list-amount-send";
76  break;
82  path = "://ic-transaction-staked";
83  css = "text-list-amount-receive";
84  break;
89  path = "://ic-transaction-received";
90  css = "text-list-amount-receive";
91  break;
93  path = "://ic-transaction-received-memo";
94  css = "text-list-amount-receive";
95  break;
103  path = "://ic-transaction-sent";
104  css = "text-list-amount-send";
105  break;
108  path = "://ic-transaction-mint";
109  css = "text-list-amount-send";
110  break;
112  path = "://ic-transaction-stake-delegated";
113  css = "text-list-amount-receive";
114  break;
116  path = "://ic-transaction-stake-hot";
117  css = "text-list-amount-unconfirmed";
118  break;
121  path = "://ic-transaction-cs-contract";
122  css = "text-list-amount-send";
123  break;
125  path = "://ic-transaction-cs-contract";
126  css = "text-list-amount-unconfirmed";
127  break;
130  path = "://ic-transaction-cs-contract";
131  css = "text-list-amount-send";
132  break;
135  path = "://ic-transaction-mint";
136  css = "text-list-amount-unconfirmed";
137  cssAmountBottom = "text-list-amount-send-small";
138  break;
139  default:
140  path = "://ic-pending";
141  sameIcon = true;
142  css = "text-list-amount-unconfirmed";
143  break;
144  }
145 
146  if (!isLightTheme && !sameIcon){
147  path += "-dark";
148  }
149 
150  if (!isConfirmed){
151  css = "text-list-amount-unconfirmed";
152  cssAmountBottom = "text-list-amount-unconfirmed";
153  path += "-inactive";
154  setConfirmStatus(false);
155  } else {
156  setConfirmStatus(true);
157  }
158  setCssProperty(ui->lblAmountTop, css, true);
159  if (isDoubleAmount) setCssProperty(ui->lblAmountBottom, cssAmountBottom, true);
160  ui->icon->setIcon(QIcon(path));
161 }
162 
164 {
165  delete ui;
166 }
Definition: txrow.h:17
void showHideSecondAmount(bool show)
Definition: txrow.cpp:25
void init(bool isLightTheme)
Definition: txrow.cpp:19
bool isConfirmed
Definition: txrow.h:36
void setDate(QDateTime)
Definition: txrow.cpp:50
void setConfirmStatus(bool isConfirmed)
Definition: txrow.cpp:32
bool isDoubleAmount
Definition: txrow.h:37
TxRow(QWidget *parent=nullptr)
Definition: txrow.cpp:11
~TxRow()
Definition: txrow.cpp:163
void updateStatus(bool isLightTheme, bool isHover, bool isSelected)
Definition: txrow.cpp:42
void setLabel(QString)
Definition: txrow.cpp:55
void setAmount(QString top, QString bottom)
Definition: txrow.cpp:60
Ui::TxRow * ui
Definition: txrow.h:35
void setType(bool isLightTheme, int type, bool isConfirmed)
Definition: txrow.cpp:66
QString dateTimeStr(const QDateTime &date)
Definition: guiutil.cpp:69
bool isLightTheme()
Definition: qtutils.cpp:210
void setCssProperty(std::initializer_list< QWidget * > args, const QString &value)
Definition: qtutils.cpp:334