Refactor: Move theme and display settings to a dedicated Settings menu
This commit is contained in:
32
tamigo.py
32
tamigo.py
@@ -315,14 +315,10 @@ def main():
|
|||||||
|
|
||||||
def menu(client):
|
def menu(client):
|
||||||
while True:
|
while True:
|
||||||
show_zero = current_config.get("show_zero_hours", False)
|
settings_text = "SETTINGS" if current_theme_name == "fallout" else "Settings"
|
||||||
toggle_text = "HIDE ZERO-HOUR DAYS" if show_zero else "SHOW ZERO-HOUR DAYS"
|
|
||||||
if current_theme_name != "fallout":
|
|
||||||
toggle_text = "Hide zero-hour days" if show_zero else "Show zero-hour days"
|
|
||||||
|
|
||||||
choice = questionary.select(
|
choice = questionary.select(
|
||||||
"SELECT ACTION:" if current_theme_name == "fallout" else "What would you like to do?",
|
"SELECT ACTION:" if current_theme_name == "fallout" else "What would you like to do?",
|
||||||
choices=["Calculate actual work days", "Export hours worked", "Show profile info", "Switch UI Theme", toggle_text, "Logout and Exit"],
|
choices=["Calculate actual work days", "Export hours worked", "Show profile info", settings_text, "Logout and Exit"],
|
||||||
style=theme_data["questionary"]
|
style=theme_data["questionary"]
|
||||||
).ask()
|
).ask()
|
||||||
|
|
||||||
@@ -331,7 +327,28 @@ def menu(client):
|
|||||||
elif choice == "Show profile info":
|
elif choice == "Show profile info":
|
||||||
if client.user_info: console.print_json(data=client.user_info)
|
if client.user_info: console.print_json(data=client.user_info)
|
||||||
else: console.print("[error]ERROR: NO PROFILE INFO.[/error]")
|
else: console.print("[error]ERROR: NO PROFILE INFO.[/error]")
|
||||||
elif choice == "Switch UI Theme":
|
elif choice == settings_text:
|
||||||
|
settings_menu()
|
||||||
|
else:
|
||||||
|
console.print("[highlight]SYSTEM SHUTDOWN...[/highlight]" if current_theme_name == "fallout" else "Exiting...")
|
||||||
|
break
|
||||||
|
|
||||||
|
def settings_menu():
|
||||||
|
while True:
|
||||||
|
show_zero = current_config.get("show_zero_hours", False)
|
||||||
|
toggle_text = "HIDE ZERO-HOUR DAYS" if current_theme_name == "fallout" else "Hide zero-hour days"
|
||||||
|
if not show_zero:
|
||||||
|
toggle_text = "SHOW ZERO-HOUR DAYS" if current_theme_name == "fallout" else "Show zero-hour days"
|
||||||
|
|
||||||
|
back_text = "BACK" if current_theme_name == "fallout" else "Back"
|
||||||
|
|
||||||
|
choice = questionary.select(
|
||||||
|
"SELECT SETTING:" if current_theme_name == "fallout" else "Settings:",
|
||||||
|
choices=["Switch UI Theme", toggle_text, back_text],
|
||||||
|
style=theme_data["questionary"]
|
||||||
|
).ask()
|
||||||
|
|
||||||
|
if choice == "Switch UI Theme":
|
||||||
new_theme = "normal" if current_theme_name == "fallout" else "fallout"
|
new_theme = "normal" if current_theme_name == "fallout" else "fallout"
|
||||||
apply_theme(new_theme)
|
apply_theme(new_theme)
|
||||||
console.print(f"[success]UI THEME SET TO: {new_theme.upper()}[/success]")
|
console.print(f"[success]UI THEME SET TO: {new_theme.upper()}[/success]")
|
||||||
@@ -341,7 +358,6 @@ def menu(client):
|
|||||||
state = "VISIBLE" if not show_zero else "HIDDEN"
|
state = "VISIBLE" if not show_zero else "HIDDEN"
|
||||||
console.print(f"[success]ZERO-HOUR DAYS ARE NOW {state}.[/success]" if current_theme_name == "fallout" else f"[success]Zero-hour days are now {state.lower()}.[/success]")
|
console.print(f"[success]ZERO-HOUR DAYS ARE NOW {state}.[/success]" if current_theme_name == "fallout" else f"[success]Zero-hour days are now {state.lower()}.[/success]")
|
||||||
else:
|
else:
|
||||||
console.print("[highlight]SYSTEM SHUTDOWN...[/highlight]" if current_theme_name == "fallout" else "Exiting...")
|
|
||||||
break
|
break
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user