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

Progress bar bug fixes

parent b1be4520
Branches
Tags
No related merge requests found
import asyncio
from PyQt5.QtWidgets import QDialog from PyQt5.QtWidgets import QDialog
from PyQt5.QtCore import pyqtSignal, Qt, QElapsedTimer, QDateTime, QCoreApplication from PyQt5.QtCore import pyqtSignal, Qt, QElapsedTimer, QDateTime, QCoreApplication
from .connection_cfg_uic import Ui_ConnectionConfigurationDialog from .connection_cfg_uic import Ui_ConnectionConfigurationDialog
...@@ -5,6 +6,7 @@ from .congratulation_uic import Ui_CongratulationPopup ...@@ -5,6 +6,7 @@ from .congratulation_uic import Ui_CongratulationPopup
from duniterpy.key import SigningKey, ScryptParams from duniterpy.key import SigningKey, ScryptParams
from math import ceil, log from math import ceil, log
from sakia.gui.widgets import toast from sakia.gui.widgets import toast
from sakia.decorators import asyncify
from sakia.helpers import timestamp_to_dhms from sakia.helpers import timestamp_to_dhms
from sakia.gui.widgets.dialogs import dialog_async_exec, QAsyncMessageBox from sakia.gui.widgets.dialogs import dialog_async_exec, QAsyncMessageBox
from sakia.constants import ROOT_SERVERS, G1_LICENCE from sakia.constants import ROOT_SERVERS, G1_LICENCE
...@@ -156,16 +158,16 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog): ...@@ -156,16 +158,16 @@ class ConnectionConfigView(QDialog, Ui_ConnectionConfigurationDialog):
:param float ratio: the ratio of progress of current step (between 0 and 1) :param float ratio: the ratio of progress of current step (between 0 and 1)
:return: :return:
""" """
QCoreApplication.processEvents() SMOOTHING_FACTOR = 0.005
if self.timer.elapsed() > 0:
value = self.progress_bar.value() value = self.progress_bar.value()
next_value = value + 1000000*step_ratio next_value = value + 1000000*step_ratio
SMOOTHING_FACTOR = 0.005
speed_percent_by_ms = (next_value - value) / self.timer.elapsed() speed_percent_by_ms = (next_value - value) / self.timer.elapsed()
self.average_speed = SMOOTHING_FACTOR * self.last_speed + (1 - SMOOTHING_FACTOR) * self.average_speed self.average_speed = SMOOTHING_FACTOR * self.last_speed + (1 - SMOOTHING_FACTOR) * self.average_speed
remaining = (self.progress_bar.maximum() - next_value) / self.average_speed remaining = (self.progress_bar.maximum() - next_value) / self.average_speed
self.last_speed = speed_percent_by_ms self.last_speed = speed_percent_by_ms
displayed_remaining_time = QDateTime.fromTime_t(remaining).toUTC().toString("hh:mm:ss") displayed_remaining_time = QDateTime.fromTime_t(remaining).toUTC().toString("hh:mm:ss")
self.progress_bar.setFormat(self.tr("{0} scs remaining...".format(displayed_remaining_time))) self.progress_bar.setFormat(self.tr("{0} remaining...".format(displayed_remaining_time)))
self.progress_bar.setValue(next_value) self.progress_bar.setValue(next_value)
self.timer.restart() self.timer.restart()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment