[ReaderLink, Dispatcher] add toggle for tap-to-follow links (#13469)
Some checks failed
macos / macOS 13 x86-64 🔨15.2 🎯10.15 (push) Has been cancelled
macos / macOS 14 ARM64 🔨15.4 🎯11.0 (push) Has been cancelled

closes #13381
This commit is contained in:
David
2025-04-05 15:16:17 +01:00
committed by GitHub
parent 7e12cab461
commit 68f3b347a9
2 changed files with 15 additions and 12 deletions

View File

@@ -460,15 +460,15 @@ From the footnote popup, you can jump to the footnote location in the book by sw
local footnote_popup_settings_items = {}
table.insert(menu_items.follow_links.sub_item_table, 5, {
text = _("Footnote popup settings"),
enabled_func = function()
return isFootnoteLinkInPopupEnabled() and
(isTapToFollowLinksOn() or isSwipeToFollowNearestLinkEnabled())
end,
sub_item_table = footnote_popup_settings_items,
separator = true,
})
table.insert(footnote_popup_settings_items, {
text = _("Show more links as footnotes"),
enabled_func = function()
return isFootnoteLinkInPopupEnabled() and
(isTapToFollowLinksOn() or isSwipeToFollowNearestLinkEnabled())
end,
checked_func = isPreferFootnoteEnabled,
callback = function()
G_reader_settings:saveSetting("link_prefer_footnote",
@@ -479,10 +479,6 @@ From the footnote popup, you can jump to the footnote location in the book by sw
})
table.insert(footnote_popup_settings_items, {
text = _("Use book font as popup font"),
enabled_func = function()
return isFootnoteLinkInPopupEnabled() and
(isTapToFollowLinksOn() or isSwipeToFollowNearestLinkEnabled())
end,
checked_func = function()
return G_reader_settings:isTrue("footnote_popup_use_book_font")
end,
@@ -493,10 +489,6 @@ From the footnote popup, you can jump to the footnote location in the book by sw
})
table.insert(footnote_popup_settings_items, {
text = _("Set footnote popup font size"),
enabled_func = function()
return isFootnoteLinkInPopupEnabled() and
(isTapToFollowLinksOn() or isSwipeToFollowNearestLinkEnabled())
end,
keep_menu_open = true,
callback = function()
local spin_widget
@@ -703,6 +695,15 @@ function ReaderLink:onTap(_, ges)
end
end
function ReaderLink:onToggleTapLinks()
G_reader_settings:flipNilOrTrue("tap_to_follow_links")
local tap_links_status = isTapToFollowLinksOn() and _("on") or _("off")
UIManager:show(Notification:new{
text = T(_("Tap to follow links: %1"), tap_links_status),
})
return true
end
function ReaderLink:getCurrentLocation()
return self.ui.paging and self.ui.paging:getBookLocation()
or {xpointer = self.ui.rolling:getBookLocation()}

View File

@@ -172,6 +172,7 @@ local settingsList = {
follow_nearest_internal_link = {category="arg", event="GoToInternalPageLink", arg={pos={x=0,y=0}}, title=_("Follow nearest internal link"), reader=true},
select_prev_page_link = { category="none", event = "SelectPrevPageLink", title=_("Select previous link in current page"), reader=true, condition=not Device:isTouchDevice()},
select_next_page_link = { category="none", event = "SelectNextPageLink", title=_("Select next link in current page"), reader=true, condition=not Device:isTouchDevice()},
toggle_tap_links = {category="none", event="ToggleTapLinks", title=_("Toggle tap-to-follow links"), reader=true, condition=Device:isTouchDevice()},
add_location_to_history = {category="none", event="AddCurrentLocationToStack", arg=true, title=_("Add current location to history"), reader=true},
clear_location_history = {category="none", event="ClearLocationStack", arg=true, title=_("Clear location history"), reader=true, separator=true},
----
@@ -407,6 +408,7 @@ local dispatcher_menu_order = {
"follow_nearest_internal_link",
"select_prev_page_link",
"select_next_page_link",
"toggle_tap_links",
"add_location_to_history",
"clear_location_history",
----