Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2dfeb38

Browse files
Add timezone setting
1 parentfb23bfc commit2dfeb38

File tree

7 files changed

+856
-8
lines changed

7 files changed

+856
-8
lines changed

‎internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
importgc
22
importos
3-
importtime
43

54
frommpos.appsimportActivity
65
importmpos.ui

‎internal_filesystem/builtin/apps/com.micropythonos.settings/assets/settings.py‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
importmpos.config
44
importmpos.ui
5+
importmpos.time
56

67
# Used to list and edit all settings:
78
classSettingsActivity(Activity):
@@ -37,10 +38,10 @@ def __init__(self):
3738
{"title":"Light/Dark Theme","key":"theme_light_dark","value_label":None,"cont":None,"ui":"radiobuttons","ui_options": [("Light","light"), ("Dark","dark")]},
3839
{"title":"Theme Color","key":"theme_primary_color","value_label":None,"cont":None,"placeholder":"HTML hex color, like: EC048C","ui":"dropdown","ui_options":theme_colors},
3940
{"title":"Restart to Bootloader","key":"boot_mode","value_label":None,"cont":None,"ui":"radiobuttons","ui_options": [("Normal","normal"), ("Bootloader","bootloader")]},# special that doesn't get saved
41+
{"title":"Timezone","key":"timezone","value_label":None,"cont":None,"ui":"dropdown","ui_options":self.get_timezone_tuples(),"changed_callback":lambda :mpos.time.refresh_timezone_preference()},
4042
# This is currently only in the drawer but would make sense to have it here for completeness:
4143
#{"title": "Display Brightness", "key": "display_brightness", "value_label": None, "cont": None, "placeholder": "A value from 0 to 100."},
4244
# Maybe also add font size (but ideally then all fonts should scale up/down)
43-
#{"title": "Timezone", "key": "timezone", "value_label": None, "cont": None, "placeholder": "Example: Europe/Prague"},
4445
]
4546

4647
defonCreate(self):
@@ -59,6 +60,7 @@ def onResume(self, screen):
5960
# Create settings entries
6061
screen.clean()
6162
forsettinginself.settings:
63+
#print(f"setting {setting.get('title')} has changed_callback {setting.get('changed_callback')}")
6264
# Container for each setting
6365
setting_cont=lv.obj(screen)
6466
setting_cont.set_width(lv.pct(100))
@@ -91,6 +93,10 @@ def startSettingActivity(self, setting):
9193
intent.putExtra("setting",setting)
9294
self.startActivity(intent)
9395

96+
@staticmethod
97+
defget_timezone_tuples():
98+
return [(tz,tz)fortzinmpos.time.get_timezones()]
99+
94100
# Used to edit one setting:
95101
classSettingActivity(Activity):
96102

@@ -109,6 +115,7 @@ def __init__(self):
109115

110116
defonCreate(self):
111117
setting=self.getIntent().extras.get("setting")
118+
#print(f"onCreate changed_callback: {setting.get('changed_callback')}")
112119
settings_screen_detail=lv.obj()
113120
settings_screen_detail.set_style_pad_all(mpos.ui.pct_of_display_width(2),0)
114121
settings_screen_detail.set_flex_flow(lv.FLEX_FLOW.COLUMN)
@@ -146,7 +153,12 @@ def onCreate(self):
146153
elifuiandui=="dropdown"andui_options:
147154
self.dropdown=lv.dropdown(settings_screen_detail)
148155
self.dropdown.set_width(lv.pct(100))
149-
options_with_newlines="\n".join(f"{option[0]} ({option[1]})"foroptioninui_options)
156+
options_with_newlines=""
157+
foroptioninui_options:
158+
ifoption[0]!=option[1]:
159+
options_with_newlines+= (f"{option[0]} ({option[1]})\n")
160+
else:# don't show identical options
161+
options_with_newlines+= (f"{option[0]}\n")
150162
self.dropdown.set_options(options_with_newlines)
151163
# select the right one:
152164
fori, (option_text,option_value)inenumerate(ui_options):
@@ -282,8 +294,14 @@ def save_setting(self, setting):
282294
new_value=self.textarea.get_text()
283295
else:
284296
new_value=""
297+
old_value=self.prefs.get_string(setting["key"])
285298
editor=self.prefs.edit()
286299
editor.put_string(setting["key"],new_value)
287300
editor.commit()
288301
setting["value_label"].set_text(new_valueifnew_valueelse"(not set)")
302+
changed_callback=setting.get("changed_callback")
303+
#print(f"changed_callback: {changed_callback}")
304+
ifchanged_callbackandold_value!=new_value:
305+
print(f"Setting{setting['key']} changed from{old_value} to{new_value}, calling changed_callback...")
306+
changed_callback()
289307
self.finish()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp