Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

During the update process, the gui is busy #170

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move behind comment

"""
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