mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Menu widget: rotation handler (#12573)
This commit is contained in:
@@ -11,7 +11,6 @@ local ReadCollection = require("readcollection")
|
||||
local SortWidget = require("ui/widget/sortwidget")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local Screen = require("device").screen
|
||||
local filemanagerutil = require("apps/filemanager/filemanagerutil")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
@@ -73,8 +72,8 @@ function FileManagerCollection:onShowColl(collection_name)
|
||||
onLeftButtonTap = function() self:showCollDialog() end,
|
||||
onMenuChoice = self.onMenuChoice,
|
||||
onMenuHold = self.onMenuHold,
|
||||
onSetRotationMode = self.MenuSetRotationModeHandler,
|
||||
_manager = self,
|
||||
_recreate_func = function() self:onShowColl(collection_name) end,
|
||||
collection_name = collection_name,
|
||||
}
|
||||
self.coll_menu.close_callback = function()
|
||||
@@ -101,6 +100,10 @@ function FileManagerCollection:updateItemTable(show_last_item)
|
||||
self.coll_menu:switchItemTable(title, item_table, item_number)
|
||||
end
|
||||
|
||||
function FileManagerCollection:onSetDimensions(dimen)
|
||||
self.dimen = dimen
|
||||
end
|
||||
|
||||
function FileManagerCollection:onMenuChoice(item)
|
||||
if self.ui.document then
|
||||
if self.ui.document.file ~= item.file then
|
||||
@@ -274,21 +277,6 @@ function FileManagerCollection:sortCollection()
|
||||
UIManager:show(sort_widget)
|
||||
end
|
||||
|
||||
function FileManagerCollection:MenuSetRotationModeHandler(rotation)
|
||||
if rotation ~= nil and rotation ~= Screen:getRotationMode() then
|
||||
UIManager:close(self._manager.coll_menu)
|
||||
if self._manager.ui.view and self._manager.ui.view.onSetRotationMode then
|
||||
self._manager.ui.view:onSetRotationMode(rotation)
|
||||
elseif self._manager.ui.onSetRotationMode then
|
||||
self._manager.ui:onSetRotationMode(rotation)
|
||||
else
|
||||
Screen:setRotationMode(rotation)
|
||||
end
|
||||
self._manager:onShowColl()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function FileManagerCollection:onBookMetadataChanged()
|
||||
if self.coll_menu then
|
||||
self.coll_menu:updateItems()
|
||||
@@ -316,8 +304,8 @@ function FileManagerCollection:onShowCollList(file_or_files, caller_callback, no
|
||||
onLeftButtonTap = function() self:showCollListDialog(caller_callback, no_dialog) end,
|
||||
onMenuChoice = self.onCollListChoice,
|
||||
onMenuHold = self.onCollListHold,
|
||||
onSetRotationMode = self.MenuSetRotationModeHandler,
|
||||
_manager = self,
|
||||
_recreate_func = function() self:onShowCollList(file_or_files, caller_callback, no_dialog) end,
|
||||
}
|
||||
self.coll_list.close_callback = function(force_close)
|
||||
if force_close or self.selected_colections == nil then
|
||||
|
||||
@@ -9,7 +9,6 @@ local Menu = require("ui/widget/menu")
|
||||
local ReadCollection = require("readcollection")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local Screen = require("device").screen
|
||||
local Utf8Proc = require("ffi/utf8proc")
|
||||
local filemanagerutil = require("apps/filemanager/filemanagerutil")
|
||||
local util = require("util")
|
||||
@@ -230,23 +229,6 @@ function FileManagerHistory:onMenuHold(item)
|
||||
return true
|
||||
end
|
||||
|
||||
-- Can't *actually* name it onSetRotationMode, or it also fires in FM itself ;).
|
||||
function FileManagerHistory:MenuSetRotationModeHandler(rotation)
|
||||
if rotation ~= nil and rotation ~= Screen:getRotationMode() then
|
||||
UIManager:close(self._manager.hist_menu)
|
||||
-- Also re-layout ReaderView or FileManager itself
|
||||
if self._manager.ui.view and self._manager.ui.view.onSetRotationMode then
|
||||
self._manager.ui.view:onSetRotationMode(rotation)
|
||||
elseif self._manager.ui.onSetRotationMode then
|
||||
self._manager.ui:onSetRotationMode(rotation)
|
||||
else
|
||||
Screen:setRotationMode(rotation)
|
||||
end
|
||||
self._manager:onShowHist()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function FileManagerHistory:onShowHist(search_info)
|
||||
self.hist_menu = Menu:new{
|
||||
ui = self.ui,
|
||||
@@ -261,8 +243,8 @@ function FileManagerHistory:onShowHist(search_info)
|
||||
onLeftButtonTap = function() self:showHistDialog() end,
|
||||
onMenuChoice = self.onMenuChoice,
|
||||
onMenuHold = self.onMenuHold,
|
||||
onSetRotationMode = self.MenuSetRotationModeHandler,
|
||||
_manager = self,
|
||||
_recreate_func = function() self:onShowHist(search_info) end,
|
||||
}
|
||||
|
||||
if search_info then
|
||||
|
||||
@@ -3,7 +3,6 @@ local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local Menu = require("ui/widget/menu")
|
||||
local Screen = require("device").screen
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
@@ -191,21 +190,6 @@ function FileManagerShortcuts:onSetDimensions(dimen)
|
||||
self.dimen = dimen
|
||||
end
|
||||
|
||||
function FileManagerShortcuts:MenuSetRotationModeHandler(rotation)
|
||||
if rotation ~= nil and rotation ~= Screen:getRotationMode() then
|
||||
UIManager:close(self._manager.shortcuts_menu)
|
||||
if self._manager.ui.view and self._manager.ui.view.onSetRotationMode then
|
||||
self._manager.ui.view:onSetRotationMode(rotation)
|
||||
elseif self._manager.ui.onSetRotationMode then
|
||||
self._manager.ui:onSetRotationMode(rotation)
|
||||
else
|
||||
Screen:setRotationMode(rotation)
|
||||
end
|
||||
self._manager:onShowFolderShortcutsDialog()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function FileManagerShortcuts:onShowFolderShortcutsDialog(select_callback)
|
||||
self.shortcuts_menu = Menu:new{
|
||||
title = self.title,
|
||||
@@ -217,8 +201,8 @@ function FileManagerShortcuts:onShowFolderShortcutsDialog(select_callback)
|
||||
onLeftButtonTap = function() self:addShortcut() end,
|
||||
onMenuChoice = self.onMenuChoice,
|
||||
onMenuHold = not select_callback and self.onMenuHold or nil,
|
||||
onSetRotationMode = self.MenuSetRotationModeHandler,
|
||||
_manager = self,
|
||||
_recreate_func = function() self:onShowFolderShortcutsDialog(select_callback) end,
|
||||
}
|
||||
self.shortcuts_menu.close_callback = function()
|
||||
UIManager:close(self.shortcuts_menu)
|
||||
|
||||
@@ -1272,6 +1272,20 @@ function Menu:onScreenResize(dimen)
|
||||
return false
|
||||
end
|
||||
|
||||
function Menu:onSetRotationMode(rotation)
|
||||
if self._recreate_func and rotation ~= nil and rotation ~= Screen:getRotationMode() then
|
||||
UIManager:close(self)
|
||||
-- Also re-layout ReaderView or FileManager itself
|
||||
if self._manager.ui.view then
|
||||
self._manager.ui.view:onSetRotationMode(rotation)
|
||||
else
|
||||
self._manager.ui:onSetRotationMode(rotation)
|
||||
end
|
||||
self._recreate_func()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function Menu:onSelectByShortCut(_, keyevent)
|
||||
for k,v in ipairs(self.item_shortcuts) do
|
||||
if k > self.perpage then
|
||||
|
||||
Reference in New Issue
Block a user