Skip to content

Commit

Permalink
Merge pull request #170 from Nitrokey/setGuiBusy
Browse files Browse the repository at this point in the history
During the update process, the gui is busy
  • Loading branch information
jj-so authored Nov 24, 2023
2 parents 23a173f + 0a50290 commit 54c1469
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions nitrokeyapp/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
12 changes: 11 additions & 1 deletion nitrokeyapp/overview_tab.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 54c1469

Please sign in to comment.