From db60ba48b72cfc40697d85bf28197b3dcddb6ed3 Mon Sep 17 00:00:00 2001 From: hius07 <62179190+hius07@users.noreply.github.com> Date: Tue, 29 Jun 2021 11:22:03 +0300 Subject: [PATCH] OPDS catalog, Cloud storage: hold return arrow to go to top (#7845) --- frontend/apps/cloudstorage/cloudstorage.lua | 13 +++++++++++++ frontend/ui/widget/menu.lua | 3 +++ plugins/opds.koplugin/opdsbrowser.lua | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/frontend/apps/cloudstorage/cloudstorage.lua b/frontend/apps/cloudstorage/cloudstorage.lua index e635bb081..ae96d583e 100644 --- a/frontend/apps/cloudstorage/cloudstorage.lua +++ b/frontend/apps/cloudstorage/cloudstorage.lua @@ -712,4 +712,17 @@ function CloudStorage:onReturn() return true end +function CloudStorage:onHoldReturn() + if #self.paths > 1 then + local path = self.paths[1] + if path then + for i = #self.paths, 2, -1 do + table.remove(self.paths) + end + self:openCloudServer(path.url) + end + end + return true +end + return CloudStorage diff --git a/frontend/ui/widget/menu.lua b/frontend/ui/widget/menu.lua index e6338e32e..845ee2342 100644 --- a/frontend/ui/widget/menu.lua +++ b/frontend/ui/widget/menu.lua @@ -884,6 +884,9 @@ function Menu:init() callback = function() if self.onReturn then self:onReturn() end end, + hold_callback = function() + if self.onHoldReturn then self:onHoldReturn() end + end, bordersize = 0, show_parent = self.show_parent, readonly = self.return_arrow_propagation, diff --git a/plugins/opds.koplugin/opdsbrowser.lua b/plugins/opds.koplugin/opdsbrowser.lua index efe7743de..e53bd1ff9 100644 --- a/plugins/opds.koplugin/opdsbrowser.lua +++ b/plugins/opds.koplugin/opdsbrowser.lua @@ -884,6 +884,20 @@ function OPDSBrowser:onReturn() return true end +function OPDSBrowser:onHoldReturn() + if #self.paths > 1 then + local path = self.paths[1] + if path then + for i = #self.paths, 2, -1 do + table.remove(self.paths) + end + self.catalog_title = path.title + self:updateCatalog(path.url, path.username, path.password) + end + end + return true +end + function OPDSBrowser:onNext() -- self.page_num comes from menu.lua local page_num = self.page_num @@ -898,7 +912,6 @@ function OPDSBrowser:onNext() break end end - return true end