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

Refresh animation during blockchain loading

parent a8b52928
No related branches found
No related tags found
No related merge requests found
<RCC> <RCC>
<qresource prefix="icons"> <qresource prefix="icons">
<file alias="loader">loader.gif</file>
<file alias="guest_icon">noun_178537_cc.svg</file> <file alias="guest_icon">noun_178537_cc.svg</file>
<file alias="menu_icon">noun_100552_cc.svg</file> <file alias="menu_icon">noun_100552_cc.svg</file>
<file alias="leave_icon">noun_155520_cc.svg</file> <file alias="leave_icon">noun_155520_cc.svg</file>
......
res/icons/loader.gif

4.18 KiB

...@@ -52,6 +52,8 @@ class Application(QObject): ...@@ -52,6 +52,8 @@ class Application(QObject):
sources_refreshed = pyqtSignal() sources_refreshed = pyqtSignal()
new_blocks_handled = pyqtSignal() new_blocks_handled = pyqtSignal()
view_in_wot = pyqtSignal(Identity) view_in_wot = pyqtSignal(Identity)
refresh_started = pyqtSignal()
refresh_finished = pyqtSignal()
qapp = attr.ib() qapp = attr.ib()
loop = attr.ib() loop = attr.ib()
......
...@@ -87,6 +87,8 @@ class MainWindowController(QObject): ...@@ -87,6 +87,8 @@ class MainWindowController(QObject):
main_window.view.showMaximized() main_window.view.showMaximized()
else: else:
main_window.view.show() main_window.view.show()
app.refresh_started.connect(main_window.status_bar.start_loading)
app.refresh_finished.connect(main_window.status_bar.stop_loading)
main_window.model.load_plugins(main_window) main_window.model.load_plugins(main_window)
main_window.refresh(app.currency) main_window.refresh(app.currency)
return main_window return main_window
......
...@@ -14,8 +14,8 @@ class StatusBarController(QObject): ...@@ -14,8 +14,8 @@ class StatusBarController(QObject):
""" """
Constructor of the navigation component Constructor of the navigation component
:param sakia.gui.status_bar.view.StatusBarView view: the presentation :param sakia.gui.main_window.status_bar.view.StatusBarView view: the presentation
:param sakia.core.status_bar.model.StatusBarModel model: the model :param sakia.gui.main_window.status_bar.model.StatusBarModel model: the model
""" """
super().__init__() super().__init__()
self.view = view self.view = view
...@@ -53,6 +53,12 @@ class StatusBarController(QObject): ...@@ -53,6 +53,12 @@ class StatusBarController(QObject):
timer.timeout.connect(self.update_time) timer.timeout.connect(self.update_time)
timer.start(1000) timer.start(1000)
def start_loading(self):
self.view.start_loading()
def stop_loading(self):
self.view.stop_loading()
def new_blocks_handled(self): def new_blocks_handled(self):
current_block = self.model.current_block() current_block = self.model.current_block()
current_time = self.model.current_time() current_time = self.model.current_time()
......
from PyQt5.QtWidgets import QStatusBar from PyQt5.QtWidgets import QStatusBar
from PyQt5.QtWidgets import QLabel, QComboBox from PyQt5.QtWidgets import QLabel, QComboBox, QSpacerItem, QSizePolicy
from PyQt5.QtCore import Qt from PyQt5.QtGui import QMovie
from PyQt5.QtCore import Qt, QSize
class StatusBarView(QStatusBar): class StatusBarView(QStatusBar):
...@@ -10,7 +11,6 @@ class StatusBarView(QStatusBar): ...@@ -10,7 +11,6 @@ class StatusBarView(QStatusBar):
def __init__(self, parent): def __init__(self, parent):
super().__init__(parent) super().__init__(parent)
self.label_icon = QLabel("", parent)
self.status_label = QLabel("", parent) self.status_label = QLabel("", parent)
self.status_label.setTextFormat(Qt.RichText) self.status_label.setTextFormat(Qt.RichText)
...@@ -18,8 +18,20 @@ class StatusBarView(QStatusBar): ...@@ -18,8 +18,20 @@ class StatusBarView(QStatusBar):
self.label_time = QLabel("", parent) self.label_time = QLabel("", parent)
self.combo_referential = QComboBox(parent) self.combo_referential = QComboBox(parent)
self.movie_loader = QMovie(":/icons/loader")
self.addPermanentWidget(self.label_icon, 1) self.label_loading = QLabel(parent)
self.label_loading.setMovie(self.movie_loader)
self.label_loading.setMaximumHeight(self.height())
self.movie_loader.setScaledSize(QSize(16, 16))
self.movie_loader.start()
self.movie_loader.setPaused(True)
self.addPermanentWidget(self.label_loading)
self.addPermanentWidget(self.status_label, 2) self.addPermanentWidget(self.status_label, 2)
self.addPermanentWidget(self.label_time) self.addPermanentWidget(self.label_time)
self.addPermanentWidget(self.combo_referential) self.addPermanentWidget(self.combo_referential)
def start_loading(self):
self.movie_loader.setPaused(False)
def stop_loading(self):
self.movie_loader.setPaused(True)
...@@ -60,6 +60,7 @@ class BlockchainService(QObject): ...@@ -60,6 +60,7 @@ class BlockchainService(QObject):
if self._blockchain_processor.initialized(self.currency) and not self._update_lock: if self._blockchain_processor.initialized(self.currency) and not self._update_lock:
try: try:
self._update_lock = True self._update_lock = True
self.app.refresh_started.emit()
block_numbers = await self.new_blocks(network_blockstamp) block_numbers = await self.new_blocks(network_blockstamp)
while block_numbers: while block_numbers:
start = self.current_buid().number start = self.current_buid().number
...@@ -92,6 +93,7 @@ class BlockchainService(QObject): ...@@ -92,6 +93,7 @@ class BlockchainService(QObject):
except (NoPeerAvailable, DuniterError) as e: except (NoPeerAvailable, DuniterError) as e:
self._logger.debug(str(e)) self._logger.debug(str(e))
finally: finally:
self.app.refresh_finished.emit()
self._update_lock = False self._update_lock = False
def current_buid(self): def current_buid(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment