Support disabling automatic database updates
This commit is contained in:
+82
-54
@@ -54,10 +54,10 @@ local BluetoothSettings = screen:new {
|
||||
bluetooth.enabled:set(enabled)
|
||||
end)
|
||||
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Paired Device",
|
||||
pad_bottom = 1,
|
||||
}, "settings_title")
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Paired Device",
|
||||
pad_bottom = 1,
|
||||
}, "settings_title")
|
||||
|
||||
local paired_container = self.menu.content:Object {
|
||||
flex = {
|
||||
@@ -80,10 +80,10 @@ local BluetoothSettings = screen:new {
|
||||
bluetooth.paired_device:set()
|
||||
end)
|
||||
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Nearby Devices",
|
||||
pad_bottom = 1,
|
||||
}, "settings_title")
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Nearby Devices",
|
||||
pad_bottom = 1,
|
||||
}, "settings_title")
|
||||
|
||||
local devices = self.menu.content:List {
|
||||
w = lvgl.PCT(100),
|
||||
@@ -123,9 +123,9 @@ local HeadphonesSettings = screen:new {
|
||||
createUi = function(self)
|
||||
self.menu = SettingsScreen("Headphones")
|
||||
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Maxiumum volume limit",
|
||||
}, "settings_title")
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Maxiumum volume limit",
|
||||
}, "settings_title")
|
||||
|
||||
local volume_chooser = self.menu.content:Dropdown {
|
||||
options = "Line Level (-10 dB)\nCD Level (+6 dB)\nMaximum (+10dB)",
|
||||
@@ -138,9 +138,9 @@ local HeadphonesSettings = screen:new {
|
||||
volume.limit_db:set(limits[selection])
|
||||
end)
|
||||
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Left/Right balance",
|
||||
}, "settings_title")
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Left/Right balance",
|
||||
}, "settings_title")
|
||||
|
||||
local balance = self.menu.content:Slider {
|
||||
w = lvgl.PCT(100),
|
||||
@@ -186,20 +186,20 @@ local DisplaySettings = screen:new {
|
||||
createUi = function(self)
|
||||
self.menu = SettingsScreen("Display")
|
||||
|
||||
local brightness_title = self.menu.content:Object {
|
||||
flex = {
|
||||
flex_direction = "row",
|
||||
justify_content = "flex-start",
|
||||
align_items = "flex-start",
|
||||
align_content = "flex-start",
|
||||
},
|
||||
w = lvgl.PCT(100),
|
||||
h = lvgl.SIZE_CONTENT,
|
||||
local brightness_title = self.menu.content:Object {
|
||||
flex = {
|
||||
flex_direction = "row",
|
||||
justify_content = "flex-start",
|
||||
align_items = "flex-start",
|
||||
align_content = "flex-start",
|
||||
},
|
||||
w = lvgl.PCT(100),
|
||||
h = lvgl.SIZE_CONTENT,
|
||||
|
||||
}
|
||||
brightness_title:Label { text = "Brightness", flex_grow = 1 }
|
||||
local brightness_pct = brightness_title:Label {}
|
||||
theme.set_style(brightness_pct, "settings_title")
|
||||
}
|
||||
brightness_title:Label { text = "Brightness", flex_grow = 1 }
|
||||
local brightness_pct = brightness_title:Label {}
|
||||
theme.set_style(brightness_pct, "settings_title")
|
||||
|
||||
local brightness = self.menu.content:Slider {
|
||||
w = lvgl.PCT(100),
|
||||
@@ -223,9 +223,9 @@ local InputSettings = screen:new {
|
||||
createUi = function(self)
|
||||
self.menu = SettingsScreen("Input Method")
|
||||
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Control scheme",
|
||||
}, "settings_title")
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Control scheme",
|
||||
}, "settings_title")
|
||||
|
||||
local schemes = controls.schemes()
|
||||
local option_to_scheme = {}
|
||||
@@ -261,9 +261,9 @@ local InputSettings = screen:new {
|
||||
controls.scheme:set(scheme)
|
||||
end)
|
||||
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Scroll Sensitivity",
|
||||
}, "settings_title")
|
||||
theme.set_style(self.menu.content:Label {
|
||||
text = "Scroll Sensitivity",
|
||||
}, "settings_title")
|
||||
|
||||
local slider_scale = 4; -- Power steering
|
||||
local sensitivity = self.menu.content:Slider {
|
||||
@@ -333,25 +333,53 @@ local DatabaseSettings = screen:new {
|
||||
widgets.Row(self.menu.content, "Schema version", db.version())
|
||||
widgets.Row(self.menu.content, "Size on disk", string.format("%.1f KiB", db.size() / 1024))
|
||||
|
||||
local actions_container = self.menu.content:Object {
|
||||
w = lvgl.PCT(100),
|
||||
h = lvgl.SIZE_CONTENT,
|
||||
flex = {
|
||||
flex_direction = "row",
|
||||
justify_content = "center",
|
||||
align_items = "space-evenly",
|
||||
align_content = "center",
|
||||
},
|
||||
pad_top = 4,
|
||||
pad_column = 4,
|
||||
}
|
||||
actions_container:add_style(styles.list_item)
|
||||
local auto_update_container = self.menu.content:Object {
|
||||
flex = {
|
||||
flex_direction = "row",
|
||||
justify_content = "flex-start",
|
||||
align_items = "flex-start",
|
||||
align_content = "flex-start",
|
||||
},
|
||||
w = lvgl.PCT(100),
|
||||
h = lvgl.SIZE_CONTENT,
|
||||
}
|
||||
auto_update_container:add_style(styles.list_item)
|
||||
auto_update_container:Label { text = "Auto update", flex_grow = 1 }
|
||||
local auto_update_sw = auto_update_container:Switch {}
|
||||
|
||||
auto_update_sw:onevent(lvgl.EVENT.VALUE_CHANGED, function()
|
||||
database.auto_update:set(auto_update_sw:enabled())
|
||||
end)
|
||||
|
||||
local actions_container = self.menu.content:Object {
|
||||
w = lvgl.PCT(100),
|
||||
h = lvgl.SIZE_CONTENT,
|
||||
flex = {
|
||||
flex_direction = "row",
|
||||
justify_content = "center",
|
||||
align_items = "space-evenly",
|
||||
align_content = "center",
|
||||
},
|
||||
pad_top = 4,
|
||||
pad_column = 4,
|
||||
}
|
||||
actions_container:add_style(styles.list_item)
|
||||
|
||||
local update = actions_container:Button {}
|
||||
update:Label { text = "Update" }
|
||||
update:Label { text = "Update now" }
|
||||
update:onClicked(function()
|
||||
database.update()
|
||||
end)
|
||||
|
||||
self.bindings = {
|
||||
database.auto_update:bind(function(en)
|
||||
if en then
|
||||
auto_update_sw:add_state(lvgl.STATE.CHECKED)
|
||||
else
|
||||
auto_update_sw:clear_state(lvgl.STATE.CHECKED)
|
||||
end
|
||||
end),
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
@@ -383,13 +411,13 @@ return screen:new {
|
||||
flex_grow = 1,
|
||||
}
|
||||
|
||||
local function section(name)
|
||||
local elem = self.list:Label {
|
||||
text = name,
|
||||
pad_left = 4,
|
||||
}
|
||||
theme.set_style(elem, "settings_title")
|
||||
end
|
||||
local function section(name)
|
||||
local elem = self.list:Label {
|
||||
text = name,
|
||||
pad_left = 4,
|
||||
}
|
||||
theme.set_style(elem, "settings_title")
|
||||
end
|
||||
|
||||
local function submenu(name, class)
|
||||
local item = self.list:add_btn(nil, name)
|
||||
|
||||
Reference in New Issue
Block a user