Skip to content

Commit

Permalink
renaming objects in Overview
Browse files Browse the repository at this point in the history
  • Loading branch information
jj-so committed Jan 29, 2024
1 parent e44ec97 commit 8bd66d7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 63 deletions.
70 changes: 35 additions & 35 deletions nitrokeyapp/overview_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def __init__(self, info_box: InfoBox, parent: Optional[QWidget] = None) -> None:
# self.ui === self -> this tricks mypy due to monkey-patching self
self.ui = self.load_ui("overview_tab.ui", self)

self.collapse(self.ui.more_options_frame, self.ui.more_options_btn)
self.ui.update_with_file_btn.clicked.connect(self.update_with_file)
self.ui.more_options_btn.clicked.connect(self.show_more_options)
self.ui.pushButtonUpdate.clicked.connect(self.run_update)
self.collapse(self.ui.more_options, self.ui.btn_more_options)
self.ui.btn_update_with_file.clicked.connect(self.update_with_file)
self.ui.btn_more_options.clicked.connect(self.show_more_options)
self.ui.btn_update.clicked.connect(self.run_update)

self.reset()

Expand All @@ -45,9 +45,9 @@ def worker(self) -> Optional[Worker]:
def reset(self) -> None:
self.data = None
self.set_device_data("?", "?", "?", "?", "?")
self.ui.progressBar_Update.hide()
self.ui.progressBar_Download.hide()
self.ui.progressBar_Finalization.hide()
self.ui.update_progress.hide()
self.ui.download_progress.hide()
self.ui.finalization_progress.hide()

def refresh(self, data: DeviceData) -> None:
if data == self.data:
Expand All @@ -66,27 +66,27 @@ def refresh(self, data: DeviceData) -> None:
)

if data.status.init_status is None:
self.ui.label_init_status.hide()
self.ui.nk3_lineedit_init_status.hide()
self.ui.status_label.hide()
self.ui.nk3_status.hide()
else:
self.status_error(InitStatus(data.status.init_status))

def set_device_data(
self, path: str, uuid: str, version: str, variant: str, init_status: str
) -> None:
self.ui.nk3_lineedit_path.setText(path)
self.ui.nk3_lineedit_uuid.setText(uuid)
self.ui.nk3_lineedit_version.setText(version)
self.ui.nk3_lineedit_variant.setText(variant)
self.ui.nk3_lineedit_init_status.setText(init_status)
self.ui.nk3_path.setText(path)
self.ui.nk3_uuid.setText(uuid)
self.ui.nk3_version.setText(version)
self.ui.nk3_variant.setText(variant)
self.ui.nk3_status.setText(init_status)

def status_error(self, init: InitStatus) -> None:
if init.is_error():
self.ui.warnNoticeIcon.show()
self.ui.moreInfo.show()
self.ui.icon_warn_notice.show()
self.ui.more_info.show()
else:
self.ui.warnNoticeIcon.hide()
self.ui.moreInfo.hide()
self.ui.icon_warn_notice.hide()
self.ui.more_info.hide()

def set_update_enabled(self, enabled: bool) -> None:
tooltip = ""
Expand All @@ -98,33 +98,33 @@ def set_update_enabled(self, enabled: bool) -> None:
)
tooltip = "Please remove all Nitrokey 3 devices except the one you want to update."

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.btn_update.setEnabled(enabled)
self.ui.btn_update.setToolTip(tooltip)
self.ui.btn_more_options.setEnabled(enabled)
self.ui.btn_more_options.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)
self.ui.btn_update.setEnabled(enabled)
self.ui.btn_update.setToolTip(tooltip)
self.ui.btn_more_options.setEnabled(enabled)
self.ui.btn_more_options.setToolTip(tooltip)
self.ui.btn_update_with_file.setEnabled(enabled)
self.ui.btn_update_with_file.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)
self.ui.btn_update.setEnabled(enabled)
self.ui.btn_update.setToolTip(tooltip)
self.ui.btn_more_options.setEnabled(enabled)
self.ui.btn_more_options.setToolTip(tooltip)
self.ui.btn_update_with_file.setEnabled(enabled)
self.ui.btn_update_with_file.setToolTip(tooltip)

def show_more_options(self) -> None:
self.collapse(self.ui.more_options_frame, self.ui.more_options_btn)
self.collapse(self.ui.more_options, self.ui.btn_more_options)

@Slot()
def run_update(self) -> None:
Expand Down
50 changes: 25 additions & 25 deletions nitrokeyapp/ui/overview_tab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea_2">
<widget class="QScrollArea" name="___overview_space">
<property name="autoFillBackground">
<bool>false</bool>
</property>
Expand All @@ -46,7 +46,7 @@
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<widget class="QWidget" name="___overview">
<property name="geometry">
<rect>
<x>0</x>
Expand All @@ -66,7 +66,7 @@
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QFrame" name="Nitrokey3">
<widget class="QFrame" name="___nk3_info_space">
<property name="enabled">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -99,7 +99,7 @@
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_nk3">
<widget class="QLabel" name="___nk3_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -126,7 +126,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_uuid">
<widget class="QLabel" name="___uuid_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -148,7 +148,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="nk3_lineedit_uuid">
<widget class="QLabel" name="nk3_uuid">
<property name="text">
<string>TextLabel</string>
</property>
Expand All @@ -158,7 +158,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_path">
<widget class="QLabel" name="___path_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -180,7 +180,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="nk3_lineedit_path">
<widget class="QLabel" name="nk3_path">
<property name="text">
<string>TextLabel</string>
</property>
Expand All @@ -190,7 +190,7 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_version">
<widget class="QLabel" name="___version_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -212,7 +212,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="nk3_lineedit_version">
<widget class="QLabel" name="nk3_version">
<property name="text">
<string>TextLabel</string>
</property>
Expand All @@ -222,7 +222,7 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_variant">
<widget class="QLabel" name="___variant_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -244,7 +244,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="nk3_lineedit_variant">
<widget class="QLabel" name="nk3_variant">
<property name="text">
<string>TextLabel</string>
</property>
Expand All @@ -254,7 +254,7 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_init_status">
<widget class="QLabel" name="status_label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -276,9 +276,9 @@
</widget>
</item>
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="status_space">
<item>
<widget class="QLabel" name="nk3_lineedit_init_status">
<widget class="QLabel" name="nk3_status">
<property name="text">
<string>TextLabel</string>
</property>
Expand All @@ -288,7 +288,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="warnNoticeIcon">
<widget class="QLabel" name="icon_warn_notice">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -328,7 +328,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="moreInfo">
<widget class="QLabel" name="more_info">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://docs.nitrokey.com/nitrokey3/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#c80636;&quot;&gt;More Info&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
Expand Down Expand Up @@ -369,9 +369,9 @@
</spacer>
</item>
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="buttonLayout_nk3">
<layout class="QHBoxLayout" name="___button_layout">
<item>
<widget class="QPushButton" name="pushButtonUpdate">
<widget class="QPushButton" name="btn_update">
<property name="text">
<string>Check for Update</string>
</property>
Expand All @@ -383,7 +383,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="more_options_btn">
<widget class="QPushButton" name="btn_more_options">
<property name="text">
<string>More Options</string>
</property>
Expand All @@ -403,7 +403,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="more_options_frame">
<widget class="QFrame" name="more_options">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand All @@ -430,7 +430,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="update_with_file_btn">
<widget class="QPushButton" name="btn_update_with_file">
<property name="text">
<string>Update with local Firmware</string>
</property>
Expand All @@ -444,7 +444,7 @@
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar_Download">
<widget class="QProgressBar" name="download_progress">
<property name="value">
<number>0</number>
</property>
Expand All @@ -457,7 +457,7 @@
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar_Update">
<widget class="QProgressBar" name="update_progress">
<property name="value">
<number>0</number>
</property>
Expand All @@ -467,7 +467,7 @@
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar_Finalization">
<widget class="QProgressBar" name="finalization_progress">
<property name="value">
<number>0</number>
</property>
Expand Down
6 changes: 3 additions & 3 deletions nitrokeyapp/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def __init__(
) -> None:
self._version_printed = False
self.overview_tab = overview_tab
self.bar_update = overview_tab.ui.progressBar_Update
self.bar_download = overview_tab.ui.progressBar_Download
self.bar_finalization = overview_tab.ui.progressBar_Finalization
self.bar_update = overview_tab.ui.update_progress
self.bar_download = overview_tab.ui.download_progress
self.bar_finalization = overview_tab.ui.finalization_progress
self.info_frame = info_frame

def error(self, *msgs: Any) -> Exception:
Expand Down

0 comments on commit 8bd66d7

Please sign in to comment.