Skip to content

Commit

Permalink
apply make fix
Browse files Browse the repository at this point in the history
  • Loading branch information
daringer committed Dec 18, 2023
1 parent c64dd24 commit 3328053
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 22 deletions.
1 change: 0 additions & 1 deletion nitrokeyapp/about_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from nitrokeyapp.logger import save_log
from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn


## unused ?


Expand Down
2 changes: 1 addition & 1 deletion nitrokeyapp/error_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QDialog, QDialogButtonBox, QPushButton, QWidget

from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn
from nitrokeyapp.logger import save_log
from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn


class ErrorDialog(QtUtilsMixIn, QDialog):
Expand Down
13 changes: 7 additions & 6 deletions nitrokeyapp/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str):
self.monitor = pyudev.Monitor.from_netlink(self.context)
self.monitor.filter_by(subsystem="usb")
# pyudev.pyside6 integration doesn't work properly
self.observer = pyudev.MonitorObserver(self.monitor, lambda action, device: self.sig_device_change.emit(action))
self.observer = pyudev.MonitorObserver(
self.monitor, lambda action, device: self.sig_device_change.emit(action)
)
self.observer.start()

# windows
Expand All @@ -86,7 +88,7 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str):

# loads main ui
self.ui = self.load_ui("mainwindow.ui", self)
#self.setCentralWidget(self.ui)
# self.setCentralWidget(self.ui)

self.info_box = InfoBox(
self.ui.information_frame,
Expand Down Expand Up @@ -130,15 +132,14 @@ def __init__(self, qt_app: QtWidgets.QApplication, log_file: str):

self.sig_device_change.connect(self.device_connect)


self.init_gui()
self.show()

# nk3
self.help_btn.clicked.connect(
lambda: webbrowser.open("https://docs.nitrokey.com/nitrokey3")
)
#self.lock_btn.clicked.connect(self.slot_lock_button_pressed)
# self.lock_btn.clicked.connect(self.slot_lock_button_pressed)
self.home_button.clicked.connect(self.home_button_pressed)
# self.settings_btn.clicked.connect()
# connections for functional signals
Expand Down Expand Up @@ -259,8 +260,8 @@ def refresh(self) -> None:
def init_gui(self) -> None:
self.tabs.hide()
self.info_box.hide()
#self.lock_btn.setEnabled(False)
#self.settings_btn.setEnabled(False)
# self.lock_btn.setEnabled(False)
# self.settings_btn.setEnabled(False)
self.detect_added_devices()

def device_selected(self, data: DeviceData) -> None:
Expand Down
1 change: 1 addition & 0 deletions nitrokeyapp/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

log_to_console = "NKAPP_LOG" in os.environ


@contextmanager
def init_logging() -> Generator[str, None, None]:
log_file = NamedTemporaryFile(prefix="nitrokey-app2.", suffix=".log", delete=False)
Expand Down
4 changes: 2 additions & 2 deletions nitrokeyapp/qt_utils_mix_in.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Optional, Type, TypeVar
from pathlib import Path
from typing import Optional, Type, TypeVar

from PySide6 import QtGui, QtWidgets
from PySide6.QtCore import QObject, QSize, QDir, QMetaObject
from PySide6.QtCore import QDir, QMetaObject, QObject, QSize
from PySide6.QtWidgets import QWidget

from nitrokeyapp.ui_loader import UiLoader
Expand Down
9 changes: 5 additions & 4 deletions nitrokeyapp/secrets_tab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

from nitrokeyapp.add_secret_dialog import AddSecretDialog
from nitrokeyapp.device_data import DeviceData
#from nitrokeyapp.ui.secrets_tab import Ui_SecretsTab
from nitrokeyapp.worker import Worker
from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn

# from nitrokeyapp.ui.secrets_tab import Ui_SecretsTab
from nitrokeyapp.worker import Worker

from .data import Credential, OtpData
from .worker import SecretsWorker

Expand Down Expand Up @@ -72,8 +73,8 @@ def __init__(self, parent: Optional[QWidget] = None) -> None:
self.originalText = self.clipboard.text()

self.ui = self.load_ui("secrets_tab.ui", self)
#breakpoint()
#print(self.pageCompatible)
# breakpoint()
# print(self.pageCompatible)

labels = [
self.labelName,
Expand Down
11 changes: 8 additions & 3 deletions nitrokeyapp/ui_loader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from PySide6.QtUiTools import QUiLoader


# taken/inspired with many thanks from: https://gist.github.com/cpbotha/1b42a20c8f3eb9bb7cb8
class UiLoader(QUiLoader):
"""
Expand Down Expand Up @@ -27,7 +28,7 @@ def __init__(self, baseinstance, customWidgets=None):
self.baseinstance = baseinstance
self.customWidgets = customWidgets

def createWidget(self, class_name, parent=None, name=''):
def createWidget(self, class_name, parent=None, name=""):
"""
Function that is called for each widget defined in ui file,
overridden here to populate baseinstance instead.
Expand All @@ -46,7 +47,11 @@ def createWidget(self, class_name, parent=None, name=''):
widget = self.customWidgets[class_name](parent)

except (TypeError, KeyError) as e:
raise Exception("No custom widget " + class_name + " found in customWidgets param of UiLoader __init__.")
raise Exception(
"No custom widget "
+ class_name
+ " found in customWidgets param of UiLoader __init__."
)

if self.baseinstance:
# set an attribute for the new child widget on the base
Expand All @@ -56,6 +61,6 @@ def createWidget(self, class_name, parent=None, name=''):

# this outputs the various widget names, e.g.
# sampleGraphicsView, dockWidget, samplesTableView etc.
#print(name)
# print(name)

return widget
13 changes: 9 additions & 4 deletions nitrokeyapp/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ def confirm_download(self, current: Optional[Version], new: Version) -> None:
)
confirm_download_msgBox.setWindowTitle("Nitrokey 3 Firmware Update")
confirm_download_msgBox.setStandardButtons(
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel
QtWidgets.QMessageBox.StandardButton.Ok
| QtWidgets.QMessageBox.StandardButton.Cancel
)
returnValue = confirm_download_msgBox.exec()
if returnValue == QtWidgets.QMessageBox.StandardButton.Cancel:
Expand All @@ -122,7 +123,8 @@ def confirm_update(self, current: Optional[Version], new: Version) -> None:
)
confirm_update_msgBox.setWindowTitle("Nitrokey 3 Firmware Update")
confirm_update_msgBox.setStandardButtons(
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel
QtWidgets.QMessageBox.StandardButton.Ok
| QtWidgets.QMessageBox.StandardButton.Cancel
)
returnValue = confirm_update_msgBox.exec()
if returnValue == QtWidgets.QMessageBox.StandardButton.Cancel:
Expand All @@ -138,13 +140,16 @@ def confirm_update(self, current: Optional[Version], new: Version) -> None:

def confirm_update_same_version(self, version: Version) -> None:
confirm_update_same_version_msgBox = QtWidgets.QMessageBox(self.overview_tab)
confirm_update_same_version_msgBox.setIcon(QtWidgets.QMessageBox.Icon.Information)
confirm_update_same_version_msgBox.setIcon(
QtWidgets.QMessageBox.Icon.Information
)
confirm_update_same_version_msgBox.setText(
"The version of the firmware image is the same as on the device. Do you want to continue anyway?"
)
confirm_update_same_version_msgBox.setWindowTitle("Nitrokey 3 Firmware Update")
confirm_update_same_version_msgBox.setStandardButtons(
QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel
QtWidgets.QMessageBox.StandardButton.Ok
| QtWidgets.QMessageBox.StandardButton.Cancel
)
returnValue = confirm_update_same_version_msgBox.exec()
if returnValue == QtWidgets.QMessageBox.StandardButton.Cancel:
Expand Down
1 change: 0 additions & 1 deletion nitrokeyapp/welcome_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from nitrokeyapp.qt_utils_mix_in import QtUtilsMixIn



class WelcomeTab(QtUtilsMixIn, QWidget):
def __init__(self, parent: Optional[QWidget], log_file: str) -> None:
QWidget.__init__(self, parent)
Expand Down

0 comments on commit 3328053

Please sign in to comment.