Skip to content

Commit

Permalink
add init_status and variant
Browse files Browse the repository at this point in the history
	modified:   nitrokeyapp/device_data.py
	modified:   nitrokeyapp/overview_tab.py
	modified:   nitrokeyapp/ui/overview_tab.ui
  • Loading branch information
jj-so committed Oct 20, 2023
1 parent 38d809e commit c1cde91
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 11 deletions.
1 change: 1 addition & 0 deletions nitrokeyapp/device_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, device: Nitrokey3Device) -> None:
self.uuid = device.uuid()
self.version = device.version()
self.updating = False
self.status = device.admin.status()

@property
def uuid_prefix(self) -> str:
Expand Down
17 changes: 14 additions & 3 deletions nitrokeyapp/overview_tab.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import webbrowser

from typing import Optional

from PyQt5.QtCore import pyqtSlot
Expand All @@ -24,6 +26,9 @@ def __init__(self, info_box: InfoBox, parent: Optional[QWidget] = None) -> None:
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.ui.pushButtonSupport.clicked.connect(
lambda: webbrowser.open("https://docs.nitrokey.com/nitrokey3")
)

self.reset()

Expand All @@ -41,7 +46,7 @@ def worker(self) -> Optional[Worker]:

def reset(self) -> None:
self.data = None
self.set_device_data("?", "?", "?")
self.set_device_data("?", "?", "?", "?", "?")
self.ui.progressBar_Update.hide()
self.ui.progressBar_Download.hide()
self.ui.progressBar_Finalization.hide()
Expand All @@ -52,12 +57,18 @@ def refresh(self, data: DeviceData) -> None:
self.reset()
self.data = data

self.set_device_data(str(data.path), str(data.uuid), str(data.version))
self.set_device_data(str(data.path), str(data.uuid), str(data.version), str(data.status.variant), str(data.status.init_status))

def set_device_data(self, path: str, uuid: str, version: str) -> None:
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[8:])
self.ui.nk3_lineedit_init_status.setText(init_status)
if init_status == "ok":
self.ui.pushButtonSupport.hide()
else:
self.ui.pushButtonSupport.show()

def set_update_enabled(self, enabled: bool) -> None:
tooltip = ""
Expand Down
93 changes: 85 additions & 8 deletions nitrokeyapp/ui/overview_tab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<height>366</height>
<width>488</width>
<height>369</height>
</rect>
</property>
<property name="sizePolicy">
Expand All @@ -64,8 +64,8 @@
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QFrame" name="Nitrokey3">
<property name="enabled">
<bool>true</bool>
Expand Down Expand Up @@ -223,6 +223,70 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_variant">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="text">
<string>Variant:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="nk3_lineedit_variant">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_init_status">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>10</height>
</size>
</property>
<property name="text">
<string>Init status:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="nk3_lineedit_init_status">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -238,7 +302,7 @@
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<layout class="QHBoxLayout" name="buttonLayout_nk3">
<item>
<widget class="QPushButton" name="pushButtonUpdate">
Expand All @@ -249,10 +313,21 @@
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QPushButton" name="pushButtonSupport">
<property name="text">
<string>Contact Support</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/icons/icon_warning.svg</normaloff>:/icons/icon_warning.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignLeft">
<item row="1" column="0">
<widget class="QPushButton" name="more_options_btn">
<property name="text">
<string>More Options</string>
Expand All @@ -268,7 +343,7 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<item row="2" column="0">
<widget class="QFrame" name="more_options_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
Expand Down Expand Up @@ -344,6 +419,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit c1cde91

Please sign in to comment.