mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
PathChooser: add left Home button (#8646)
This commit is contained in:
@@ -941,21 +941,7 @@ function FileManager:onRefresh()
|
||||
end
|
||||
|
||||
function FileManager:goHome()
|
||||
local home_dir = G_reader_settings:readSetting("home_dir")
|
||||
if not home_dir or lfs.attributes(home_dir, "mode") ~= "directory" then
|
||||
-- Try some sane defaults, depending on platform
|
||||
home_dir = Device.home_dir
|
||||
end
|
||||
if home_dir then
|
||||
-- Jump to the first page if we're already home
|
||||
if self.file_chooser.path and home_dir == self.file_chooser.path then
|
||||
self.file_chooser:onGotoPage(1)
|
||||
-- Also pick up new content, if any.
|
||||
self.file_chooser:refreshPath()
|
||||
else
|
||||
self.file_chooser:changeToPath(home_dir)
|
||||
end
|
||||
else
|
||||
if not self.file_chooser:goHome() then
|
||||
self:setHome()
|
||||
end
|
||||
return true
|
||||
|
||||
@@ -406,6 +406,25 @@ function FileChooser:changeToPath(path, focused_path)
|
||||
self:onPathChanged(path)
|
||||
end
|
||||
|
||||
function FileChooser:goHome()
|
||||
local home_dir = G_reader_settings:readSetting("home_dir")
|
||||
if not home_dir or lfs.attributes(home_dir, "mode") ~= "directory" then
|
||||
-- Try some sane defaults, depending on platform
|
||||
home_dir = Device.home_dir
|
||||
end
|
||||
if home_dir then
|
||||
-- Jump to the first page if we're already home
|
||||
if self.path and home_dir == self.path then
|
||||
self:onGotoPage(1)
|
||||
-- Also pick up new content, if any.
|
||||
self:refreshPath()
|
||||
else
|
||||
self:changeToPath(home_dir)
|
||||
end
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
function FileChooser:onFolderUp()
|
||||
if not (G_reader_settings:isTrue("lock_home_folder") and
|
||||
self.path == G_reader_settings:readSetting("home_dir")) then
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local BD = require("ui/bidi")
|
||||
local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
|
||||
local FileChooser = require("ui/widget/filechooser")
|
||||
local Font = require("ui/font")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local ffiutil = require("ffi/util")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
@@ -17,9 +16,6 @@ local PathChooser = FileChooser:extend{
|
||||
is_popout = false,
|
||||
covers_fullscreen = true, -- set it to false if you set is_popout = true
|
||||
is_borderless = true,
|
||||
-- smaller font to allow displaying our long titles
|
||||
tface = Font:getFace("smalltfont"),
|
||||
|
||||
select_directory = true, -- allow selecting directories
|
||||
select_file = true, -- allow selecting files
|
||||
show_files = true, -- show files, even if select_files=false
|
||||
@@ -45,6 +41,10 @@ function PathChooser:init()
|
||||
-- Let FileChooser display "Long-press to choose current folder"
|
||||
self.show_current_dir_for_hold = true
|
||||
end
|
||||
self.title_bar_left_icon = "home"
|
||||
self.onLeftButtonTap = function()
|
||||
self:goHome()
|
||||
end
|
||||
FileChooser.init(self)
|
||||
end
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ local InfoMessage = require("ui/widget/infomessage")
|
||||
local Menu = require("ui/widget/menu")
|
||||
local TextViewer = require("ui/widget/textviewer")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local filemanagerutil = require("apps/filemanager/filemanagerutil")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local util = require("util")
|
||||
@@ -113,7 +114,7 @@ function CoverMenu:updateItems(select_number)
|
||||
self:updatePageInfo(select_number)
|
||||
|
||||
if self.show_path then
|
||||
self.title_bar:setSubTitle(BD.directory(self.path))
|
||||
self.title_bar:setSubTitle(BD.directory(filemanagerutil.abbreviate(self.path)))
|
||||
end
|
||||
self.show_parent.dithered = self._has_cover_images
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
|
||||
Reference in New Issue
Block a user