Skip to content
Snippets Groups Projects
Commit f4756458 authored by inso's avatar inso
Browse files

Progress bar showing current progress ( Issue #112 )

parent 8a207a32
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ from ucoinpy.key import SigningKey
import logging
import time
from PyQt5.QtCore import QObject, pyqtSignal, Qt
from PyQt5.QtCore import QObject, pyqtSignal, QCoreApplication
from .wallet import Wallet
from .community import Community
......@@ -182,10 +182,11 @@ class Account(QObject):
self.loading_progressed.emit(account_value, account_max)
for w in self.wallets:
w.refresh_progressed.connect(progressing, type=Qt.DirectConnection)
w.refresh_progressed.connect(progressing)
for c in self.communities:
w.init_cache(c)
loaded_wallets = loaded_wallets + 1
QCoreApplication.processEvents()
def set_display_referential(self, index):
self.referential = index
......
......@@ -15,6 +15,8 @@ from PyQt5.QtCore import pyqtSignal
class BlockchainWatcher(Watcher):
new_transfers = pyqtSignal(list)
loading_progressed = pyqtSignal(int, int)
def __init__(self, account, community):
super().__init__()
self.account = account
......@@ -24,15 +26,26 @@ class BlockchainWatcher(Watcher):
self.last_block = self.community.network.latest_block
def watch(self):
loaded_wallets = 0
def progressing(value, maximum):
account_value = maximum * loaded_wallets + value
account_max = maximum * len(self.account.wallets)
self.loading_progressed.emit(account_value, account_max)
try:
received_list = []
block_number = self.community.network.latest_block
if self.last_block != block_number:
for w in self.account.wallets:
w.refresh_progressed.connect(progressing)
if not self.exiting:
self.community.refresh_cache()
for w in self.account.wallets:
if not self.exiting:
w.refresh_cache(self.community, received_list)
loaded_wallets = loaded_wallets + 1
logging.debug("New block, {0} mined in {1}".format(block_number,
self.community.currency))
......
......@@ -142,8 +142,8 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
@param: block_number: The number of the block mined
'''
logging.debug("Refresh block")
self.tab_history.progressbar.show()
#self.app.monitor.blockchain_watcher(self.community).thread().start()
self.tab_history.start_progress()
self.app.monitor.blockchain_watcher(self.community).thread().start()
self.app.monitor.persons_watcher(self.community).thread().start()
self.refresh_status()
......@@ -158,8 +158,8 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget):
if self.tab_history.table_history.model():
self.tab_history.table_history.model().sourceModel().refresh_transfers()
#self.tab_history.refresh_balance()
self.tab_history.progressbar.hide()
self.tab_history.refresh_balance()
self.tab_history.stop_progress()
self.refresh_status()
@pyqtSlot()
......
......@@ -67,6 +67,18 @@ class TransactionsTabWidget(QWidget, Ui_transactionsTabWidget):
self.refresh_balance()
def start_progress(self):
def progressing(value, maximum):
self.progressbar.setValue(value)
self.progressbar.setMaximum(maximum)
self.progressbar.show()
blockchain_watcher = self.app.monitor.blockchain_watcher(self.community)
blockchain_watcher.loading_progressed.connect(progressing)
def stop_progress(self):
self.progressbar.hide()
def refresh_balance(self):
proxy = self.table_history.model()
balance = proxy.deposits - proxy.payments
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment