From 82a7e021ef07526e4ddb70dee9057df3f33fcac3 Mon Sep 17 00:00:00 2001 From: croneter Date: Sat, 15 Sep 2018 15:07:57 +0200 Subject: [PATCH] Make home button close user selection dialog --- resources/lib/userclient.py | 2 +- resources/lib/windows/userselect.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index bcce8137..9b6ca486 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -237,7 +237,7 @@ class UserClient(Thread): plextoken = utils.settings('plexToken') if plextoken: LOG.info("Trying to connect to plex.tv to get a user list") - user = userselect.start() + user, aborted = userselect.start() if not user: # FAILURE: Something went wrong, try again self.auth = True diff --git a/resources/lib/windows/userselect.py b/resources/lib/windows/userselect.py index 82fe4deb..4e34bfe6 100644 --- a/resources/lib/windows/userselect.py +++ b/resources/lib/windows/userselect.py @@ -40,11 +40,12 @@ class UserSelectWindow(kodigui.BaseWindow): USER_LIST_ID = 101 PIN_ENTRY_GROUP_ID = 400 - SHUTDOWN_BUTTON_ID = 500 # Todo: DELETE + HOME_BUTTON_ID = 500 def __init__(self, *args, **kwargs): self.task = None self.user = None + self.aborted = False kodigui.BaseWindow.__init__(self, *args, **kwargs) def onFirstInit(self): @@ -89,6 +90,8 @@ class UserSelectWindow(kodigui.BaseWindow): self.userSelected(item) elif 200 < controlID < 212: self.pinEntryClicked(controlID) + elif controlID == self.HOME_BUTTON_ID: + self.home_button_clicked() def onFocus(self, controlID): if controlID == self.USER_LIST_ID: @@ -126,6 +129,14 @@ class UserSelectWindow(kodigui.BaseWindow): finally: self.setProperty('busy', '') + def home_button_clicked(self): + """ + Action taken if user clicked the home button + """ + self.user = None + self.aborted = True + self.doClose() + def pinEntryClicked(self, controlID): item = self.userList.getSelectedItem() if item.getProperty('editing.pin'): @@ -182,10 +193,13 @@ def start(): Returns ======= + tuple (user, aborted) user : HomeUser Or None if user switch failed or aborted by the user) + aborted : bool + True if the user cancelled the dialog """ w = UserSelectWindow.open() - user = w.user + user, aborted = w.user, w.aborted del w - return user + return user, aborted