mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 02:59:20 +01:00
Added "Empty trash" clarification for RMB menu to prevent rootmaster's hysteria
This commit is contained in:
parent
b84d8f084e
commit
4bc3ab5139
@ -609,41 +609,70 @@ local function iconDeselectAndSelect(icon)
|
|||||||
if not keyboard.isKeyDown(29) and not keyboard.isKeyDown(219) then
|
if not keyboard.isKeyDown(29) and not keyboard.isKeyDown(219) then
|
||||||
icon.parent:clearSelection()
|
icon.parent:clearSelection()
|
||||||
end
|
end
|
||||||
icon.selected = true
|
|
||||||
|
|
||||||
workspace:draw()
|
icon.selected = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function moveToTrash(path)
|
local function moveToTrash(pathsToMove)
|
||||||
local ext = filesystem.extension(path)
|
local path, extension
|
||||||
local name = filesystem.name(path)
|
|
||||||
local dir = filesystem.path(path)
|
for i = 1, #pathsToMove do
|
||||||
if dir == paths.user.trash or ext == ".lnk" then
|
path = pathsToMove[i]
|
||||||
|
|
||||||
|
extension = filesystem.extension(path)
|
||||||
|
|
||||||
|
-- If file is in trash or it's a shortcut - we can safely delete it
|
||||||
|
if filesystem.path(path) == paths.user.trash or extension == ".lnk" then
|
||||||
filesystem.remove(path)
|
filesystem.remove(path)
|
||||||
else
|
else
|
||||||
local name = filesystem.name(path)
|
local name = filesystem.name(path)
|
||||||
local clearName = filesystem.hideExtension(name)
|
local newPath = paths.user.trash .. name
|
||||||
local newPath = paths.user.trash .. name
|
local counter = 1
|
||||||
local repeats = 1
|
|
||||||
|
|
||||||
while filesystem.exists(newPath) do
|
while filesystem.exists(newPath) do
|
||||||
newPath, repeats = paths.user.trash .. clearName .. string.rep("-copy", repeats) .. (ext or ""), repeats + 1
|
newPath, counter = paths.user.trash .. filesystem.hideExtension(name) .. string.rep("-copy", counter) .. (extension or ""), counter + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
filesystem.rename(path, newPath)
|
||||||
end
|
end
|
||||||
|
|
||||||
filesystem.rename(path, newPath)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
computer.pushSignal("system", "updateFileList")
|
computer.pushSignal("system", "updateFileList")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function emptyTrash()
|
||||||
|
local container = GUI.addBackgroundContainer(workspace, true, true, localization.areYouSure)
|
||||||
|
|
||||||
|
container.layout:addChild(GUI.button(1, 1, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, "OK")).onTouch = function()
|
||||||
|
local list = filesystem.list(paths.user.trash)
|
||||||
|
|
||||||
|
for i = 1, #list do
|
||||||
|
filesystem.remove(paths.user.trash .. list[i])
|
||||||
|
end
|
||||||
|
|
||||||
|
container:remove()
|
||||||
|
|
||||||
|
computer.pushSignal("system", "updateFileList")
|
||||||
|
end
|
||||||
|
|
||||||
|
container.panel.onTouch = function()
|
||||||
|
container:remove()
|
||||||
|
workspace:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
|
end
|
||||||
|
|
||||||
local function moveSelectedIconsToTrash(selectedIcons)
|
local function moveSelectedIconsToTrash(selectedIcons)
|
||||||
local icon
|
local pathsToMove = {}
|
||||||
|
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
icon = selectedIcons[i]
|
table.insert(pathsToMove, selectedIcons[i].path)
|
||||||
moveToTrash(icon.path)
|
|
||||||
icon.selected = false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
moveToTrash(pathsToMove)
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
||||||
@ -905,14 +934,22 @@ local function iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.delete).onTouch = function()
|
|
||||||
moveSelectedIconsToTrash(selectedIcons)
|
if icon.path == paths.user.trash then
|
||||||
|
contextMenu:addItem(localization.emptyTrash).onTouch = emptyTrash
|
||||||
|
else
|
||||||
|
contextMenu:addItem(localization.delete).onTouch = function()
|
||||||
|
moveSelectedIconsToTrash(selectedIcons)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if icon.isShortcut then
|
if icon.isShortcut then
|
||||||
contextMenu:addItem(localization.deleteWithSource).onTouch = function()
|
contextMenu:addItem(localization.deleteWithSource).onTouch = function()
|
||||||
moveToTrash(icon.shortcutPath)
|
moveToTrash({
|
||||||
moveToTrash(icon.path)
|
icon.shortcutPath,
|
||||||
|
icon.path
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -945,6 +982,8 @@ local function iconFieldIconEventHandler(workspace, icon, e1, e2, e3, e4, e5, ..
|
|||||||
|
|
||||||
if e5 == 0 then
|
if e5 == 0 then
|
||||||
iconDeselectAndSelect(icon)
|
iconDeselectAndSelect(icon)
|
||||||
|
|
||||||
|
workspace:draw()
|
||||||
else
|
else
|
||||||
-- Если иконка выбрана - похуй, все ок
|
-- Если иконка выбрана - похуй, все ок
|
||||||
if icon.selected then
|
if icon.selected then
|
||||||
@ -2603,28 +2642,7 @@ function system.updateDesktop()
|
|||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(localization.emptyTrash).onTouch = function()
|
contextMenu:addItem(localization.emptyTrash).onTouch = emptyTrash
|
||||||
local container = GUI.addBackgroundContainer(workspace, true, true, localization.areYouSure)
|
|
||||||
|
|
||||||
container.layout:addChild(GUI.button(1, 1, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, "OK")).onTouch = function()
|
|
||||||
local list = filesystem.list(paths.user.trash)
|
|
||||||
|
|
||||||
for i = 1, #list do
|
|
||||||
filesystem.remove(paths.user.trash .. list[i])
|
|
||||||
end
|
|
||||||
|
|
||||||
container:remove()
|
|
||||||
|
|
||||||
computer.pushSignal("system", "updateFileList")
|
|
||||||
end
|
|
||||||
|
|
||||||
container.panel.onTouch = function()
|
|
||||||
container:remove()
|
|
||||||
workspace:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
workspace:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
workspace:draw()
|
workspace:draw()
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user