DoubleSpinWidget, SpinWidget: add units, make usage more consistent (#9046)

This commit is contained in:
zwim
2022-05-24 00:25:50 +02:00
committed by GitHub
parent 13274d6212
commit d5d5867d4e
18 changed files with 184 additions and 75 deletions

View File

@@ -397,9 +397,12 @@ function ReaderHighlight:addToMainMenu(menu_items)
text = _("Long-press on text"),
sub_item_table = {
{
text = _("Highlight long-press interval"),
text_func = function()
return T(_("Highlight long-press interval: %1 s"),
G_reader_settings:readSetting("highlight_long_hold_threshold_s", 3))
end,
keep_menu_open = true,
callback = function()
callback = function(touchmenu_instance)
local SpinWidget = require("ui/widget/spinwidget")
local items = SpinWidget:new{
title_text = _("Highlight long-press interval"),
@@ -408,15 +411,17 @@ If a touch is not released in this interval, it is considered a long-press. On d
The interval value is in seconds and can range from 3 to 20 seconds.]]),
width = math.floor(Screen:getWidth() * 0.75),
value = G_reader_settings:readSetting("highlight_long_hold_threshold", 3),
value = G_reader_settings:readSetting("highlight_long_hold_threshold_s", 3),
value_min = 3,
value_max = 20,
value_step = 1,
value_hold_step = 5,
unit = C_("Time", "s"),
ok_text = _("Set interval"),
default_value = 3,
callback = function(spin)
G_reader_settings:saveSetting("highlight_long_hold_threshold", spin.value)
G_reader_settings:saveSetting("highlight_long_hold_threshold_s", spin.value)
if touchmenu_instance then touchmenu_instance:updateItems() end
end
}
UIManager:show(items)
@@ -1425,7 +1430,7 @@ function ReaderHighlight:onHoldRelease()
local long_final_hold = false
if self.hold_last_time then
local hold_duration = time.now() - self.hold_last_time
local long_hold_threshold_s = G_reader_settings:readSetting("highlight_long_hold_threshold", 3) -- seconds
local long_hold_threshold_s = G_reader_settings:readSetting("highlight_long_hold_threshold_s", 3) -- seconds
if hold_duration > time.s(long_hold_threshold_s) then
-- We stayed 3 seconds before release without updating selection
long_final_hold = true