Skip to content

Commit

Permalink
Functional update with settings update
Browse files Browse the repository at this point in the history
  • Loading branch information
WhatDamon committed Feb 22, 2024
1 parent d0c0f75 commit 0cc1bb3
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 29 deletions.
Empty file added i18n/__init__.py
Empty file.
33 changes: 29 additions & 4 deletions i18n/en_US.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
"orgiName": "",
"code": "en_US",
"font": "",
"machineTranslated": True
"machineTranslated": True,
"useKKGithub": False
}

infomation = {
"wslWarning": "We noticed that you are using WSL, in fact, we recommend you to use the Windows version directly to avoid potential bugs.",
"cygwinWarning": "We noticed that you are using Cygwin, in fact, we recommend you to use the Windows version directly to avoid potential bugs.",
"nonTestWarning": "The software has not been tested for stability except for Windows, and there may be bugs that need to be fixed that the developer is not aware of.",
"machineTranslate": "The language you are using is machine-translated and may have some language comprehension issues"
"machineTranslate": "The language you are using is machine-translated and may have some language comprehension issues",
"updateUseKKGithubMirror": "Note: Switching to KKGitHub mirrors when checking for updates while use this language"
}

menuBar = {
Expand Down Expand Up @@ -95,7 +97,8 @@
"findUpdate": "Discover Update",
"update": "Update",
"cancel": "Cancel",
"ok": "OK"
"ok": "OK",
"githubRepo": "GitHub Repo"
}

update = {
Expand All @@ -109,9 +112,31 @@

sets = {
"settings": "Settings",
"note": "The spacebar can also be used here to control the play and pause of the music.",
"pleaseSelect": "Please select...",
"construction": "Under Construction",
"language": "Languages",
"systemDefault": "System",
"langNameEng": "English Name: ",
"langNameOrigial": "Name: ",
"langCode": "Language Code: ",
"langFont": "Language Font: ",
"appearances": "Appearances",
"colorMode": "Color Mode: ",
"colorLight": "Light",
"colorDark": "Dark",
"colorSchemes": "Color Schemes: ",
"blue": "Blue",
"pink": "Pink",
"green": "Green",
"brown": "Brown",
"purple": "Purple",
"play": "Play",
"lyrics": "Lyrics"
"immediatelyPlay": "Play the song immediately after loading",
"lyrics": "Lyrics",
"lyricsDefaultVis": "Lyrics display by default",
"feedback": "Feedback",
"bugReport": "Report a BUG",
"shareIdeas": "Share new feature ideas",
"discussion": "Join discussions"
}
35 changes: 30 additions & 5 deletions i18n/zh_CN.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
"orgiName": "简体中文",
"code": "zh_CN",
"font": "Microsoft YaHei",
"machineTranslated": False
"machineTranslated": False,
"useKKGithub": True
}

infomation = {
"wslWarning": "发现您正在使用 WSL, 实际上, 我们更推荐您直接使用 Windows 版本以避免潜在的 BUG",
"cygwinWarning": "发现您正在使用 Cygwin, 实际上, 我们更推荐您直接使用 Windows 版本以避免潜在的 BUG",
"nonTestWarning": "除 Windows 外, 该软件没有做过稳定性测试, 可能会存在一些开发者也不清楚的 BUG 需要修复",
"machineTranslate": "您所使用的语言是机器翻译得到的,可能会存在一些语言理解性问题"
"machineTranslate": "您所使用的语言是机器翻译得到的,可能会存在一些语言理解性问题",
"updateUseKKGithubMirror": "注: 使用该语言时检查更新将切换为 KKGitHub 镜像站"
}

menuBar = {
Expand Down Expand Up @@ -89,13 +91,14 @@
"songIdInput": "输入歌曲 ID:",
"songIdHint": "(目前仅限网易云 + 非会员歌曲)",
"vipOrNoCopyrightAlert": "抱歉, 不支持获取会员或由于版权问题无法播放的歌曲",
"errorPrompt": "请输入正确的歌曲ID",
"errorPrompt": "请输入正确的歌曲 ID",
"updateTimeout": "检查更新超时, 请检查网络连接",
"youAreUsingLatest": "你正在使用最新版本",
"findUpdate": "发现更新",
"update": "更新",
"cancel": "取消",
"ok": "确定"
"ok": "确定",
"githubRepo": "GitHub 仓库"
}

update = {
Expand All @@ -109,9 +112,31 @@

sets = {
"settings": "设置",
"note": "这里也可以用空格键来控制音乐的播放与暂停哟~",
"pleaseSelect": "请选择...",
"construction": "正在施工",
"language": "语言",
"systemDefault": "系统默认",
"langNameEng": "英文名: ",
"langNameOrigial": "名称: ",
"langCode": "语言代码: ",
"langFont": "语言字体: ",
"appearances": "外观",
"colorMode": "亮暗模式: ",
"colorLight": "亮色",
"colorDark": "暗色",
"colorSchemes": "配色方案: ",
"blue": "蓝色",
"pink": "粉色",
"green": "绿色",
"brown": "棕色",
"purple": "紫色",
"play": "播放",
"lyrics": "歌词"
"immediatelyPlay": "加载歌曲后立即播放",
"lyrics": "歌词",
"lyricsDefaultVis": "歌词默认显示",
"feedback": "反馈",
"bugReport": "报告 BUG",
"shareIdeas": "分享新功能想法",
"discussion": "加入讨论"
}
2 changes: 0 additions & 2 deletions lib/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion lib/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def updateApi():
# API定义
global api
if lang.langInfo["code"] == "zh_CN":
if lang.langInfo["useKKGithub"] == True:
api = requests.get("https://api.kkgithub.com/repos/WhatDamon/Simplay-Player/releases", timeout = 10, verify = False) # SSL禁用
log_init.logging.info("Using KKGitHub mirror")
else:
Expand Down
4 changes: 2 additions & 2 deletions lib/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,5 @@ def balanceMiddle(e):
balance = 0,
on_duration_changed = lambda e: log_init.logging.info("Duration changed:" + e.data),
on_state_changed = lambda e: log_init.logging.info("State changed:" + e.data),
on_seek_complete = lambda _: log_init.logging.info("Seek complete"),
)
on_seek_complete = lambda _: log_init.logging.info("Seek complete")
)
106 changes: 96 additions & 10 deletions pages/settingsPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,64 @@

log_init.logging.info("Basic libs imported at settingsPage.py")

from i18n import lang
import i18n

log_init.logging.info("Languages imported at settingsPage.py")

appBar = ft.AppBar(title = ft.Row(controls = [ft.Icon(ft.icons.SETTINGS_OUTLINED), ft.Text(value = lang.sets["settings"])]))
appBar = ft.AppBar(title = ft.Row(controls = [ft.Icon(ft.icons.SETTINGS_OUTLINED), ft.Text(value = i18n.lang.sets["settings"])]))

constructionNotice = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.CONSTRUCTION_OUTLINED, size = 40, color = ft.colors.AMBER)], alignment = ft.MainAxisAlignment.CENTER),
ft.Row(controls = [ft.Text(value = lang.sets["construction"], size = 15, color = ft.colors.AMBER, weight = ft.FontWeight.BOLD)], alignment = ft.MainAxisAlignment.CENTER)
ft.Row(controls = [ft.Text(value = i18n.lang.sets["construction"], size = 15, color = ft.colors.AMBER, weight = ft.FontWeight.BOLD)], alignment = ft.MainAxisAlignment.CENTER)
]
),
padding = 15
),
elevation = 0.5,
disabled = True
elevation = 0.5
)

settingsNotice = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.NOTE_OUTLINED), ft.Text(value = i18n.lang.sets["note"])])
]
),
padding = 15
),
elevation = 0.5
)

langSelect_dropd = ft.Dropdown(
label = i18n.lang.sets["pleaseSelect"],
value = "sys",
options = [
ft.dropdown.Option(key = "sys", text = i18n.lang.sets["systemDefault"]),
ft.dropdown.Option(key = "zh_CN", text = i18n.zh_CN.langInfo["orgiName"]),
ft.dropdown.Option(key = "en_US", text = i18n.en_US.langInfo["engName"])
]
)

langInfoText = "· " + i18n.lang.sets["langNameEng"] + i18n.lang.langInfo["engName"]
if i18n.lang.langInfo["orgiName"] != "":
langInfoText += "\n· " + i18n.lang.sets["langNameOrigial"] + i18n.lang.langInfo["orgiName"]
langInfoText += "\n· " + i18n.lang.sets["langCode"] + i18n.lang.langInfo["code"]
if i18n.lang.langInfo["font"] == "":
langInfoText += "\n· " + i18n.lang.sets["langFont"] + "Default"
else:
langInfoText += "\n· " + i18n.lang.sets["langFont"] + i18n.lang.langInfo["font"]
if i18n.lang.langInfo["machineTranslated"] == True:
langInfoText += "\n· " + i18n.lang.infomation["machineTranslate"]
if i18n.lang.langInfo["useKKGithub"] == True:
langInfoText += "\n· " + i18n.lang.infomation["updateUseKKGithubMirror"]

languageSetCard = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.LANGUAGE_OUTLINED), ft.Text(value = lang.sets["language"], size = 18)]),
ft.Row(controls = [ft.Icon(ft.icons.LANGUAGE_OUTLINED), ft.Text(value = i18n.lang.sets["language"], size = 18)]),
langSelect_dropd,
ft.Text(langInfoText)
]
),
padding = 15
Expand All @@ -34,10 +69,37 @@
disabled = True
)

colorMode_dropd = ft.Dropdown(
label = i18n.lang.sets["pleaseSelect"],
value = "sys",
options = [
ft.dropdown.Option(key = "sys", text = i18n.lang.sets["systemDefault"]),
ft.dropdown.Option(key = "light", text = i18n.lang.sets["colorLight"]),
ft.dropdown.Option(key = "dark", text = i18n.lang.sets["colorDark"])
]
)


colorSchemes_radio = ft.RadioGroup(
value = "blue",
content = ft.Row(controls = [
ft.Radio(value = "blue", label = i18n.lang.sets["blue"], fill_color = ft.colors.BLUE_800),
ft.Radio(value = "pink", label = i18n.lang.sets["pink"], fill_color = ft.colors.PINK_700),
ft.Radio(value = "green", label = i18n.lang.sets["green"], fill_color = ft.colors.GREEN_700),
ft.Radio(value = "brown", label = i18n.lang.sets["brown"], fill_color = ft.colors.BROWN),
ft.Radio(value = "purple", label = i18n.lang.sets["purple"], fill_color = ft.colors.DEEP_PURPLE),
]
)
)

appearancesSetCard = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.BRUSH_OUTLINED), ft.Text(value = lang.sets["appearances"], size = 18)]),
ft.Row(controls = [ft.Icon(ft.icons.BRUSH_OUTLINED), ft.Text(value = i18n.lang.sets["appearances"], size = 18)]),
ft.Text(value = i18n.lang.sets["colorMode"]),
colorMode_dropd,
ft.Text(value = i18n.lang.sets["colorSchemes"]),
colorSchemes_radio
]
),
padding = 15
Expand All @@ -46,10 +108,13 @@
disabled = True
)

playImmediatelyAfterLoaded_switch = ft.Switch(label = i18n.lang.sets["immediatelyPlay"])

playSetCard = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.PLAY_ARROW_OUTLINED), ft.Text(value = lang.sets["play"], size = 18)]),
ft.Row(controls = [ft.Icon(ft.icons.PLAY_ARROW_OUTLINED), ft.Text(value = i18n.lang.sets["play"], size = 18)]),
playImmediatelyAfterLoaded_switch
]
),
padding = 15
Expand All @@ -58,10 +123,13 @@
disabled = True
)

lyricsDefaultVisible_switch = ft.Switch(label = i18n.lang.sets["lyricsDefaultVis"], value = True)

lyricsSetCard = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.LYRICS_OUTLINED), ft.Text(value = lang.sets["lyrics"], size = 18)]),
ft.Row(controls = [ft.Icon(ft.icons.LYRICS_OUTLINED), ft.Text(value = i18n.lang.sets["lyrics"], size = 18)]),
lyricsDefaultVisible_switch
]
),
padding = 15
Expand All @@ -70,4 +138,22 @@
disabled = True
)

settings_pageView = ft.View("/settings", controls = [appBar, constructionNotice, languageSetCard, appearancesSetCard, playSetCard, lyricsSetCard])
feedbackSetCard = ft.Card(
content = ft.Container(
content = ft.Column(controls = [
ft.Row(controls = [ft.Icon(ft.icons.FEEDBACK_OUTLINED), ft.Text(value = i18n.lang.sets["feedback"], size = 18)]),
ft.Row(controls = [
ft.FilledTonalButton(text = i18n.lang.sets["bugReport"], icon = ft.icons.BUG_REPORT_OUTLINED, url = "https://github.com/WhatDamon/Simplay-Player/issues"),
ft.FilledTonalButton(text = i18n.lang.sets["shareIdeas"], icon = ft.icons.STAR_OUTLINE, url = r"https://github.com/WhatDamon/Simplay-Player/discussions/categories/%E6%83%B3%E6%B3%95"),
ft.FilledTonalButton(text = i18n.lang.sets["discussion"], icon = ft.icons.CHAT_OUTLINED, url = "https://github.com/WhatDamon/Simplay-Player/discussions"),
],
wrap = True
)
]
),
padding = 15
),
elevation = 0.5
)

settings_pageView = ft.View("/settings", controls = [appBar, constructionNotice, settingsNotice, languageSetCard, appearancesSetCard, playSetCard, lyricsSetCard, feedbackSetCard], scroll = ft.ScrollMode.AUTO)
38 changes: 33 additions & 5 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ def main(page: ft.Page):
log_init.logging.info("Window created")

page.theme = ft.Theme(color_scheme_seed = ft.colors.BLUE)
if lang.langInfo["font"] == None:
if lang.langInfo["font"] == "":
page.fonts = {"Inter": "./asset/Inter.ttc"}
page.theme = ft.Theme(font_family = "Inter")
else:
page.theme = ft.Theme(font_family = lang.langInfo["font"])
log_init.logging.info("Assets loaded")

page.scroll = ft.ScrollMode.AUTO

# 快捷键
def keyboardEventTrack(e: ft.KeyboardEvent):
log_init.logging.info("Keyboard event")
Expand Down Expand Up @@ -461,7 +459,18 @@ def closeFindUpdDlg(e):
def openAboutDlg(e):
about_dlg = ft.AlertDialog(
title = ft.Text(value = lang.mainMenu["about"]),
content = ft.Markdown("__Simplay Player__\n\rby WhatDamon & open source community\n\r- Version: " + ver + "\n\r- Powered by: Flet, Tinytag\n\r- Python: " + platform.python_version() + "\n\r- OS: " + platform.platform() + "-" + platform.machine(), selectable = True)
content = ft.Markdown("__Simplay Player__\n\rby WhatDamon & open source community\n\r- Version: " + ver + "\n\r- Powered by: Flet, Tinytag\n\r- Python: " + platform.python_version() + "\n\r- OS: " + platform.platform() + "-" + platform.machine(), selectable = True),
actions = [
ft.Row(controls = [
ft.TextButton(
text = lang.dialog["githubRepo"],
icon = ft.icons.COLLECTIONS_BOOKMARK_OUTLINED,
url = "https://github.com/WhatDamon/Simplay-Player/"
)
],
alignment = ft.MainAxisAlignment.END
)
]
)
page.dialog = about_dlg
about_dlg.open = True
Expand Down Expand Up @@ -816,9 +825,27 @@ def viewPop(e):
moreBtns_row = ft.Row(controls = [lyrics_btn, playInRepeat_btn, audioList_btn, audioInfo_btn, settings_btn])
btns_row = ft.Row(controls = [playbackCtrl_row, moreBtns_row], alignment = ft.MainAxisAlignment.SPACE_BETWEEN)

releaseWarning = ft.Text(visible = False, size = 10, color = ft.colors.GREY)

if "pre" in ver:
releaseWarning.value = "Pre-release version for testing purposes only! Current Version: " + ver
log_init.logging.warning("You are using a pre-release version")
releaseWarning.visible = True
log_init.logging.info("Set releaseWarning as visible")
if "debug" in ver:
releaseWarning.value = "Debug version for development use! Current Version: " + ver
log_init.logging.warning("You are using a debug version")
releaseWarning.visible = True
log_init.logging.info("Set releaseWarning as visible")
if "experiment" in ver:
releaseWarning.value = "Experimental version for develop and testing! Current Version: " + ver
log_init.logging.warning("You are using a experiment version")
releaseWarning.visible = True
log_init.logging.info("Set releaseWarning as visible")

page.overlay.append(audioList_menu)
log_init.logging.info("Append audioList_menu")
main_pageView = ft.View("/", controls = [ft.Column(controls = [ft.Row(controls = [menuBar]), audioBasicInfo, audioProgressBar, btns_row, lyrics_before, lyrics_text, lyrics_after])])
main_pageView = ft.View("/", controls = [ft.Column(controls = [ft.Row(controls = [menuBar]), audioBasicInfo, releaseWarning, audioProgressBar, btns_row, lyrics_before, lyrics_text, lyrics_after])], scroll = ft.ScrollMode.AUTO)
page.views.append(main_pageView)
page.go("/")
log_init.logging.info("Set to page: main")
Expand All @@ -845,6 +872,7 @@ def viewPop(e):
audioArtistText = lang.mainMenu["unknownArtist"]
work.audioInfo = lang.mainMenu["none"]
log_init.logging.info("Basic initialization complete")
log_init.logging.info("You are using " + ver)
from pages import settingsPage
log_init.logging.info("Imported settingsPage")
ft.app(target = main)

0 comments on commit 0cc1bb3

Please sign in to comment.