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 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,
@ -27,6 +32,7 @@ def SettingsPage():
]) ])
) )
def hide_notification(): def hide_notification():
notification.visible = False notification.visible = False
main_container.update() main_container.update()

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)]
@ -56,3 +59,8 @@ def setlanguage(lang):
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()