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:
commit
858bef810a
2 changed files with 17 additions and 3 deletions
|
@ -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
|
||||||
|
|
10
src/utils.py
10
src/utils.py
|
@ -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()
|
||||||
|
|
Loading…
Add table
Reference in a new issue