mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
DoubleSpinWidget, SpinWidget: add units, make usage more consistent (#9046)
This commit is contained in:
@@ -7,6 +7,7 @@ local SpinWidget = require("ui/widget/spinwidget")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local powerd = Device:getPowerDevice()
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local ReaderDeviceStatus = InputContainer:new{
|
||||
@@ -36,8 +37,8 @@ function ReaderDeviceStatus:init()
|
||||
UIManager:close(self.battery_confirm_box)
|
||||
end
|
||||
self.battery_confirm_box = ConfirmBox:new {
|
||||
text = is_charging and T(_("High battery level: %1%\n\nDismiss battery level alert?"), battery_capacity)
|
||||
or T(_("Low battery level: %1%\n\nDismiss battery level alert?"), battery_capacity),
|
||||
text = is_charging and T(_("High battery level: %1 %\n\nDismiss battery level alert?"), battery_capacity)
|
||||
or T(_("Low battery level: %1 %\n\nDismiss battery level alert?"), battery_capacity),
|
||||
ok_text = _("Dismiss"),
|
||||
dismissable = false,
|
||||
ok_callback = function()
|
||||
@@ -154,6 +155,7 @@ function ReaderDeviceStatus:addToMainMenu(menu_items)
|
||||
value_min = 1,
|
||||
value_max = 60,
|
||||
default_value = 10,
|
||||
unit = C_("Time", "min"),
|
||||
value_hold_step = 5,
|
||||
title_text = _("Battery check interval"),
|
||||
callback = function(spin)
|
||||
@@ -172,7 +174,7 @@ function ReaderDeviceStatus:addToMainMenu(menu_items)
|
||||
table.insert(menu_items.device_status_alarm.sub_item_table,
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Thresholds: %1% – %2%"), self.battery_threshold, self.battery_threshold_high)
|
||||
return T(_("Thresholds: %1 % / %2 %"), self.battery_threshold, self.battery_threshold_high)
|
||||
end,
|
||||
enabled_func = function()
|
||||
return G_reader_settings:isTrue("device_status_battery_alarm")
|
||||
@@ -199,16 +201,12 @@ High level threshold is checked when the device is charging.]]),
|
||||
right_default = 100,
|
||||
right_hold_step = 5,
|
||||
default_values = true,
|
||||
unit = "%",
|
||||
callback = function(left_value, right_value)
|
||||
if not left_value then -- "Default" button pressed
|
||||
left_value = 20
|
||||
right_value = 100
|
||||
end
|
||||
self.battery_threshold = left_value
|
||||
self.battery_threshold_high = right_value
|
||||
G_reader_settings:saveSetting("device_status_battery_threshold", self.battery_threshold)
|
||||
G_reader_settings:saveSetting("device_status_battery_threshold_high", self.battery_threshold_high)
|
||||
UIManager:close(thresholds_widget)
|
||||
touchmenu_instance:updateItems()
|
||||
powerd:setDismissBatteryStatus(false)
|
||||
end,
|
||||
@@ -249,6 +247,7 @@ High level threshold is checked when the device is charging.]]),
|
||||
value_min = 1,
|
||||
value_max = 60,
|
||||
default_value = 5,
|
||||
unit = C_("Time", "min"),
|
||||
value_hold_step = 5,
|
||||
title_text = _("Memory check interval"),
|
||||
callback = function(spin)
|
||||
@@ -278,6 +277,7 @@ High level threshold is checked when the device is charging.]]),
|
||||
value_min = 20,
|
||||
value_max = 500,
|
||||
default_value = 100,
|
||||
unit = C_("Data storage size", "MB"),
|
||||
value_step = 5,
|
||||
value_hold_step = 10,
|
||||
title_text = _("Memory alert threshold"),
|
||||
|
||||
@@ -630,14 +630,14 @@ function ReaderFooter:set_custom_text(touchmenu_instance)
|
||||
title = "Enter a custom text",
|
||||
fields = {
|
||||
{
|
||||
text = self.custom_text or "",
|
||||
text = self.custom_text or "",
|
||||
description = _("Custom string:"),
|
||||
input_type = "string",
|
||||
},
|
||||
{
|
||||
text = self.custom_text_repetitions,
|
||||
description =_("Number of repetitions:"),
|
||||
input_type = "number",
|
||||
input_type = "number",
|
||||
},
|
||||
},
|
||||
buttons = {
|
||||
@@ -1198,7 +1198,7 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
value_max = 36,
|
||||
default_value = 14,
|
||||
ok_text = _("Set size"),
|
||||
title_text = _("Footer font size"),
|
||||
title_text = _("Footer font size"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
self.settings.text_font_size = spin.value
|
||||
@@ -1251,7 +1251,7 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
value_max = 98,
|
||||
default_value = DMINIBAR_CONTAINER_HEIGHT,
|
||||
ok_text = _("Set height"),
|
||||
title_text = _("Container height"),
|
||||
title_text = _("Container height"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
self.settings.container_height = spin.value
|
||||
@@ -1277,7 +1277,7 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
value_max = 49,
|
||||
default_value = 1,
|
||||
ok_text = _("Set margin"),
|
||||
title_text = _("Container bottom margin"),
|
||||
title_text = _("Container bottom margin"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
self.settings.container_bottom_padding = spin.value
|
||||
@@ -1295,7 +1295,7 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
sub_item_table = {
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Book title: %1%"), self.settings.book_title_max_width_pct)
|
||||
return T(_("Book title: %1 %"), self.settings.book_title_max_width_pct)
|
||||
end,
|
||||
callback = function(touchmenu_instance)
|
||||
local SpinWidget = require("ui/widget/spinwidget")
|
||||
@@ -1305,7 +1305,8 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
value_step = 5,
|
||||
value_hold_step = 20,
|
||||
value_max = 100,
|
||||
title_text = _("Maximum width"),
|
||||
unit = "%",
|
||||
title_text = _("Maximum width"),
|
||||
info_text = _("Maximum book title width in percentage of screen width"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
@@ -1320,7 +1321,7 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
},
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Current chapter: %1%"), self.settings.book_chapter_max_width_pct)
|
||||
return T(_("Current chapter: %1 %"), self.settings.book_chapter_max_width_pct)
|
||||
end,
|
||||
callback = function(touchmenu_instance)
|
||||
local SpinWidget = require("ui/widget/spinwidget")
|
||||
@@ -1330,7 +1331,8 @@ function ReaderFooter:addToMainMenu(menu_items)
|
||||
value_step = 5,
|
||||
value_hold_step = 20,
|
||||
value_max = 100,
|
||||
title_text = _("Maximum width"),
|
||||
unit = "%",
|
||||
title_text = _("Maximum width"),
|
||||
info_text = _("Maximum chapter width in percentage of screen width"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
@@ -1572,7 +1574,7 @@ With this enabled, the current page is included, so the count goes from n to 1 i
|
||||
table.insert(sub_items[settings_submenu_num].sub_item_table, 4, {
|
||||
text_func = function()
|
||||
if self.settings.battery_hide_threshold <= (Device:hasAuxBattery() and 200 or 100) then
|
||||
return T(_("Hide battery status if level higher than: %1%"), self.settings.battery_hide_threshold)
|
||||
return T(_("Hide battery status if level higher than: %1 %"), self.settings.battery_hide_threshold)
|
||||
else
|
||||
return _("Hide battery status")
|
||||
end
|
||||
@@ -1591,8 +1593,9 @@ With this enabled, the current page is included, so the count goes from n to 1 i
|
||||
value_min = 0,
|
||||
value_max = Device:hasAuxBattery() and 200 or 100,
|
||||
default_value = Device:hasAuxBattery() and 200 or 100,
|
||||
unit = "%",
|
||||
value_hold_step = 10,
|
||||
title_text = _("Hide battery threshold"),
|
||||
title_text = _("Hide battery threshold"),
|
||||
callback = function(spin)
|
||||
self.settings.battery_hide_threshold = spin.value
|
||||
self:refreshFooter(true, true)
|
||||
@@ -1747,7 +1750,7 @@ With this enabled, the current page is included, so the count goes from n to 1 i
|
||||
value_hold_step = 2,
|
||||
value_max = value_max,
|
||||
default_value = default_value,
|
||||
title_text = _("Progress bar size"),
|
||||
title_text = _("Progress bar size"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
if self.settings.progress_style_thin then
|
||||
@@ -1907,7 +1910,7 @@ With this enabled, the current page is included, so the count goes from n to 1 i
|
||||
},
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Minimal width: %1%"), self.settings.progress_bar_min_width_pct)
|
||||
return T(_("Minimal width: %1 %"), self.settings.progress_bar_min_width_pct)
|
||||
end,
|
||||
enabled_func = function()
|
||||
return self.settings.progress_bar_position == "alongside" and not self.settings.disable_progress_bar
|
||||
@@ -1921,7 +1924,8 @@ With this enabled, the current page is included, so the count goes from n to 1 i
|
||||
value_step = 5,
|
||||
value_hold_step = 20,
|
||||
value_max = 50,
|
||||
title_text = _("Minimal width"),
|
||||
unit = "%",
|
||||
title_text = _("Minimal width"),
|
||||
text = _("Minimal progress bar width in percentage of screen width"),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(spin)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,6 +5,7 @@ local UIManager = require("ui/uimanager")
|
||||
local logger = require("logger")
|
||||
local time = require("ui/time")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = require("ffi/util").template
|
||||
local Screen = Device.screen
|
||||
|
||||
@@ -162,6 +163,7 @@ Default value: %1 ms]]), scroll_activation_delay_default_ms),
|
||||
value_max = 2000,
|
||||
value_step = 100,
|
||||
value_hold_step = 500,
|
||||
unit = C_("Time", "ms"),
|
||||
ok_text = _("Set delay"),
|
||||
default_value = scroll_activation_delay_default_ms,
|
||||
callback = function(spin)
|
||||
|
||||
@@ -349,7 +349,7 @@ When the book's language tag is not among our presets, no specific features will
|
||||
if G_reader_settings:has("hyph_left_hyphen_min") or
|
||||
G_reader_settings:has("hyph_right_hyphen_min") then
|
||||
-- @translators to RTL language translators: %1/left is the min length of the start of a hyphenated word, %2/right is the min length of the end of a hyphenated word (note that there is yet no support for hyphenation with RTL languages, so this will mostly apply to LTR documents)
|
||||
return T(_("Left/right minimal sizes: %1 - %2"),
|
||||
return T(_("Left/right minimal sizes: %1 / %2"),
|
||||
G_reader_settings:readSetting("hyph_left_hyphen_min"),
|
||||
G_reader_settings:readSetting("hyph_right_hyphen_min"))
|
||||
end
|
||||
@@ -376,7 +376,7 @@ When the book's language tag is not among our presets, no specific features will
|
||||
-- the hyphenation changes happening
|
||||
width_factor = 0.6,
|
||||
default_values = true,
|
||||
default_text = _("Use language defaults"),
|
||||
default_text = T(_("Language defaults: %1 / %2"), alg_left_hyphen_min, alg_right_hyphen_min),
|
||||
title_text = _("Hyphenation limits"),
|
||||
info_text = _([[
|
||||
Set minimum length before hyphenation occurs.
|
||||
@@ -384,6 +384,9 @@ These settings will apply to all books with any hyphenation dictionary.
|
||||
'Use language defaults' resets them.]]),
|
||||
keep_shown_on_apply = true,
|
||||
callback = function(left_hyphen_min, right_hyphen_min)
|
||||
if left_hyphen_min == alg_left_hyphen_min and right_hyphen_min == alg_right_hyphen_min then
|
||||
left_hyphen_min, right_hyphen_min = nil, nil -- don't store default values
|
||||
end
|
||||
G_reader_settings:saveSetting("hyph_left_hyphen_min", left_hyphen_min)
|
||||
G_reader_settings:saveSetting("hyph_right_hyphen_min", right_hyphen_min)
|
||||
self.ui.document:setHyphLeftHyphenMin(G_reader_settings:readSetting("hyph_left_hyphen_min") or 0)
|
||||
|
||||
@@ -14,6 +14,7 @@ local logger = require("logger")
|
||||
local util = require("util")
|
||||
local time = require("ui/time")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local N_ = _.ngettext
|
||||
local T = require("ffi/util").template
|
||||
|
||||
@@ -150,6 +151,7 @@ If set to 0, keitai input is disabled entirely and only flick input can be used.
|
||||
value_min = 0,
|
||||
value_max = 10,
|
||||
value_step = 1,
|
||||
unit = C_("Time", "s"),
|
||||
ok_text = _("Set interval"),
|
||||
default_value = DEFAULT_KEITAI_TAP_INTERVAL_S,
|
||||
callback = function(spin)
|
||||
|
||||
@@ -7,7 +7,7 @@ local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
|
||||
-- Date at which the last migration snippet was added
|
||||
local CURRENT_MIGRATION_DATE = 20220426
|
||||
local CURRENT_MIGRATION_DATE = 20220523
|
||||
|
||||
-- Retrieve the date of the previous migration, if any
|
||||
local last_migration_date = G_reader_settings:readSetting("last_migration_date", 0)
|
||||
@@ -366,7 +366,7 @@ if last_migration_date < 20220205 then
|
||||
end
|
||||
end
|
||||
|
||||
-- Rename several time storing settings and shift their value to the new meaning
|
||||
-- Rename several time storing settings and shift their value to the new meaning see (#8999)
|
||||
if last_migration_date < 20220426 then
|
||||
local function migrateSettingsName(old, new, factor)
|
||||
factor = factor or 1
|
||||
@@ -387,6 +387,18 @@ if last_migration_date < 20220426 then
|
||||
migrateSettingsName("device_status_memory_interval", "device_status_memory_interval_minutes")
|
||||
end
|
||||
|
||||
-- Rename several time storing settings and shift their value to the new meaning follow up to (#8999)
|
||||
if last_migration_date < 20220523 then
|
||||
local function migrateSettingsName(old, new, factor)
|
||||
factor = factor or 1
|
||||
if G_reader_settings:readSetting(old) then
|
||||
local value = math.floor(G_reader_settings:readSetting(old) * factor)
|
||||
G_reader_settings:saveSetting(new, value)
|
||||
G_reader_settings:delSetting(old)
|
||||
end
|
||||
end
|
||||
migrateSettingsName("highlight_long_hold_threshold", "highlight_long_hold_threshold_s")
|
||||
end
|
||||
|
||||
-- We're done, store the current migration date
|
||||
G_reader_settings:saveSetting("last_migration_date", CURRENT_MIGRATION_DATE)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
local Screensaver = require("ui/screensaver")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local function hasLastFile()
|
||||
if G_reader_settings:hasNot("lastfile") then
|
||||
@@ -157,7 +158,8 @@ return {
|
||||
if G_reader_settings:nilOrFalse("screensaver_stretch_images") then
|
||||
return _("Stretch to fit screen")
|
||||
elseif G_reader_settings:readSetting("screensaver_stretch_limit_percentage") then
|
||||
return _("Stretch to fit screen (with limit)")
|
||||
return T(_("Stretch to fit screen (with limit: %1 %)"),
|
||||
G_reader_settings:readSetting("screensaver_stretch_limit_percentage"))
|
||||
else
|
||||
return _("Stretch to fit screen")
|
||||
end
|
||||
|
||||
@@ -391,7 +391,8 @@ function Screensaver:setStretchLimit(touchmenu_instance)
|
||||
value = G_reader_settings:readSetting("screensaver_stretch_limit_percentage", 8),
|
||||
value_min = 0,
|
||||
value_max = 25,
|
||||
default_value = 8, -- percent
|
||||
default_value = 8,
|
||||
unit = "%",
|
||||
title_text = _("Set maximum stretch limit"),
|
||||
ok_text = _("Set"),
|
||||
ok_always_enabled = true,
|
||||
|
||||
@@ -43,16 +43,19 @@ local DoubleSpinWidget = FocusManager:new{
|
||||
right_wrap = false,
|
||||
cancel_text = _("Close"),
|
||||
ok_text = _("Apply"),
|
||||
ok_always_enabled = false, -- set to true to enable OK button for unchanged values
|
||||
cancel_callback = nil,
|
||||
callback = nil,
|
||||
close_callback = nil,
|
||||
keep_shown_on_apply = false,
|
||||
-- Set this to add upper default button that applies default values with callback(nil, nil)
|
||||
-- Set this to add upper default button that applies default values with callback(left_default, right_default)
|
||||
default_values = false,
|
||||
default_text = nil,
|
||||
-- Optional extra button above ok/cancel buttons row
|
||||
extra_text = nil,
|
||||
extra_callback = nil,
|
||||
is_range = false, -- show a range separator in default button and between the spinners
|
||||
unit = nil,
|
||||
}
|
||||
|
||||
function DoubleSpinWidget:init()
|
||||
@@ -81,6 +84,11 @@ function DoubleSpinWidget:init()
|
||||
}
|
||||
end
|
||||
|
||||
if self.unit and self.unit ~= "" then
|
||||
self.left_precision = self.left_precision and self.left_precision or "%1d"
|
||||
self.right_precision = self.right_precision and self.right_precision or "%1d"
|
||||
end
|
||||
|
||||
-- Actually the widget layout
|
||||
self:update()
|
||||
end
|
||||
@@ -98,6 +106,7 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val
|
||||
value_hold_step = self.left_hold_step,
|
||||
precision = self.left_precision,
|
||||
wrap = self.left_wrap,
|
||||
unit = self.unit,
|
||||
}
|
||||
self:mergeLayoutInHorizontal(left_widget)
|
||||
local right_widget = NumberPickerWidget:new{
|
||||
@@ -109,6 +118,7 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val
|
||||
value_hold_step = self.right_hold_step,
|
||||
precision = self.right_precision,
|
||||
wrap = self.right_wrap,
|
||||
unit = self.unit,
|
||||
}
|
||||
self:mergeLayoutInHorizontal(right_widget)
|
||||
left_widget.picker_updated_callback = function(value)
|
||||
@@ -117,26 +127,43 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val
|
||||
right_widget.picker_updated_callback = function(value)
|
||||
self:update(left_widget:getValue(), value)
|
||||
end
|
||||
local separator_widget = TextWidget:new{
|
||||
text = self.is_range and "–" or "",
|
||||
face = self.title_face,
|
||||
bold = true,
|
||||
}
|
||||
|
||||
local text_max_width = math.floor(0.95 * self.width / 2)
|
||||
local left_vertical_group = VerticalGroup:new{
|
||||
align = "center",
|
||||
TextWidget:new{
|
||||
text = self.left_text,
|
||||
face = self.title_face,
|
||||
max_width = text_max_width,
|
||||
},
|
||||
left_widget,
|
||||
}
|
||||
local separator_vertical_group = VerticalGroup:new{
|
||||
align = "center",
|
||||
separator_widget,
|
||||
}
|
||||
local right_vertical_group = VerticalGroup:new{
|
||||
align = "center",
|
||||
TextWidget:new{
|
||||
right_widget,
|
||||
}
|
||||
|
||||
if self.left_text ~= "" or self.right_text ~= "" then
|
||||
table.insert(left_vertical_group, 1, TextWidget:new{
|
||||
text = self.left_text,
|
||||
face = self.title_face,
|
||||
max_width = text_max_width,
|
||||
})
|
||||
table.insert(separator_vertical_group, 1, TextWidget:new{
|
||||
text = "",
|
||||
face = self.title_face,
|
||||
})
|
||||
table.insert(right_vertical_group, 1, TextWidget:new{
|
||||
text = self.right_text,
|
||||
face = self.title_face,
|
||||
max_width = text_max_width,
|
||||
},
|
||||
right_widget,
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
local widget_group = HorizontalGroup:new{
|
||||
align = "center",
|
||||
CenterContainer:new{
|
||||
@@ -144,15 +171,19 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val
|
||||
w = self.width / 2,
|
||||
h = left_vertical_group:getSize().h,
|
||||
},
|
||||
left_vertical_group
|
||||
left_vertical_group,
|
||||
},
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{},
|
||||
separator_vertical_group,
|
||||
},
|
||||
CenterContainer:new{
|
||||
dimen = Geom:new{
|
||||
w = self.width / 2,
|
||||
h = right_vertical_group:getSize().h,
|
||||
},
|
||||
right_vertical_group
|
||||
}
|
||||
right_vertical_group,
|
||||
},
|
||||
}
|
||||
|
||||
local title_bar = TitleBar:new{
|
||||
@@ -167,17 +198,26 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val
|
||||
|
||||
local buttons = {}
|
||||
if self.default_values then
|
||||
local separator = self.is_range and "–" or "/"
|
||||
local unit = ""
|
||||
if self.unit then
|
||||
if self.unit == "°" then
|
||||
unit = self.unit
|
||||
elseif self.unit ~= "" then
|
||||
unit = "\xE2\x80\xAF" .. self.unit -- use Narrow No-Break Space (NNBSP) here
|
||||
end
|
||||
end
|
||||
table.insert(buttons, {
|
||||
{
|
||||
text = self.default_text or T(_("Apply default values: %1 / %2"),
|
||||
text = self.default_text or T(_("Default values: %1%3 %4 %2%3"),
|
||||
self.left_precision and string.format(self.left_precision, self.left_default) or self.left_default,
|
||||
self.right_precision and string.format(self.right_precision, self.right_default) or self.right_default),
|
||||
self.right_precision and string.format(self.right_precision, self.right_default) or self.right_default,
|
||||
unit, separator),
|
||||
callback = function()
|
||||
left_widget.value = self.left_default
|
||||
right_widget.value = self.right_default
|
||||
left_widget:update()
|
||||
right_widget:update()
|
||||
self.callback(nil, nil)
|
||||
end,
|
||||
}
|
||||
})
|
||||
@@ -209,7 +249,8 @@ function DoubleSpinWidget:update(numberpicker_left_value, numberpicker_right_val
|
||||
},
|
||||
{
|
||||
text = self.ok_text,
|
||||
enabled = self.left_value ~= left_widget:getValue() or self.right_value ~= right_widget:getValue(),
|
||||
enabled = self.ok_always_enabled or self.left_value ~= left_widget:getValue()
|
||||
or self.right_value ~= right_widget:getValue(),
|
||||
callback = function()
|
||||
self.left_value = left_widget:getValue()
|
||||
self.right_value = right_widget:getValue()
|
||||
|
||||
@@ -22,6 +22,7 @@ local VerticalSpan = require("ui/widget/verticalspan")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local time = require("ui/time")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local Screen = Device.screen
|
||||
|
||||
local FrontLightWidget = FocusManager:new{
|
||||
@@ -181,7 +182,7 @@ function FrontLightWidget:layout()
|
||||
self.fl_level,
|
||||
}
|
||||
local fl_min = Button:new{
|
||||
text = _("Min"),
|
||||
text = C_("Extrema", "Min"),
|
||||
margin = Size.margin.small,
|
||||
radius = 0,
|
||||
enabled = true,
|
||||
@@ -192,7 +193,7 @@ function FrontLightWidget:layout()
|
||||
end, -- min is 1 (We use 0 to mean "toggle")
|
||||
}
|
||||
local fl_max = Button:new{
|
||||
text = _("Max"),
|
||||
text = C_("Extrema", "Max"),
|
||||
margin = Size.margin.small,
|
||||
radius = 0,
|
||||
enabled = true,
|
||||
@@ -310,7 +311,7 @@ function FrontLightWidget:layout()
|
||||
self.nl_level,
|
||||
}
|
||||
local nl_min = Button:new{
|
||||
text = _("Min"),
|
||||
text = C_("Extrema", "Min"),
|
||||
margin = Size.margin.small,
|
||||
radius = 0,
|
||||
enabled = true,
|
||||
@@ -321,7 +322,7 @@ function FrontLightWidget:layout()
|
||||
end,
|
||||
}
|
||||
local nl_max = Button:new{
|
||||
text = _("Max"),
|
||||
text = C_("Extrema", "Max"),
|
||||
margin = Size.margin.small,
|
||||
radius = 0,
|
||||
enabled = true,
|
||||
|
||||
@@ -50,6 +50,7 @@ local NumberPickerWidget = FocusManager:new{
|
||||
date_year = nil,
|
||||
-- on update signal to the caller and pass updated value
|
||||
picker_updated_callback = nil,
|
||||
unit = "",
|
||||
}
|
||||
|
||||
function NumberPickerWidget:init()
|
||||
@@ -176,8 +177,16 @@ function NumberPickerWidget:init()
|
||||
end
|
||||
end
|
||||
|
||||
local unit = ""
|
||||
if self.unit then
|
||||
if self.unit == "°" then
|
||||
unit = self.unit
|
||||
elseif self.unit ~= "" then
|
||||
unit = "\xE2\x80\xAF" .. self.unit -- use Narrow No-Break Space (NNBSP) here
|
||||
end
|
||||
end
|
||||
self.text_value = Button:new{
|
||||
text = tostring(self.formatted_value),
|
||||
text = tostring(self.formatted_value) .. unit,
|
||||
bordersize = 0,
|
||||
padding = 0,
|
||||
text_font_face = self.spinner_face.font,
|
||||
|
||||
@@ -49,6 +49,7 @@ local SpinWidget = FocusManager:new{
|
||||
-- Optional extra button above ok/cancel buttons row
|
||||
option_text = nil,
|
||||
option_callback = nil,
|
||||
unit = nil,
|
||||
}
|
||||
|
||||
function SpinWidget:init()
|
||||
@@ -80,6 +81,9 @@ function SpinWidget:init()
|
||||
}
|
||||
end
|
||||
|
||||
if self.unit and self.unit ~= "" then
|
||||
self.precision = self.precision and self.precision or "%1d"
|
||||
end
|
||||
-- Actually the widget layout
|
||||
self:update()
|
||||
end
|
||||
@@ -102,6 +106,7 @@ function SpinWidget:update(numberpicker_value, numberpicker_value_index)
|
||||
picker_updated_callback = function(value, value_index)
|
||||
self:update(value, value_index)
|
||||
end,
|
||||
unit = self.unit,
|
||||
}
|
||||
self:mergeLayoutInVertical(value_widget)
|
||||
local value_group = HorizontalGroup:new{
|
||||
@@ -121,10 +126,18 @@ function SpinWidget:update(numberpicker_value, numberpicker_value_index)
|
||||
|
||||
local buttons = {}
|
||||
if self.default_value then
|
||||
local unit = ""
|
||||
if self.unit then
|
||||
if self.unit == "°" then
|
||||
unit = self.unit
|
||||
elseif self.unit ~= "" then
|
||||
unit = "\xE2\x80\xAF" .. self.unit -- use Narrow No-Break Space (NNBSP) here
|
||||
end
|
||||
end
|
||||
table.insert(buttons, {
|
||||
{
|
||||
text = self.default_text or T(_("Default value: %1"),
|
||||
self.precision and string.format(self.precision, self.default_value) or self.default_value),
|
||||
text = self.default_text or T(_("Default value: %1%2"),
|
||||
self.precision and string.format(self.precision, self.default_value) or self.default_value, unit),
|
||||
callback = function()
|
||||
value_widget.value = self.default_value
|
||||
value_widget:update()
|
||||
|
||||
@@ -4,6 +4,7 @@ This module contains miscellaneous helper functions for the KOReader frontend.
|
||||
|
||||
local BaseUtil = require("ffi/util")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = BaseUtil.template
|
||||
|
||||
local lshift = bit.lshift
|
||||
@@ -203,18 +204,18 @@ function util.secondsToHClock(seconds, withoutSeconds, hmsFormat, withDays)
|
||||
end
|
||||
if hmsFormat then
|
||||
-- @translators This is the 'h' for hour, like in 1h30m30s. This is a duration.
|
||||
time_string = time_string:gsub(":", _("h"), 1)
|
||||
time_string = time_string:gsub(":", C_("Time", "h"), 1)
|
||||
-- @translators This is the 'm' for minute, like in 1h30m30s. This is a duration.
|
||||
time_string = time_string:gsub(":", _("m"), 1)
|
||||
time_string = time_string:gsub("^00" .. _("h"), "") -- delete leading "00h"
|
||||
time_string = time_string:gsub(":", C_("Time", "m"), 1)
|
||||
time_string = time_string:gsub("^00" .. C_("Time", "h"), "") -- delete leading "00h"
|
||||
time_string = time_string:gsub("^0", "") -- delete leading "0"
|
||||
-- @translators This is the 's' for second, like in 1h30m30s. This is a duration.
|
||||
return withoutSeconds and time_string or (time_string .. _("s"))
|
||||
return withoutSeconds and time_string or (time_string .. C_("Time", "s"))
|
||||
else
|
||||
-- @translators This is the 'h' for hour, like in 1h30m30s. This is a duration.
|
||||
time_string = time_string:gsub(":", _("h"), 1)
|
||||
time_string = time_string:gsub(":", C_("Time", "h"), 1)
|
||||
time_string = time_string:gsub(":", "'", 1)
|
||||
time_string = time_string:gsub("^00" .. _("h"), "") -- delete leading "00h"
|
||||
time_string = time_string:gsub("^00" .. C_("Time", "h"), "") -- delete leading "00h"
|
||||
time_string = time_string:gsub("^0", "") -- delete leading "0"
|
||||
return withoutSeconds and time_string or (time_string .. SECONDS_SYMBOL)
|
||||
end
|
||||
|
||||
@@ -22,6 +22,7 @@ local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = FFIUtil.template
|
||||
local Screen = require("device").screen
|
||||
local util = require("util")
|
||||
@@ -483,7 +484,7 @@ function AutoWarmth:getLocationMenu()
|
||||
},
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Coordinates: (%1, %2)"), self.latitude, self.longitude)
|
||||
return T(_("Coordinates: (%1°, %2°)"), self.latitude, self.longitude)
|
||||
end,
|
||||
callback = function(touchmenu_instance)
|
||||
local location_widget = DoubleSpinWidget:new{
|
||||
@@ -503,6 +504,7 @@ function AutoWarmth:getLocationMenu()
|
||||
right_step = 0.1,
|
||||
right_hold_step = 5,
|
||||
right_precision = "%0.2f",
|
||||
unit = "°",
|
||||
callback = function(lat, long)
|
||||
self.latitude = lat
|
||||
self.longitude = long
|
||||
@@ -520,7 +522,7 @@ function AutoWarmth:getLocationMenu()
|
||||
},
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Altitude: %1m"), self.altitude)
|
||||
return T(_("Altitude: %1 m"), self.altitude)
|
||||
end,
|
||||
callback = function(touchmenu_instance)
|
||||
UIManager:show(SpinWidget:new{
|
||||
@@ -532,6 +534,7 @@ function AutoWarmth:getLocationMenu()
|
||||
wrap = false,
|
||||
value_step = 10,
|
||||
value_hold_step = 100,
|
||||
unit = C_("Length", "m"),
|
||||
ok_text = _("Set"),
|
||||
callback = function(spin)
|
||||
self.altitude = spin.value
|
||||
@@ -676,9 +679,9 @@ function AutoWarmth:getWarmthMenu()
|
||||
text_func = function()
|
||||
if Device:hasNaturalLight() then
|
||||
if self.warmth[num] <= 100 then
|
||||
return T(_("%1: %2%"), text, self.warmth[num])
|
||||
return T(_("%1: %2 %"), text, self.warmth[num])
|
||||
else
|
||||
return T(_("%1: 100% + ☾"), text)
|
||||
return T(_("%1: 100 % + ☾"), text)
|
||||
end
|
||||
else
|
||||
if self.warmth[num] <= 100 then
|
||||
@@ -699,6 +702,7 @@ function AutoWarmth:getWarmthMenu()
|
||||
wrap = false,
|
||||
value_step = math.floor(100 / device_max_warmth),
|
||||
value_hold_step = 10,
|
||||
unit = "%",
|
||||
ok_text = _("Set"),
|
||||
callback = function(spin)
|
||||
self.warmth[num] = spin.value
|
||||
|
||||
@@ -19,6 +19,7 @@ local util = require("util")
|
||||
local T = FFIUtil.template
|
||||
local time = require("ui/time")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local logger = require("logger")
|
||||
|
||||
if not Device:isTouchDevice() then
|
||||
@@ -457,6 +458,7 @@ Higher values mean faster screen updates, but also use more CPU.]]),
|
||||
value_max = 60.0,
|
||||
value_step = 1,
|
||||
value_hold_step = 15,
|
||||
unit = C_("Frequency", "Hz"),
|
||||
ok_text = _("Set rate"),
|
||||
default_value = default_value,
|
||||
callback = function(spin)
|
||||
@@ -484,6 +486,7 @@ The interval value is in milliseconds and can range from 0 (0 seconds) to 2000 (
|
||||
value_max = 2000,
|
||||
value_step = 50,
|
||||
value_hold_step = 200,
|
||||
unit = C_("Time", "ms"),
|
||||
ok_text = _("Set interval"),
|
||||
default_value = GestureDetector.TAP_INTERVAL_MS,
|
||||
callback = function(spin)
|
||||
@@ -510,6 +513,7 @@ The interval value is in milliseconds and can range from 0 (0 seconds) to 2000 (
|
||||
value_max = 2000,
|
||||
value_step = 50,
|
||||
value_hold_step = 200,
|
||||
unit = C_("Time", "ms"),
|
||||
ok_text = _("Set interval"),
|
||||
default_value = 0,
|
||||
callback = function(spin)
|
||||
@@ -535,6 +539,7 @@ The interval value is in milliseconds and can range from 100 (0.1 seconds) to 20
|
||||
value_max = 2000,
|
||||
value_step = 100,
|
||||
value_hold_step = 500,
|
||||
unit = C_("Time", "ms"),
|
||||
ok_text = _("Set interval"),
|
||||
default_value = GestureDetector.DOUBLE_TAP_INTERVAL_MS,
|
||||
callback = function(spin)
|
||||
@@ -561,6 +566,7 @@ The duration value is in milliseconds and can range from 100 (0.1 seconds) to 20
|
||||
value_max = 2000,
|
||||
value_step = 100,
|
||||
value_hold_step = 500,
|
||||
unit = C_("Time", "ms"),
|
||||
ok_text = _("Set duration"),
|
||||
default_value = GestureDetector.TWO_FINGER_TAP_DURATION_MS,
|
||||
callback = function(spin)
|
||||
@@ -587,6 +593,7 @@ The interval value is in milliseconds and can range from 100 (0.1 seconds) to 20
|
||||
value_max = 2000,
|
||||
value_step = 100,
|
||||
value_hold_step = 500,
|
||||
unit = C_("Time", "ms"),
|
||||
ok_text = _("Set interval"),
|
||||
default_value = GestureDetector.HOLD_INTERVAL_MS,
|
||||
callback = function(spin)
|
||||
@@ -612,6 +619,7 @@ The interval value is in milliseconds and can range from 100 (0.1 seconds) to 20
|
||||
value_min = 100,
|
||||
value_max = 2000,
|
||||
value_step = 100,
|
||||
unit = C_("Time", "ms"),
|
||||
value_hold_step = 500,
|
||||
ok_text = _("Set interval"),
|
||||
default_value = GestureDetector.SWIPE_INTERVAL_MS,
|
||||
|
||||
@@ -20,6 +20,7 @@ local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local N_ = _.ngettext
|
||||
local T = FFIUtil.template
|
||||
|
||||
@@ -935,21 +936,21 @@ function ReaderStatistics:addToMainMenu(menu_items)
|
||||
sub_item_table = {
|
||||
{
|
||||
text_func = function()
|
||||
return T(_("Read page duration limits: %1 s / %2 s"),
|
||||
return T(_("Read page duration limits: %1 s – %2 s"),
|
||||
self.settings.min_sec, self.settings.max_sec)
|
||||
end,
|
||||
callback = function(touchmenu_instance)
|
||||
local DoubleSpinWidget = require("/ui/widget/doublespinwidget")
|
||||
local durations_widget
|
||||
durations_widget = DoubleSpinWidget:new{
|
||||
left_text = _("Min"),
|
||||
left_text = C_("Extrema", "Min"),
|
||||
left_value = self.settings.min_sec,
|
||||
left_default = DEFAULT_MIN_READ_SEC,
|
||||
left_min = 0,
|
||||
left_max = 120,
|
||||
left_step = 1,
|
||||
left_hold_step = 10,
|
||||
right_text = _("Max"),
|
||||
right_text = C_("Extrema", "Max"),
|
||||
right_value = self.settings.max_sec,
|
||||
right_default = DEFAULT_MAX_READ_SEC,
|
||||
right_min = 10,
|
||||
@@ -957,19 +958,17 @@ function ReaderStatistics:addToMainMenu(menu_items)
|
||||
right_step = 10,
|
||||
right_hold_step = 60,
|
||||
default_values = true,
|
||||
is_range = true,
|
||||
-- @translators This is the time unit for seconds.
|
||||
unit = C_("Time", "s"),
|
||||
title_text = _("Read page duration limits"),
|
||||
info_text = _([[
|
||||
Set min and max time spent (in seconds) on a page for it to be counted as read in statistics.
|
||||
The min value ensures pages you quickly browse and skip are not included.
|
||||
The max value ensures a page you stay on for a long time (because you fell asleep or went away) will be included, but with a duration capped to this specified max value.]]),
|
||||
callback = function(min, max)
|
||||
if not min then -- "Default" button pressed
|
||||
min = DEFAULT_MIN_READ_SEC
|
||||
max = DEFAULT_MAX_READ_SEC
|
||||
end
|
||||
self.settings.min_sec = min
|
||||
self.settings.max_sec = max
|
||||
UIManager:close(durations_widget)
|
||||
touchmenu_instance:updateItems()
|
||||
end,
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ local TextWidget = require("ui/widget/textwidget")
|
||||
local bit = require("bit")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local CHUNK_SIZE = 80 * 40 -- max. nb of read bytes (reduce this, if taps are not detected)
|
||||
@@ -550,6 +551,7 @@ Aliases (shortcuts) to frequently used commands can be placed in:
|
||||
value_max = 30,
|
||||
value_hold_step = 2,
|
||||
default_value = 16,
|
||||
unit = C_("Data storage size", "kB"),
|
||||
title_text = _("Terminal emulator buffer size (kB)"),
|
||||
callback = function(spin)
|
||||
G_reader_settings:saveSetting("terminal_buffer_size", spin.value)
|
||||
|
||||
Reference in New Issue
Block a user