diff --git a/res/icons/icons.qrc b/res/icons/icons.qrc index d7193f256f84c7c5be21a3d9fd88e479e19e94f3..c8a8a8e959a10a3ef5326d9a07404aa8795fa7a7 100644 --- a/res/icons/icons.qrc +++ b/res/icons/icons.qrc @@ -1,5 +1,6 @@ <RCC> <qresource prefix="icons"> + <file alias="loader">loader.gif</file> <file alias="guest_icon">noun_178537_cc.svg</file> <file alias="menu_icon">noun_100552_cc.svg</file> <file alias="leave_icon">noun_155520_cc.svg</file> diff --git a/res/icons/loader.gif b/res/icons/loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..6a4c333d919c7aa2802f921cf9c95126743c3654 Binary files /dev/null and b/res/icons/loader.gif differ diff --git a/src/sakia/app.py b/src/sakia/app.py index 8636db9b5ea52c84ed17f06c2a0d49895f263268..d66c5424e4d9dcc287c45c40be3d80d2b83e50bd 100644 --- a/src/sakia/app.py +++ b/src/sakia/app.py @@ -52,6 +52,8 @@ class Application(QObject): sources_refreshed = pyqtSignal() new_blocks_handled = pyqtSignal() view_in_wot = pyqtSignal(Identity) + refresh_started = pyqtSignal() + refresh_finished = pyqtSignal() qapp = attr.ib() loop = attr.ib() diff --git a/src/sakia/gui/main_window/controller.py b/src/sakia/gui/main_window/controller.py index f74102c208cd286dad1a134fa4b880bb742ceaf6..b9848b110f6fbf6605eab03a54683196fef7f6c8 100644 --- a/src/sakia/gui/main_window/controller.py +++ b/src/sakia/gui/main_window/controller.py @@ -87,6 +87,8 @@ class MainWindowController(QObject): main_window.view.showMaximized() else: 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.refresh(app.currency) return main_window diff --git a/src/sakia/gui/main_window/status_bar/controller.py b/src/sakia/gui/main_window/status_bar/controller.py index 8500b1a88513358a8f68b5cebd3f434dc7e5104d..ffd20c19d3a867e0b16388d01d528eea539d9be0 100644 --- a/src/sakia/gui/main_window/status_bar/controller.py +++ b/src/sakia/gui/main_window/status_bar/controller.py @@ -14,8 +14,8 @@ class StatusBarController(QObject): """ Constructor of the navigation component - :param sakia.gui.status_bar.view.StatusBarView view: the presentation - :param sakia.core.status_bar.model.StatusBarModel model: the model + :param sakia.gui.main_window.status_bar.view.StatusBarView view: the presentation + :param sakia.gui.main_window.status_bar.model.StatusBarModel model: the model """ super().__init__() self.view = view @@ -53,6 +53,12 @@ class StatusBarController(QObject): timer.timeout.connect(self.update_time) timer.start(1000) + def start_loading(self): + self.view.start_loading() + + def stop_loading(self): + self.view.stop_loading() + def new_blocks_handled(self): current_block = self.model.current_block() current_time = self.model.current_time() diff --git a/src/sakia/gui/main_window/status_bar/view.py b/src/sakia/gui/main_window/status_bar/view.py index 14ade070b7cb5a7ecbf5bee5081d3235fe8d433f..ef8721b4fbf08fd1136409310ad02aa80333dd6d 100644 --- a/src/sakia/gui/main_window/status_bar/view.py +++ b/src/sakia/gui/main_window/status_bar/view.py @@ -1,6 +1,7 @@ from PyQt5.QtWidgets import QStatusBar -from PyQt5.QtWidgets import QLabel, QComboBox -from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QLabel, QComboBox, QSpacerItem, QSizePolicy +from PyQt5.QtGui import QMovie +from PyQt5.QtCore import Qt, QSize class StatusBarView(QStatusBar): @@ -10,7 +11,6 @@ class StatusBarView(QStatusBar): def __init__(self, parent): super().__init__(parent) - self.label_icon = QLabel("", parent) self.status_label = QLabel("", parent) self.status_label.setTextFormat(Qt.RichText) @@ -18,8 +18,20 @@ class StatusBarView(QStatusBar): self.label_time = QLabel("", parent) self.combo_referential = QComboBox(parent) - - self.addPermanentWidget(self.label_icon, 1) + self.movie_loader = QMovie(":/icons/loader") + 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.label_time) self.addPermanentWidget(self.combo_referential) + + def start_loading(self): + self.movie_loader.setPaused(False) + + def stop_loading(self): + self.movie_loader.setPaused(True) diff --git a/src/sakia/services/blockchain.py b/src/sakia/services/blockchain.py index a1659d3adaa3a40da804be0adc485872e4d2c4cc..ac4aab31d3e3996a9d04dcd76b5f6c9bf6561c4c 100644 --- a/src/sakia/services/blockchain.py +++ b/src/sakia/services/blockchain.py @@ -60,6 +60,7 @@ class BlockchainService(QObject): if self._blockchain_processor.initialized(self.currency) and not self._update_lock: try: self._update_lock = True + self.app.refresh_started.emit() block_numbers = await self.new_blocks(network_blockstamp) while block_numbers: start = self.current_buid().number @@ -92,6 +93,7 @@ class BlockchainService(QObject): except (NoPeerAvailable, DuniterError) as e: self._logger.debug(str(e)) finally: + self.app.refresh_finished.emit() self._update_lock = False def current_buid(self):