diff --git a/nitrokeyapp/gui.py b/nitrokeyapp/gui.py index 3077a771..230767d8 100644 --- a/nitrokeyapp/gui.py +++ b/nitrokeyapp/gui.py @@ -239,9 +239,12 @@ def remove_device(self, data: DeviceData) -> None: self.widget_show() def refresh(self) -> None: + self.overview_tab.busy_state_changed.connect(self.set_busy) """ Should be called if the selected device or the selected tab is changed """ + self.overview_tab.busy_state_changed.connect(self.set_busy) + if self.selected_device: self.widgetTab.hide() self.views[self.tabs.currentIndex()].refresh(self.selected_device) @@ -292,8 +295,13 @@ def slot_lock_button_pressed(self) -> None: def set_busy(self, busy: bool) -> None: if busy: self.setCursor(QCursor(Qt.WaitCursor)) + self.home_button.setEnabled(False) + self.tabs.setEnabled(False) else: self.unsetCursor() + self.home_button.setEnabled(True) + self.tabs.setEnabled(True) + # TODO: setEnabled? # self.setEnabled(not busy) diff --git a/nitrokeyapp/overview_tab.py b/nitrokeyapp/overview_tab.py index aa853a71..f60c9a0d 100644 --- a/nitrokeyapp/overview_tab.py +++ b/nitrokeyapp/overview_tab.py @@ -1,7 +1,7 @@ from typing import Optional from pynitrokey.nk3.admin_app import InitStatus -from PyQt5.QtCore import pyqtSlot +from PyQt5.QtCore import pyqtSignal, pyqtSlot from PyQt5.QtWidgets import QFileDialog, QWidget from nitrokeyapp.device_data import DeviceData @@ -12,6 +12,8 @@ class OverviewTab(QtUtilsMixIn, QWidget): + busy_state_changed = pyqtSignal(bool) + def __init__(self, info_box: InfoBox, parent: Optional[QWidget] = None) -> None: QWidget.__init__(self, parent) QtUtilsMixIn.__init__(self) @@ -98,18 +100,26 @@ def set_update_enabled(self, enabled: bool) -> None: self.ui.pushButtonUpdate.setEnabled(enabled) self.ui.pushButtonUpdate.setToolTip(tooltip) + self.ui.more_options_btn.setEnabled(enabled) + self.ui.more_options_btn.setToolTip(tooltip) def update_btns_during_update(self, enabled: bool) -> None: tooltip = "" if enabled: + self.busy_state_changed.emit(False) self.ui.pushButtonUpdate.setEnabled(enabled) self.ui.pushButtonUpdate.setToolTip(tooltip) + self.ui.more_options_btn.setEnabled(enabled) + self.ui.more_options_btn.setToolTip(tooltip) self.ui.update_with_file_btn.setEnabled(enabled) self.ui.update_with_file_btn.setToolTip(tooltip) else: tooltip = "Update is already running. Please wait." + self.busy_state_changed.emit(True) self.ui.pushButtonUpdate.setEnabled(enabled) self.ui.pushButtonUpdate.setToolTip(tooltip) + self.ui.more_options_btn.setEnabled(enabled) + self.ui.more_options_btn.setToolTip(tooltip) self.ui.update_with_file_btn.setEnabled(enabled) self.ui.update_with_file_btn.setToolTip(tooltip)