File manager: some broken actions for parent folder (#7475)

For parent folder (..):
disabled `Copy`, `Cut`, `Delete`, `Rename`.
enabled `Paste`, `Set as HOME folder`.
pull/7480/head
hius07 3 years ago committed by GitHub
parent de543b3484
commit 91262f9647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -227,10 +227,14 @@ function FileManager:setupLayout()
local fileManager = self
function file_chooser:onFileHold(file) -- luacheck: ignore
local is_file = lfs.attributes(file, "mode") == "file"
local is_folder = lfs.attributes(file, "mode") == "directory"
local is_not_parent_folder = BaseUtil.basename(file) ~= ".."
local buttons = {
{
{
text = C_("File", "Copy"),
enabled = is_not_parent_folder,
callback = function()
copyFile(file)
UIManager:close(self.file_dialog)
@ -264,6 +268,7 @@ function FileManager:setupLayout()
{
{
text = _("Cut"),
enabled = is_not_parent_folder,
callback = function()
cutFile(file)
UIManager:close(self.file_dialog)
@ -271,6 +276,7 @@ function FileManager:setupLayout()
},
{
text = _("Delete"),
enabled = is_not_parent_folder,
callback = function()
UIManager:show(ConfirmBox:new{
text = _("Are you sure that you want to delete this file?\n") .. BD.filepath(file) .. ("\n") .. _("If you delete a file, it is permanently lost."),
@ -286,6 +292,7 @@ function FileManager:setupLayout()
},
{
text = _("Rename"),
enabled = is_not_parent_folder,
callback = function()
UIManager:close(self.file_dialog)
fileManager.rename_dialog = InputDialog:new{
@ -320,7 +327,7 @@ function FileManager:setupLayout()
},
}
if lfs.attributes(file, "mode") == "file" and Device:canExecuteScript(file) then
if is_file and Device:canExecuteScript(file) then
-- NOTE: We populate the empty separator, in order not to mess with the button reordering code in CoverMenu
table.insert(buttons[3],
{
@ -361,7 +368,7 @@ function FileManager:setupLayout()
)
end
if lfs.attributes(file, "mode") == "file" then
if is_file then
table.insert(buttons, {
{
text = _("Open with…"),
@ -422,7 +429,7 @@ function FileManager:setupLayout()
})
end
end
if lfs.attributes(file, "mode") == "directory" then
if is_folder then
local realpath = BaseUtil.realpath(file)
table.insert(buttons, {
{
@ -436,7 +443,7 @@ function FileManager:setupLayout()
end
local title
if lfs.attributes(file, "mode") == "directory" then
if is_folder then
title = BD.directory(file:match("([^/]+)$"))
else
title = BD.filename(file:match("([^/]+)$"))
@ -888,7 +895,7 @@ function FileManager:pasteHere(file)
if mode == "file" then
text = T(_("The file %1 already exists. Do you want to overwrite it?"), BD.filename(basename))
else
text = T(_("The directory %1 already exists. Do you want to overwrite it?"), BD.directory(basename))
text = T(_("The folder %1 already exists. Overwrite folder?"), BD.directory(basename))
end
UIManager:show(ConfirmBox:new {

Loading…
Cancel
Save