[UX] Set global settings independent of local setting (#5522)

pull/5530/head
yparitcher 5 years ago committed by Frans de Jonge
parent 6c68df42ec
commit aa165cefe9

@ -9,6 +9,7 @@ local InputDialog = require("ui/widget/inputdialog")
local JSON = require("json")
local KeyValuePage = require("ui/widget/keyvaluepage")
local LuaData = require("luadata")
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
local NetworkMgr = require("ui/network/manager")
local Trapper = require("ui/trapper")
local UIManager = require("ui/uimanager")
@ -249,7 +250,7 @@ If you'd like to change the order in which dictionaries are queried (and their r
self.disable_fuzzy_search = not self.disable_fuzzy_search
end,
hold_callback = function()
self:makeDisableFuzzyDefault(self.disable_fuzzy_search)
self:toggleFuzzyDefault()
end,
separator = true,
},
@ -950,21 +951,37 @@ function ReaderDictionary:onSaveSettings()
self.ui.doc_settings:saveSetting("disable_fuzzy_search", self.disable_fuzzy_search)
end
function ReaderDictionary:makeDisableFuzzyDefault(disable_fuzzy_search)
logger.dbg("disable fuzzy search", self.disable_fuzzy_search)
UIManager:show(ConfirmBox:new{
function ReaderDictionary:toggleFuzzyDefault()
local disable_fuzzy_search = G_reader_settings:isTrue("disable_fuzzy_search")
UIManager:show(MultiConfirmBox:new{
text = T(
disable_fuzzy_search
and _("Disable fuzzy search by default?")
or _("Enable fuzzy search by default?")
),
ok_text = T(
disable_fuzzy_search
and _("Disable")
or _("Enable")
and _([[
Would you like to enable or disable fuzzy search by default?
Fuzzy search can match epuisante, épuisante and épuisantes to épuisant, even if only the latter has an entry in the dictionary. It can be disabled to improve performance, but it might be worthwhile to look into disabling unneeded dictionaries before disabling fuzzy search.
The current default () is disabled.]])
or _([[
Would you like to enable or disable fuzzy search by default?
Fuzzy search can match epuisante, épuisante and épuisantes to épuisant, even if only the latter has an entry in the dictionary. It can be disabled to improve performance, but it might be worthwhile to look into disabling unneeded dictionaries before disabling fuzzy search.
The current default () is enabled.]])
),
ok_callback = function()
G_reader_settings:saveSetting("disable_fuzzy_search", disable_fuzzy_search)
choice1_text_func = function()
return disable_fuzzy_search and _("Disable (★)") or _("Disable")
end,
choice1_enabled = not disable_fuzzy_search,
choice1_callback = function()
G_reader_settings:saveSetting("disable_fuzzy_search", true)
end,
choice2_text_func = function()
return disable_fuzzy_search and _("Enable") or _("Enable (★)")
end,
choice2_enabled = disable_fuzzy_search,
choice2_callback = function()
G_reader_settings:saveSetting("disable_fuzzy_search", false)
end,
})
end

@ -1,10 +1,10 @@
local ButtonDialog = require("ui/widget/buttondialog")
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local InfoMessage = require("ui/widget/infomessage")
local Notification = require("ui/widget/notification")
local InputContainer = require("ui/widget/container/inputcontainer")
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
local Notification = require("ui/widget/notification")
local TimeVal = require("ui/timeval")
local Translator = require("ui/translator")
local UIManager = require("ui/uimanager")
@ -116,7 +116,7 @@ function ReaderHighlight:genHighlightDrawerMenu()
self.view.highlight.disabled = not self.view.highlight.disabled
end,
hold_callback = function(touchmenu_instance)
self:makeDefault(not self.view.highlight.disabled)
self:toggleDefault()
end,
separator = true,
},
@ -1179,17 +1179,24 @@ function ReaderHighlight:onClose()
self:clear()
end
function ReaderHighlight:makeDefault(highlight_disabled)
local new_text
if highlight_disabled then
new_text = _("Disable highlight by default.")
else
new_text = _("Enable highlight by default.")
end
UIManager:show(ConfirmBox:new{
text = new_text,
ok_callback = function()
G_reader_settings:saveSetting("highlight_disabled", highlight_disabled)
function ReaderHighlight:toggleDefault()
local highlight_disabled = G_reader_settings:isTrue("highlight_disabled")
UIManager:show(MultiConfirmBox:new{
text = highlight_disabled and _("Would you like to enable or disable highlighting by default?\n\nThe current default (★) is disabled.")
or _("Would you like to enable or disable highlighting by default?\n\nThe current default (★) is enabled."),
choice1_text_func = function()
return highlight_disabled and _("Disable (★)") or _("Disable")
end,
choice1_enabled = not highlight_disabled,
choice1_callback = function()
G_reader_settings:saveSetting("highlight_disabled", true)
end,
choice2_text_func = function()
return highlight_disabled and _("Enable") or _("Enable (★)")
end,
choice2_enabled = highlight_disabled,
choice2_callback = function()
G_reader_settings:saveSetting("highlight_disabled", false)
end,
})
end

@ -1,9 +1,9 @@
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local Geom = require("ui/geometry")
local InputContainer = require("ui/widget/container/inputcontainer")
local Math = require("optmath")
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
local UIManager = require("ui/uimanager")
local logger = require("logger")
local _ = require("gettext")
@ -244,13 +244,24 @@ function ReaderPaging:addToMainMenu(menu_items)
self.ui:handleEvent(Event:new("ToggleReadingOrder"))
end,
hold_callback = function(touchmenu_instance)
UIManager:show(ConfirmBox:new{
text = self.inverse_reading_order and _("Enable right to left reading by default?")
or _("Disable right to left reading by default?"),
ok_text = self.inverse_reading_order and _("Enable")
or _("Disable"),
ok_callback = function()
G_reader_settings:saveSetting("inverse_reading_order", self.inverse_reading_order)
local inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
UIManager:show(MultiConfirmBox:new{
text = inverse_reading_order and _("The default (★) for newly opened books is right-to-left (RTL) page turning.\n\nWould you like to change it?")
or _("The default (★) for newly opened books is left-to-right (LTR) page turning.\n\nWould you like to change it?"),
choice1_text_func = function()
return inverse_reading_order and _("LTR") or _("LTR (★)")
end,
choice1_enabled = inverse_reading_order,
choice1_callback = function()
G_reader_settings:saveSetting("inverse_reading_order", false)
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
choice2_text_func = function()
return inverse_reading_order and _("RTL (★)") or _("RTL")
end,
choice2_enabled = not inverse_reading_order,
choice2_callback = function()
G_reader_settings:saveSetting("inverse_reading_order", true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
})

@ -3,6 +3,7 @@ local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local InputContainer = require("ui/widget/container/inputcontainer")
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
local ProgressWidget = require("ui/widget/progresswidget")
local ReaderPanning = require("apps/reader/modules/readerpanning")
local TimeVal = require("ui/timeval")
@ -370,13 +371,24 @@ function ReaderRolling:addToMainMenu(menu_items)
self.ui:handleEvent(Event:new("ToggleReadingOrder"))
end,
hold_callback = function(touchmenu_instance)
UIManager:show(ConfirmBox:new{
text = self.inverse_reading_order and _("Enable right to left reading by default?")
or _("Disable right to left reading by default?"),
ok_text = self.inverse_reading_order and _("Enable")
or _("Disable"),
ok_callback = function()
G_reader_settings:saveSetting("inverse_reading_order", self.inverse_reading_order)
local inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
UIManager:show(MultiConfirmBox:new{
text = inverse_reading_order and _("The default (★) for newly opened books is right-to-left (RTL) page turning.\n\nWould you like to change it?")
or _("The default (★) for newly opened books is left-to-right (LTR) page turning.\n\nWould you like to change it?"),
choice1_text_func = function()
return inverse_reading_order and _("LTR") or _("LTR (★)")
end,
choice1_enabled = inverse_reading_order,
choice1_callback = function()
G_reader_settings:saveSetting("inverse_reading_order", false)
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
choice2_text_func = function()
return inverse_reading_order and _("RTL (★)") or _("RTL")
end,
choice2_enabled = not inverse_reading_order,
choice2_callback = function()
G_reader_settings:saveSetting("inverse_reading_order", true)
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
})

@ -2,6 +2,7 @@ local ConfirmBox = require("ui/widget/confirmbox")
local Event = require("ui/event")
local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer")
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
local UIManager = require("ui/uimanager")
local Math = require("optmath")
local lfs = require("libs/libkoreader-lfs")
@ -428,14 +429,24 @@ function ReaderTypeset:addToMainMenu(menu_items)
end
function ReaderTypeset:makeDefaultFloatingPunctuation()
local toggler = self.floating_punctuation == 1 and _("On") or _("Off")
UIManager:show(ConfirmBox:new{
text = T(
_("Set default hanging punctuation to %1?"),
toggler
),
ok_callback = function()
G_reader_settings:saveSetting("floating_punctuation", self.floating_punctuation)
local floating_punctuation = G_reader_settings:isTrue("floating_punctuation")
UIManager:show(MultiConfirmBox:new{
text = floating_punctuation and _("Would you like to enable or disable hanging punctuation by default?\n\nThe current default (★) is enabled.")
or _("Would you like to enable or disable hanging punctuation by default?\n\nThe current default (★) is disabled."),
choice1_text_func = function()
return floating_punctuation and _("Disable") or _("Disable (★)")
end,
choice1_enabled = floating_punctuation,
choice1_callback = function()
G_reader_settings:saveSetting("floating_punctuation", false)
end,
choice2_text_func = function()
return floating_punctuation and _("Enable (★)") or _("Enable")
end,
choice2_text = _("Enable"),
choice2_enabled = not floating_punctuation,
choice2_callback = function()
G_reader_settings:saveSetting("floating_punctuation", true)
end,
})
end

@ -43,11 +43,15 @@ local MultiConfirmBox = InputContainer:new{
text = _("no text"),
face = Font:getFace("infofont"),
choice1_text = _("Choice 1"),
choice1_text_func = nil,
choice2_text = _("Choice 2"),
choice2_text_func = nil,
cancel_text = _("Cancel"),
choice1_callback = function() end,
choice2_callback = function() end,
cancel_callback = function() end,
choice1_enabled = true,
choice2_enabled = true,
margin = Size.margin.default,
padding = Size.padding.default,
dismissable = true, -- set to false if any button callback is required
@ -102,6 +106,8 @@ function MultiConfirmBox:init()
},
{
text = self.choice1_text,
text_func = self.choice1_text_func,
enabled = self.choice1_enabled,
callback = function()
self.choice1_callback()
UIManager:close(self)
@ -109,6 +115,8 @@ function MultiConfirmBox:init()
},
{
text = self.choice2_text,
text_func = self.choice2_text_func,
enabled = self.choice2_enabled,
callback = function()
self.choice2_callback()
UIManager:close(self)

Loading…
Cancel
Save