Skip to content

Commit

Permalink
Implement user locking
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzz committed Mar 12, 2020
1 parent 538a753 commit a044243
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,19 @@ def __init__(self):
layout.addWidget(group_progress, stretch=0)
self.setLayout(layout)

self.lockable = [btn_flash_qmk, btn_reboot_bl, btn_flash_jumploader, btn_restore_stock,
self.combobox_devices, btn_refresh_devices]

self.on_click_refresh()

def lock_user(self):
pass
for obj in self.lockable:
obj.setEnabled(False)

def unlock_user(self):
self.close_dev()
for obj in self.lockable:
obj.setEnabled(True)

def close_dev(self):
if self.dev is not None:
Expand Down Expand Up @@ -282,13 +288,15 @@ def on_click_flash_qmk(self):
self.close_dev()
return

self.lock_user()
threading.Thread(target=lambda: cmd_flash(self.dev, QMK_OFFSET, firmware, self.on_progress, self.on_complete, self.on_error)).start()

def on_click_reboot(self):
self.dev = self.get_active_device()
if not self.dev:
return

self.lock_user()
threading.Thread(target=lambda: cmd_reboot(self.dev, self.on_progress, self.on_complete, self.on_error)).start()

def dangerous_flash(self, path):
Expand All @@ -304,6 +312,7 @@ def dangerous_flash(self, path):
with open(path, "rb") as inf:
firmware = inf.read()

self.lock_user()
threading.Thread(target=lambda: cmd_flash(self.dev, 0, firmware, self.on_progress, self.on_complete, self.on_error)).start()

def on_click_revert(self):
Expand Down

0 comments on commit a044243

Please sign in to comment.