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

add Init Status and Variant #158

Merged
merged 1 commit into from
Oct 30, 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
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
33 changes: 30 additions & 3 deletions nitrokeyapp/overview_tab.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional

from pynitrokey.nk3.admin_app import InitStatus
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QFileDialog, QWidget

Expand Down Expand Up @@ -41,7 +42,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 @@ -51,13 +52,39 @@ def refresh(self, data: DeviceData) -> None:
return
self.reset()
self.data = data
if data.status.variant is None:
return

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.name),
str(data.status.init_status),
)

if data.status.init_status is None:
self.ui.label_init_status.hide()
self.ui.nk3_lineedit_init_status.hide()
else:
self.status_error(InitStatus(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)
self.ui.nk3_lineedit_init_status.setText(init_status)

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

def set_update_enabled(self, enabled: bool) -> None:
tooltip = ""
Expand Down
151 changes: 142 additions & 9 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">
<item row="0" column="0">
<widget class="QFrame" name="Nitrokey3">
<property name="enabled">
<bool>true</bool>
Expand Down Expand Up @@ -97,7 +97,7 @@
<property name="midLineWidth">
<number>5</number>
</property>
<layout class="QFormLayout" name="formLayout">
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_nk3">
<property name="sizePolicy">
Expand Down Expand Up @@ -223,6 +223,137 @@
</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">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<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>
<widget class="QLabel" name="warnNoticeIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;An error occurred during device initialization. &lt;br/&gt;Click &lt;span style=&quot; font-weight:600; text-decoration: underline; color:#c81435;&quot;&gt;More Info&lt;/span&gt; for more information and contact support if the error persists.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="pixmap">
<pixmap resource="resources.qrc">:/icons/icon_warning.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="moreInfo">
<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>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand All @@ -238,7 +369,7 @@
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="buttonLayout_nk3">
<item>
<widget class="QPushButton" name="pushButtonUpdate">
Expand All @@ -252,7 +383,7 @@
</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 +399,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 +475,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>