Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add used balance to overview page #775

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions src/qt/forms/overviewpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,40 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<item row="4" column="0">
<widget class="QLabel" name="labelUsedText">
<property name="text">
<string>Used:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="labelUsed">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="toolTip">
<string>Your current used balance</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the space is tiny, and the impact should be big, every word in an effective tooltip needs to pack a punch.

Source: Internet

as the tooltip for the "used" line of the "balances" block,
"your current used balance" doesnt feel like a great tooltip

</property>
<property name="text">
<string notr="true">21 000 000.00000000 BTC</string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="5" column="2">
<widget class="Line" name="lineWatchBalance">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand All @@ -194,7 +220,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="labelTotalText">
<property name="text">
<string>Total:</string>
Expand Down Expand Up @@ -240,7 +266,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="labelTotal">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand All @@ -259,7 +285,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<item row="6" column="2">
<widget class="QLabel" name="labelWatchTotal">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
Expand Down
10 changes: 10 additions & 0 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ void OverviewPage::setBalance(const interfaces::WalletBalances& balances)
ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature);
ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature);
ui->labelWatchImmature->setVisible(!walletModel->wallet().privateKeysDisabled() && showWatchOnlyImmature); // show watch-only immature balance

// only show used balance when on wallet with 'avoid_reuse' flag
bool showUsed = walletModel->isAvoidReuseEnabled();

if (showUsed) {
ui->labelUsed->setText(BitcoinUnits::formatWithPrivacy(unit, balances.used, BitcoinUnits::SeparatorStyle::ALWAYS, m_privacy));
}
ui->labelUsedText->setVisible(showUsed);
ui->labelUsed->setVisible(showUsed);
}

// show/hide watch-only labels
Expand Down Expand Up @@ -352,4 +361,5 @@ void OverviewPage::setMonospacedFont(bool use_embedded_font)
ui->labelWatchPending->setFont(f);
ui->labelWatchImmature->setFont(f);
ui->labelWatchTotal->setFont(f);
ui->labelUsed->setFont(f);
}
5 changes: 5 additions & 0 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ bool WalletModel::isMultiwallet() const
return m_node.walletLoader().getWallets().size() > 1;
}

bool WalletModel::isAvoidReuseEnabled() const
{
return m_wallet->isAvoidReuseEnabled();
}

void WalletModel::refresh(bool pk_hash_only)
{
addressTableModel = new AddressTableModel(this, pk_hash_only);
Expand Down
2 changes: 2 additions & 0 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ class WalletModel : public QObject

bool isMultiwallet() const;

bool isAvoidReuseEnabled() const;

void refresh(bool pk_hash_only = false);

uint256 getLastBlockProcessed() const;
Expand Down
Loading