Browse Source

Merge #934: Auto expand internal addresses that has non zero balances

0e2850acf2 Auto expand internal addresses that has non zero balances, and only auto expand the external addresses of mix depth 0. (Wukong)

Pull request description:

  1. For internal addresses that has non zero balances, auto expand them as user will most likely be interested in checking the details of those addresses
  2. For external addresses, only auto-expand for mixdepth 0 as that's where user will most likely make deposits to.

ACKs for top commit:
  kristapsk:
    ACK 0e2850acf2

Tree-SHA512: 6cd397ff276e16a925d0668466bc013d53a3806e37d57c1a933429d6b8dfa761799c1e5f8fd81e28df7ac655583a42afc17db541f1015b2c280de60cd0f03e58
master
Kristaps Kaupe 4 years ago
parent
commit
71bf06dbe2
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 85
      scripts/joinmarket-qt.py

85
scripts/joinmarket-qt.py

@ -1464,71 +1464,84 @@ class JMWalletTab(QWidget):
popup.show() popup.show()
def updateWalletInfo(self, walletinfo=None): def updateWalletInfo(self, walletinfo=None):
nm = jm_single().config.getint("GUI", "max_mix_depth") max_mixdepth_count = jm_single().config.getint("GUI", "max_mix_depth")
l = self.walletTree
previous_expand_states = []
# before deleting, note whether items were expanded # before deleting, note whether items were expanded
esrs = [] for i in range(self.walletTree.topLevelItemCount()):
for i in range(l.topLevelItemCount()): tli = self.walletTree.invisibleRootItem().child(i)
tli = l.invisibleRootItem().child(i)
# must check top and also the two subitems (branches): # must check top and also the two subitems (branches):
expandedness = tuple( expandedness = tuple(
x.isExpanded() for x in [tli, tli.child(0), tli.child(1)]) x.isExpanded() for x in [tli, tli.child(0), tli.child(1)])
esrs.append(expandedness) previous_expand_states.append(expandedness)
l.clear()
if walletinfo: self.walletTree.clear()
rows, mbalances, xpubs, total_bal = walletinfo
if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "regtest": # Skip the remaining of this method if wallet info doesn't exist
self.wallet_name = mainWindow.testwalletname if walletinfo == None:
return
rows, mbalances, xpubs, total_bal = walletinfo
if jm_single().config.get("BLOCKCHAIN", "blockchain_source") == "regtest":
self.wallet_name = mainWindow.testwalletname
else:
self.wallet_name = os.path.basename(
mainWindow.wallet_service.get_storage_location())
if total_bal is None:
if jm_single().bc_interface is not None:
total_bal = " (syncing..)"
else: else:
self.wallet_name = os.path.basename( total_bal = " (unknown, no blockchain source available)"
mainWindow.wallet_service.get_storage_location()) self.label1.setText("CURRENT WALLET: " + self.wallet_name +
if total_bal is None: ', total balance: ' + total_bal)
if jm_single().bc_interface is not None: self.walletTree.show()
total_bal = " (syncing..)"
else:
total_bal = " (unknown, no blockchain source available)"
self.label1.setText("CURRENT WALLET: " + self.wallet_name +
', total balance: ' + total_bal)
l.show()
if jm_single().bc_interface is None and self.wallet_name != 'NONE': if jm_single().bc_interface is None and self.wallet_name != 'NONE':
return return
for i in range(nm): for mixdepth in range(max_mixdepth_count):
if walletinfo: if walletinfo:
mdbalance = mbalances[i] mdbalance = mbalances[mixdepth]
else: else:
mdbalance = "{0:.8f}".format(0) mdbalance = "{0:.8f}".format(0)
m_item = QTreeWidgetItem(["Mixdepth " + str(i) + " , balance: " + m_item = QTreeWidgetItem(["Mixdepth " + str(mixdepth) + " , balance: " +
mdbalance, '', '', '', '']) mdbalance, '', '', '', ''])
l.addChild(m_item) self.walletTree.addChild(m_item)
# if expansion states existed, reinstate them: # if expansion states existed, reinstate them:
if len(esrs) == nm: if len(previous_expand_states) == max_mixdepth_count:
m_item.setExpanded(esrs[i][0]) m_item.setExpanded(previous_expand_states[mixdepth][0])
# by default, if the balance of the mix depth is greater than 0, expand it
elif float(mdbalance) > 0:
m_item.setExpanded(True)
for forchange in [0, 1]: for forchange in [0, 1]:
heading = "EXTERNAL" if forchange == 0 else "INTERNAL" heading = "EXTERNAL" if forchange == 0 else "INTERNAL"
if walletinfo and heading == "EXTERNAL": if walletinfo and heading == "EXTERNAL":
heading_end = ' ' + xpubs[i][forchange] heading_end = ' ' + xpubs[mixdepth][forchange]
heading += heading_end heading += heading_end
seq_item = QTreeWidgetItem([heading, '', '', '', '']) seq_item = QTreeWidgetItem([heading, '', '', '', ''])
m_item.addChild(seq_item) m_item.addChild(seq_item)
# by default, external is expanded, but remember user choice:
if not forchange: # by default, the external addresses of mixdepth 0 is expanded
seq_item.setExpanded(True) should_expand = mixdepth == 0 and not forchange
if len(esrs) == nm:
seq_item.setExpanded(esrs[i][forchange+1])
if not walletinfo: if not walletinfo:
item = QTreeWidgetItem(['None', '', '', '']) item = QTreeWidgetItem(['None', '', '', ''])
seq_item.addChild(item) seq_item.addChild(item)
else: else:
for j in range(len(rows[i][forchange])): for j in range(len(rows[mixdepth][forchange])):
item = QTreeWidgetItem(rows[i][forchange][j]) item = QTreeWidgetItem(rows[mixdepth][forchange][j])
item.setFont(0, QFont(MONOSPACE_FONT)) item.setFont(0, QFont(MONOSPACE_FONT))
if rows[i][forchange][j][3] != 'new': if rows[mixdepth][forchange][j][3] != 'new':
item.setForeground(3, QBrush(QColor('red'))) item.setForeground(3, QBrush(QColor('red')))
# by default, if the balance is non zero, it is also expanded
if float(rows[mixdepth][forchange][j][2]) > 0:
should_expand = True
seq_item.addChild(item) seq_item.addChild(item)
# Remember user choice, if expansion states existed, reinstate them:
if len(previous_expand_states) == max_mixdepth_count:
should_expand = previous_expand_states[mixdepth][forchange+1]
seq_item.setExpanded(should_expand)
class JMMainWindow(QMainWindow): class JMMainWindow(QMainWindow):

Loading…
Cancel
Save