ConfigDialog: remove uneeded support for muliple events

Fixes reflow support for dispatcher
reviewable/pr8166/r1
yparitcher 3 years ago
parent eb949d6ebf
commit 36fd668093

@ -1172,13 +1172,17 @@ function ReaderPaging:onGotoPrevChapter()
return true return true
end end
function ReaderPaging:onToggleReflow() function ReaderPaging:onReflowUpdated()
self.view.document.configurable.text_wrap = bit.bxor(self.view.document.configurable.text_wrap, 1)
self.ui:handleEvent(Event:new("RedrawCurrentPage")) self.ui:handleEvent(Event:new("RedrawCurrentPage"))
self.ui:handleEvent(Event:new("RestoreZoomMode")) self.ui:handleEvent(Event:new("RestoreZoomMode"))
self.ui:handleEvent(Event:new("InitScrollPageStates")) self.ui:handleEvent(Event:new("InitScrollPageStates"))
end end
function ReaderPaging:onToggleReflow()
self.view.document.configurable.text_wrap = bit.bxor(self.view.document.configurable.text_wrap, 1)
self:onReflowUpdated()
end
-- Duplicated in ReaderRolling -- Duplicated in ReaderRolling
function ReaderPaging:onToggleReadingOrder() function ReaderPaging:onToggleReadingOrder()
self.inverse_reading_order = not self.inverse_reading_order self.inverse_reading_order = not self.inverse_reading_order

@ -447,17 +447,7 @@ The first option ("auto") tries to automatically align reflowed text as it is in
toggle = {_("off"), _("on")}, toggle = {_("off"), _("on")},
values = {0, 1}, values = {0, 1},
default_value = DKOPTREADER_CONFIG_TEXT_WRAP, default_value = DKOPTREADER_CONFIG_TEXT_WRAP,
events = { event = "ReflowUpdated",
{
event = "RedrawCurrentPage",
},
{
event = "RestoreZoomMode",
},
{
event = "InitScrollPageStates",
},
},
name_text_hold_callback = optionsutil.showValues, name_text_hold_callback = optionsutil.showValues,
help_text = _([[Reflow mode extracts text and images from the original document, possibly discarding some formatting, and reflows it on the screen for easier reading. help_text = _([[Reflow mode extracts text and images from the original document, possibly discarding some formatting, and reflows it on the screen for easier reading.
Some of the other settings are only available when reflow mode is enabled.]]), Some of the other settings are only available when reflow mode is enabled.]]),

@ -90,7 +90,7 @@ function OptionTextItem:onTapSelect()
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_ICON) Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_ICON)
self.config:onConfigChoose(self.values, self.name, self.config:onConfigChoose(self.values, self.name,
self.event, self.args, self.event, self.args,
self.events, self.current_item, self.hide_on_apply) self.current_item, self.hide_on_apply)
UIManager:setDirty(self.config, function() UIManager:setDirty(self.config, function()
return "fast", self[1].dimen return "fast", self[1].dimen
@ -169,7 +169,7 @@ function OptionIconItem:onTapSelect()
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_ICON) Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_ICON)
self.config:onConfigChoose(self.values, self.name, self.config:onConfigChoose(self.values, self.name,
self.event, self.args, self.event, self.args,
self.events, self.current_item, self.hide_on_apply) self.current_item, self.hide_on_apply)
UIManager:setDirty(self.config, function() UIManager:setDirty(self.config, function()
return "fast", self[1].dimen return "fast", self[1].dimen
@ -569,7 +569,6 @@ function ConfigOption:init()
values = self.options[c].values, values = self.options[c].values,
args = self.options[c].args, args = self.options[c].args,
event = self.options[c].event, event = self.options[c].event,
events = self.options[c].events,
hide_on_apply = self.options[c].hide_on_apply, hide_on_apply = self.options[c].hide_on_apply,
config = self.config, config = self.config,
enabled = enabled, enabled = enabled,
@ -614,7 +613,7 @@ function ConfigOption:init()
if arg == "-" or arg == "+" then if arg == "-" or arg == "+" then
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_FINE) Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_FINE)
self.config:onConfigFineTuneChoose(self.options[c].values, self.options[c].name, self.config:onConfigFineTuneChoose(self.options[c].values, self.options[c].name,
self.options[c].event, self.options[c].args, self.options[c].events, arg, self.options[c].hide_on_apply, self.options[c].event, self.options[c].args, arg, self.options[c].hide_on_apply,
self.options[c].fine_tune_param) self.options[c].fine_tune_param)
elseif arg == "" then elseif arg == "" then
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_MORE) Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_MORE)
@ -623,7 +622,7 @@ function ConfigOption:init()
else else
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_PROGRESS) Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_PROGRESS)
self.config:onConfigChoose(self.options[c].values, self.options[c].name, self.config:onConfigChoose(self.options[c].values, self.options[c].name,
self.options[c].event, self.options[c].args, self.options[c].events, arg, self.options[c].hide_on_apply) self.options[c].event, self.options[c].args, arg, self.options[c].hide_on_apply)
end end
UIManager:setDirty(self.config, function() UIManager:setDirty(self.config, function()
@ -968,15 +967,7 @@ function ConfigDialog:onConfigEvent(option_event, option_arg, when_applied_callb
return true return true
end end
function ConfigDialog:onConfigEvents(option_events, arg_index) function ConfigDialog:onConfigChoose(values, name, event, args, position, hide_on_apply)
for i=1, #option_events do
option_events[i].args = option_events[i].args or {}
self.ui:handleEvent(Event:new(option_events[i].event, option_events[i].args[arg_index]))
end
return true
end
function ConfigDialog:onConfigChoose(values, name, event, args, events, position, hide_on_apply)
UIManager:tickAfterNext(function() UIManager:tickAfterNext(function()
-- Repainting may be delayed depending on options -- Repainting may be delayed depending on options
local refresh_dialog_func = function() local refresh_dialog_func = function()
@ -1003,9 +994,6 @@ function ConfigDialog:onConfigChoose(values, name, event, args, events, position
args = args or {} args = args or {}
self:onConfigEvent(event, args[position], when_applied_callback) self:onConfigEvent(event, args[position], when_applied_callback)
end end
if events then
self:onConfigEvents(events, position)
end
-- Even if each toggle refreshes itself when toggled, we still -- Even if each toggle refreshes itself when toggled, we still
-- need to update and repaint the whole config panel, as other -- need to update and repaint the whole config panel, as other
-- toggles may have their state (enabled/disabled) modified -- toggles may have their state (enabled/disabled) modified
@ -1018,7 +1006,7 @@ function ConfigDialog:onConfigChoose(values, name, event, args, events, position
end end
-- Tweaked variant used with the fine_tune variant of buttonprogress (direction can only be "-" or "+") -- Tweaked variant used with the fine_tune variant of buttonprogress (direction can only be "-" or "+")
function ConfigDialog:onConfigFineTuneChoose(values, name, event, args, events, direction, hide_on_apply, params) function ConfigDialog:onConfigFineTuneChoose(values, name, event, args, direction, hide_on_apply, params)
UIManager:tickAfterNext(function() UIManager:tickAfterNext(function()
-- Repainting may be delayed depending on options -- Repainting may be delayed depending on options
local refresh_dialog_func = function() local refresh_dialog_func = function()
@ -1094,9 +1082,6 @@ function ConfigDialog:onConfigFineTuneChoose(values, name, event, args, events,
end end
self:onConfigEvent(event, arg, when_applied_callback) self:onConfigEvent(event, arg, when_applied_callback)
end end
if events then
self:onConfigEvents(events, direction)
end
-- Even if each toggle refreshes itself when toggled, we still -- Even if each toggle refreshes itself when toggled, we still
-- need to update and repaint the whole config panel, as other -- need to update and repaint the whole config panel, as other
-- toggles may have their state (enabled/disabled) modified -- toggles may have their state (enabled/disabled) modified

@ -210,9 +210,6 @@ function ToggleSwitch:onTapSelect(arg, gev)
self.args = self.args or {} self.args = self.args or {}
self.config:onConfigEvent(self.event, self.args[self.position]) self.config:onConfigEvent(self.event, self.args[self.position])
end end
if self.events then
self.config:onConfigEvents(self.events, self.position)
end
--]] --]]
if self.callback then if self.callback then
self.callback(self.position) self.callback(self.position)
@ -224,7 +221,7 @@ function ToggleSwitch:onTapSelect(arg, gev)
Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_TOGGLE) Notification:setNotifySource(Notification.SOURCE_BOTTOM_MENU_TOGGLE)
end end
self.config:onConfigChoose(self.values, self.name, self.config:onConfigChoose(self.values, self.name,
self.event, self.args, self.events, self.position, self.hide_on_apply) self.event, self.args, self.position, self.hide_on_apply)
UIManager:setDirty(self.config, function() UIManager:setDirty(self.config, function()
return "ui", self.dimen return "ui", self.dimen

Loading…
Cancel
Save