Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
maltfield committed Jun 11, 2023
1 parent 214a5cb commit 19aa292
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/buskill_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,11 @@ def __init__(self, *args, **kwargs):
self.interface_cls = kivy.uix.settings.ContentPanel
super(BusKillSettingsWithNoMenu,self).__init__( *args, **kwargs )

# The ComplexOptionsScreen
# The ComplexOptionsScreen is a sub-screen to the Settings Screen. Kivy doesn't
# have sub-screens for defining options, but that's what's expected in Material
# Design. We needed more space, so we created ComplexOption-type Settings. And
# this is the Screen where the user transitions-to to choose the options for a
# ComplexOption
class ComplexOptionsScreen(Screen):

actionview = ObjectProperty(None)
Expand Down Expand Up @@ -749,14 +753,10 @@ def show_help( self ):
self.dialog.b_cancel.text = "OK"
self.dialog.open()

# This is our main Screen when the user clicks "Settings" in the nav drawer
class BusKillSettingsScreen(Screen):

actionview = ObjectProperty(None)
settings_content = ObjectProperty(None)

def __init__(self, **kwargs):

super(BusKillSettingsScreen, self).__init__(**kwargs)

def on_pre_enter(self, *args):

Expand Down Expand Up @@ -803,6 +803,7 @@ def on_pre_enter(self, *args):
# a bunch of "ComplexOptions". Let's add those to the screen's contents
self.settings_content.add_widget( s )

# called when the user leaves the Settings screen
def on_pre_leave(self):
# update runtime 'bk' instance with any settings changes, as needed

Expand All @@ -813,6 +814,7 @@ def on_pre_leave(self):
# attempt to re-arm BusKill if the trigger changed
self.rearm_if_required()

# called when the user clicks the "reset" button in the actionbar
def reset_defaults(self):

msg = "Are you sure you want to reset all your settings back to defaults?"
Expand All @@ -824,9 +826,9 @@ def reset_defaults(self):
continue_function=self.reset_defaults2
)
self.dialog.b_cancel.text = "Cancel"
#self.dialog.l_body.bind( on_ref_press=self.ref_press )
self.dialog.open()

# called when the user confirms they want to reset their settings
def reset_defaults2(self):
msg = "DEBUG: User initiated settings reset"
print( msg ); logger.debug( msg )
Expand Down Expand Up @@ -914,6 +916,9 @@ def refresh_values(self):
# set the radio button icon to "unselected"
widget.radio_button_label.text = "[font=mdicons][size=18]\ue836[/size][/font]"

# determine if we need to re-arm BusKill (eg if they changed the trigger
# while BusKill is arm, we'd need to re-arm else it'll trigger not what the
# user expects it to trigger)
def rearm_if_required(self):

# this changes to true if we have to disarm & arm BusKill again i norder to
Expand Down Expand Up @@ -950,6 +955,7 @@ def rearm_if_required(self):
)
self.dialog.open()

# re-arms BusKill
def rearm(self):

# close the dialog if it's already opened
Expand All @@ -960,6 +966,10 @@ def rearm(self):
self.main_screen.toggle_buskill()
self.main_screen.toggle_buskill()

#############
# DEBUG LOG #
#############

class DebugLog(Screen):

debug_header = ObjectProperty(None)
Expand Down

0 comments on commit 19aa292

Please sign in to comment.