ui: 3-tier Amount color + conditional Total color (v6.1.6 polish)
Overview Total:
- Was static green in stylesheet (failed to cascade on some Qt builds)
- Now set programmatically in setBalance(): green when total > 0,
red when empty. Stylesheet rule for #labelTotal removed; C++ owns
the color so the rule can react to the balance value.
Transaction amounts (both paint sites, Overview recent-5 + Transactions tab):
- 3-tier rule using existing TransactionStatus enum:
0 confirms (Unconfirmed) -> COLOR_UNCONFIRMED grey (#61280E)
1..3 confs (Confirming) -> COLOR_CONFIRMING pale (#C5EBC9)
4+ confs (Confirmed) -> COLOR_POSITIVE bright (#7CDB8A)
Conflicted -> COLOR_UNCONFIRMED grey
Immature -> olive via .ui (unchanged)
- Negative amounts (spent) stay red across all tiers
- Now matches the icon column's existing state distinction
(transaction_0 / transaction_1..3 / transaction_confirmed)
Files touched:
src/qt/guiconstants.h new COLOR_CONFIRMING constant
src/qt/overviewpage.cpp Total rule + 3-tier amount rule
src/qt/transactiontablemodel.cpp 3-tier amount rule in ForegroundRole
src/qt/forms/overviewpage.ui removed static #labelTotal rule
This commit is contained in:
@@ -13,16 +13,14 @@ static const int STATUSBAR_ICONSIZE = 16;
|
||||
/* Invalid field background style */
|
||||
#define STYLE_INVALID "border: 1px solid #ff0000;background:#1c1c1c;color: #e32105;"
|
||||
|
||||
/* Transaction list -- unconfirmed transaction (text only) */
|
||||
/* Transaction list -- unconfirmed transaction (0 confirms: grey, both directions) */
|
||||
#define COLOR_UNCONFIRMED QColor(97, 40, 14)
|
||||
/* Transaction list -- negative amount (confirmed: spent) */
|
||||
#define COLOR_NEGATIVE QColor(255, 0, 0)
|
||||
/* Transaction list -- positive amount (confirmed: received/mined) */
|
||||
/* Transaction list -- positive amount (fully confirmed, depth >= RecommendedNumConfirmations) */
|
||||
#define COLOR_POSITIVE QColor(124, 219, 138)
|
||||
/* Transaction list -- unconfirmed positive amount (pending credit, dim green) */
|
||||
#define COLOR_UNCONFIRMED_POSITIVE QColor(61, 139, 90)
|
||||
/* Transaction list -- unconfirmed negative amount (pending debit, dim red) */
|
||||
#define COLOR_UNCONFIRMED_NEGATIVE QColor(142, 26, 4)
|
||||
/* Transaction list -- partially confirmed positive amount (1..RecommendedNumConfirmations-1 confirms) */
|
||||
#define COLOR_CONFIRMING QColor(197, 235, 201)
|
||||
/* Transaction list -- bare address (without label) */
|
||||
#define COLOR_BAREADDRESS QColor(97, 40, 14)
|
||||
|
||||
|
||||
@@ -52,11 +52,15 @@ public:
|
||||
|
||||
if(amount < 0)
|
||||
{
|
||||
foreground = confirmed ? COLOR_NEGATIVE : COLOR_UNCONFIRMED_NEGATIVE;
|
||||
foreground = COLOR_NEGATIVE;
|
||||
}
|
||||
else if(!confirmed)
|
||||
{
|
||||
foreground = COLOR_UNCONFIRMED_POSITIVE;
|
||||
foreground = COLOR_UNCONFIRMED;
|
||||
}
|
||||
else if(index.data(TransactionTableModel::StatusRole).toInt() == (int)TransactionStatus::Confirming)
|
||||
{
|
||||
foreground = COLOR_CONFIRMING;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -577,17 +577,28 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
||||
case Qt::TextAlignmentRole:
|
||||
return column_alignments[index.column()];
|
||||
case Qt::ForegroundRole:
|
||||
// Amount column: 4 states — confirmed/unconfirmed × positive/negative.
|
||||
// Other columns fall through to addressColor/etc.
|
||||
// Amount column color rule (3 tiers for positives, 2 for negatives):
|
||||
// 0 confirms (Unconfirmed) -> COLOR_UNCONFIRMED grey
|
||||
// Confirming (1..RecommendedNumConfirmations-1) -> COLOR_CONFIRMING light green (positives only)
|
||||
// Confirmed (depth >= RecommendedNumConfirmations) -> COLOR_POSITIVE bright green
|
||||
// Immature stays olive via stylesheet (unchanged)
|
||||
// Conflicted (depth < 0) -> COLOR_UNCONFIRMED grey
|
||||
// Negative amounts (spent) stay red across all confirmation tiers.
|
||||
if(index.column() == Amount)
|
||||
{
|
||||
qint64 amount = rec->credit + rec->debit;
|
||||
bool unconfirmed = !rec->status.countsForBalance && rec->status.status != TransactionStatus::Immature;
|
||||
if(unconfirmed)
|
||||
// Grey: unconfirmed, conflicted, or otherwise not counting for balance (and not immature)
|
||||
if(!rec->status.countsForBalance && rec->status.status != TransactionStatus::Immature)
|
||||
{
|
||||
return amount < 0 ? COLOR_UNCONFIRMED_NEGATIVE : COLOR_UNCONFIRMED_POSITIVE;
|
||||
return COLOR_UNCONFIRMED;
|
||||
}
|
||||
return amount < 0 ? COLOR_NEGATIVE : COLOR_POSITIVE;
|
||||
// Negative amounts always red (spent), no matter confirmation tier
|
||||
if(amount < 0)
|
||||
{
|
||||
return COLOR_NEGATIVE;
|
||||
}
|
||||
// Positive amounts: lighter green while still confirming, bright green once fully confirmed
|
||||
return rec->status.status == TransactionStatus::Confirming ? COLOR_CONFIRMING : COLOR_POSITIVE;
|
||||
}
|
||||
if(!rec->status.countsForBalance && rec->status.status != TransactionStatus::Immature)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user