mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 04:04:15 +02:00
manual progress status
This commit is contained in:
@@ -24,6 +24,7 @@ class AsyncAction(QThread, ProcessWatcher):
|
|||||||
signal_message = pyqtSignal(dict) # asks the GUI to show an error popup
|
signal_message = pyqtSignal(dict) # asks the GUI to show an error popup
|
||||||
signal_status = pyqtSignal(str) # changes the GUI status message
|
signal_status = pyqtSignal(str) # changes the GUI status message
|
||||||
signal_substatus = pyqtSignal(str) # changes the GUI substatus message
|
signal_substatus = pyqtSignal(str) # changes the GUI substatus message
|
||||||
|
signal_progress = pyqtSignal(int)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AsyncAction, self).__init__()
|
super(AsyncAction, self).__init__()
|
||||||
@@ -60,6 +61,9 @@ class AsyncAction(QThread, ProcessWatcher):
|
|||||||
def change_substatus(self, substatus: str):
|
def change_substatus(self, substatus: str):
|
||||||
self.signal_substatus.emit(substatus)
|
self.signal_substatus.emit(substatus)
|
||||||
|
|
||||||
|
def change_progress(self, val: int):
|
||||||
|
self.signal_progress.emit(val)
|
||||||
|
|
||||||
|
|
||||||
class UpdateSelectedApps(AsyncAction):
|
class UpdateSelectedApps(AsyncAction):
|
||||||
|
|
||||||
@@ -266,24 +270,51 @@ class AnimateProgress(QThread):
|
|||||||
self.progress_value = 0
|
self.progress_value = 0
|
||||||
self.increment = 5
|
self.increment = 5
|
||||||
self.stop = False
|
self.stop = False
|
||||||
|
self.limit = 100
|
||||||
|
self.sleep = 0.05
|
||||||
|
self.last_progress = 0
|
||||||
|
self.manual = False
|
||||||
|
|
||||||
|
def _reset(self):
|
||||||
|
self.progress_value = 0
|
||||||
|
self.increment = 5
|
||||||
|
self.stop = False
|
||||||
|
self.limit = 100
|
||||||
|
self.sleep = 0.05
|
||||||
|
self.last_progress = 0
|
||||||
|
self.manual = False
|
||||||
|
|
||||||
|
def set_progress(self, val: int):
|
||||||
|
if 0 <= val <= 100:
|
||||||
|
self.limit = val
|
||||||
|
self.manual = True
|
||||||
|
self.increment = 0.5
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
||||||
current_increment = self.increment
|
current_increment = self.increment
|
||||||
|
|
||||||
while not self.stop:
|
while not self.stop:
|
||||||
self.signal_change.emit(self.progress_value)
|
if self.progress_value != self.last_progress:
|
||||||
|
self.signal_change.emit(self.progress_value)
|
||||||
|
self.last_progress = self.progress_value
|
||||||
|
|
||||||
if self.progress_value == 100:
|
if not self.manual:
|
||||||
current_increment = -current_increment
|
if self.progress_value >= self.limit:
|
||||||
if self.progress_value == 0:
|
current_increment = -self.increment
|
||||||
current_increment = self.increment
|
elif self.progress_value <= 0:
|
||||||
|
current_increment = self.increment
|
||||||
|
else:
|
||||||
|
if self.progress_value >= self.limit:
|
||||||
|
current_increment = 0
|
||||||
|
else:
|
||||||
|
current_increment = self.increment
|
||||||
|
|
||||||
self.progress_value += current_increment
|
self.progress_value += current_increment
|
||||||
|
time.sleep(self.sleep)
|
||||||
|
|
||||||
time.sleep(0.05)
|
self.signal_change.emit(100)
|
||||||
|
self._reset()
|
||||||
self.progress_value = 0
|
|
||||||
|
|
||||||
|
|
||||||
class VerifyModels(QThread):
|
class VerifyModels(QThread):
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import operator
|
import operator
|
||||||
|
import time
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from typing import List, Type, Set
|
from typing import List, Type, Set
|
||||||
|
|
||||||
@@ -252,6 +253,10 @@ class ManageWindow(QWidget):
|
|||||||
self.thread_warnings = ListWarnings(man=manager, locale_keys=i18n)
|
self.thread_warnings = ListWarnings(man=manager, locale_keys=i18n)
|
||||||
self.thread_warnings.signal_warnings.connect(self._show_warnings)
|
self.thread_warnings.signal_warnings.connect(self._show_warnings)
|
||||||
|
|
||||||
|
def _update_process_progress(self, val: int):
|
||||||
|
self.progress_bar.setTextVisible(True)
|
||||||
|
self.thread_animate_progress.set_progress(val)
|
||||||
|
|
||||||
def apply_filters_async(self):
|
def apply_filters_async(self):
|
||||||
self.label_status.setText(self.i18n['manage_window.status.filtering'])
|
self.label_status.setText(self.i18n['manage_window.status.filtering'])
|
||||||
|
|
||||||
@@ -284,6 +289,8 @@ class ManageWindow(QWidget):
|
|||||||
action.signal_message.connect(self._show_message)
|
action.signal_message.connect(self._show_message)
|
||||||
action.signal_status.connect(self._change_label_status)
|
action.signal_status.connect(self._change_label_status)
|
||||||
action.signal_substatus.connect(self._change_label_substatus)
|
action.signal_substatus.connect(self._change_label_substatus)
|
||||||
|
action.signal_progress.connect(self._update_process_progress)
|
||||||
|
|
||||||
self.signal_user_res.connect(action.confirm)
|
self.signal_user_res.connect(action.confirm)
|
||||||
|
|
||||||
return action
|
return action
|
||||||
@@ -765,12 +772,16 @@ class ManageWindow(QWidget):
|
|||||||
self.combo_filter_type.setEnabled(False)
|
self.combo_filter_type.setEnabled(False)
|
||||||
|
|
||||||
def finish_action(self):
|
def finish_action(self):
|
||||||
|
self.thread_animate_progress.stop = True
|
||||||
|
self.thread_animate_progress.wait()
|
||||||
|
self.ref_progress_bar.setVisible(False)
|
||||||
|
self.progress_bar.setValue(0)
|
||||||
|
self.progress_bar.setTextVisible(False)
|
||||||
|
|
||||||
self._change_label_substatus('')
|
self._change_label_substatus('')
|
||||||
self.ref_bt_about.setVisible(True)
|
self.ref_bt_about.setVisible(True)
|
||||||
self.ref_progress_bar.setVisible(False)
|
|
||||||
self.ref_label_updates.setVisible(True)
|
self.ref_label_updates.setVisible(True)
|
||||||
self.thread_animate_progress.stop = True
|
|
||||||
self.progress_bar.setValue(0)
|
|
||||||
self.ref_bt_refresh.setVisible(True)
|
self.ref_bt_refresh.setVisible(True)
|
||||||
self.checkbox_only_apps.setEnabled(True)
|
self.checkbox_only_apps.setEnabled(True)
|
||||||
self.table_apps.setEnabled(True)
|
self.table_apps.setEnabled(True)
|
||||||
|
|||||||
Reference in New Issue
Block a user