1
0
Fork 0
forked from Fuji/Fuji

Merge pull request 'Add restart button to snackbar on Settings page' (#2) from mily/Fuji:main into main

Reviewed-on: https://git.wpkg.ovh/Fuji/Fuji/pulls/2
This commit is contained in:
Marceli 2025-03-07 20:41:24 +00:00
commit 858bef810a
2 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,6 @@
import flet as ft
from constants import *
from utils import setthemecolor, setlanguage
from utils import setthemecolor, setlanguage, restart
from i18n import _
def SettingsPage():
@ -18,6 +18,11 @@ def SettingsPage():
ft.Icon(ft.icons.INFO_OUTLINED, color=ft.colors.AMBER),
ft.Text(_("Settings changed. Restart required for changes to take effect."),
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(
icon=ft.icons.CLOSE,
icon_color=ft.colors.GREY_800,
@ -26,6 +31,7 @@ def SettingsPage():
)
])
)
def hide_notification():
notification.visible = False
@ -98,4 +104,4 @@ def SettingsPage():
main_container.content = main_content
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
from pathlib import Path
import configparser
import subprocess
import sys
import flet as ft
def saveauth(service, username, data, chunk_size=1000):
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"
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()