Change random document to open any random document, long-press for any unopened document (#13160)
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

This commit is contained in:
Artjoms Rizihs
2025-04-23 16:07:13 +03:00
committed by GitHub
parent 969d47c0bd
commit 89f7f5ac2d

View File

@@ -705,7 +705,13 @@ function FileManager:tapPlus()
text = _("Open random document"),
callback = function()
UIManager:close(plus_dialog)
self:openRandomFile(self.file_chooser.path)
-- any random document
self:openRandomFile(self.file_chooser.path, false)
end,
hold_callback = function()
UIManager:close(plus_dialog)
-- only previously unopened
self:openRandomFile(self.file_chooser.path, true)
end
},
},
@@ -863,9 +869,13 @@ function FileManager:setHome(path)
return true
end
function FileManager:openRandomFile(dir)
local match_func = function(file) -- documents, not yet opened
return DocumentRegistry:hasProvider(file) and not BookList.hasBookBeenOpened(file)
function FileManager:openRandomFile(dir, unopened_only)
local match_func = function(file)
if unopened_only then
return DocumentRegistry:hasProvider(file) and not BookList.hasBookBeenOpened(file)
else
return DocumentRegistry:hasProvider(file)
end
end
local random_file = filemanagerutil.getRandomFile(dir, match_func)
if random_file then
@@ -879,7 +889,7 @@ function FileManager:openRandomFile(dir)
-- @translators Another file. This is a button on the open random file dialog. It presents a file with the choices Open/Another.
choice2_text = _("Another"),
choice2_callback = function()
self:openRandomFile(dir)
self:openRandomFile(dir, unopened_only)
end,
})
else