60 lines
1.2 KiB
Lua
60 lines
1.2 KiB
Lua
local Config = require('opus.config')
|
|
local UI = require('opus.ui')
|
|
|
|
local config = Config.load('secure', {
|
|
enabled = false,
|
|
timeout = 60,
|
|
})
|
|
|
|
local tab = UI.Tab {
|
|
tabTitle = 'Secure',
|
|
description = 'Secure options',
|
|
label1 = UI.Text {
|
|
x = 2, y = 3,
|
|
value = 'Screen Locking',
|
|
},
|
|
checkbox = UI.Checkbox {
|
|
x = 20, y = 3,
|
|
value = config.enabled
|
|
},
|
|
label2 = UI.Text {
|
|
x = 2, y = 4,
|
|
value = 'Lock timeout',
|
|
},
|
|
timeout = UI.TextEntry {
|
|
x = 20, y = 4, width = 6,
|
|
limit = 4,
|
|
transform = 'number',
|
|
value = config.timeout,
|
|
accelerators = {
|
|
enter = 'update',
|
|
},
|
|
},
|
|
label3 = UI.Text {
|
|
ex = -2, y = -2, width = 20,
|
|
textColor = colors.yellow,
|
|
},
|
|
button = UI.Button {
|
|
x = 20, y = 6,
|
|
text = 'Update',
|
|
event = 'update',
|
|
},
|
|
}
|
|
|
|
function tab:eventHandler(event)
|
|
if event.type =='checkbox_change' then
|
|
config.enabled = not not event.checked
|
|
|
|
elseif event.type == 'update' then
|
|
config.timeout = self.timeout.value
|
|
Config.update('secure', config)
|
|
|
|
self:emit({ type = 'success_message', message = 'Settings updated' })
|
|
self.label3.value = 'Restart is required'
|
|
self.label3:draw()
|
|
end
|
|
return UI.Tab.eventHandler(self, event)
|
|
end
|
|
|
|
return tab
|