Skip to content

Commit

Permalink
Reset settings (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
infeeeee authored May 18, 2024
1 parent 80777d4 commit 77e10b4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions IoTuring/Configurator/Configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ def ManageSettings(self) -> None:

scm = ClassManager(KEY_SETTINGS)

choices = []
choices = [
CHOICE_GO_BACK,
{"name": "x Reset all settings to default", "value": "ResetSettings"},
Separator()
]

availableSettings = scm.ListAvailableClasses()
for sClass in availableSettings:
Expand All @@ -182,11 +186,24 @@ def ManageSettings(self) -> None:

choice = self.DisplayMenu(
choices=choices,
message=f"Select settings to edit"
message=f"Select settings to edit",
add_back_choice=False
)

if choice == CHOICE_GO_BACK:
self.Menu()
elif choice == "ResetSettings":

confirm = inquirer.confirm(message="Are you sure?").execute()
if confirm:
settings_configs = self.config.GetConfigsOfClass(KEY_SETTINGS)
if settings_configs:
for s in settings_configs:
self.config.RemoveActiveConfiguration(s)

self.DisplayMessage("All settings were reset to default")

self.ManageSettings()

else:
if not self.IsClassActive(choice):
Expand Down

0 comments on commit 77e10b4

Please sign in to comment.