1
0
Fork 0
forked from Fuji/Fuji

Add restart button to snackbar on Settings page

This commit is contained in:
mily 2025-03-07 21:35:57 +01:00
parent ed6d3f1df4
commit 50a52ce311
2 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,6 @@
import flet as ft import flet as ft
from constants import * from constants import *
from utils import setthemecolor, setlanguage from utils import setthemecolor, setlanguage, restart
from i18n import _ from i18n import _
def SettingsPage(): def SettingsPage():
@ -18,6 +18,11 @@ def SettingsPage():
ft.Icon(ft.icons.INFO_OUTLINED, color=ft.colors.AMBER), ft.Icon(ft.icons.INFO_OUTLINED, color=ft.colors.AMBER),
ft.Text(_("Settings changed. Restart required for changes to take effect."), ft.Text(_("Settings changed. Restart required for changes to take effect."),
color=ft.colors.BLACK, expand=True), color=ft.colors.BLACK, expand=True),
ft.TextButton(
text=_("Restart"),
on_click=lambda e: restart(e.page),
style=ft.ButtonStyle(color=ft.colors.BLUE),
),
ft.IconButton( ft.IconButton(
icon=ft.icons.CLOSE, icon=ft.icons.CLOSE,
icon_color=ft.colors.GREY_800, icon_color=ft.colors.GREY_800,
@ -26,6 +31,7 @@ def SettingsPage():
) )
]) ])
) )
def hide_notification(): def hide_notification():
notification.visible = False notification.visible = False
@ -98,4 +104,4 @@ def SettingsPage():
main_container.content = main_content main_container.content = main_content
main_container.expand = True # Make the main container expand main_container.expand = True # Make the main container expand
return main_container return main_container

View file

@ -2,6 +2,9 @@ import keyring
import os import os
from pathlib import Path from pathlib import Path
import configparser import configparser
import subprocess
import sys
import flet as ft
def saveauth(service, username, data, chunk_size=1000): def saveauth(service, username, data, chunk_size=1000):
chunks = [data[i:i+chunk_size] for i in range(0, len(data), chunk_size)] chunks = [data[i:i+chunk_size] for i in range(0, len(data), chunk_size)]
@ -55,4 +58,9 @@ def setlanguage(lang):
config["Settings"]["language"] = "en" config["Settings"]["language"] = "en"
with open(f"{getconfigpath()}/config.ini", "w") as file: with open(f"{getconfigpath()}/config.ini", "w") as file:
config.write(file) config.write(file)
def restart(page: ft.Page):
python = sys.executable
subprocess.Popen([python] + sys.argv)
page.window.destroy()