diff --git a/Libraries/System.lua b/Libraries/System.lua index 2c755f52..34942a2b 100755 --- a/Libraries/System.lua +++ b/Libraries/System.lua @@ -469,6 +469,17 @@ function system.updateIconProperties() computer.pushSignal("system", "updateFileList") end +local function getSelectedIcons (iconField) + local selectedIcons = {} + for i = 2, #iconField.children do + if iconField.children[i].selected then + table.insert(selectedIcons, iconField.children[i]) + end + end + + return selectedIcons +end + local function drawSelection(x, y, width, height, color, transparency) screen.drawText(x, y, color, string.rep("▄", width), transparency) screen.drawText(x, y + height - 1, color, string.rep("▀", width), transparency) @@ -866,12 +877,7 @@ local function gridIconFieldIconEventHandler(workspace, object, e1, e2, e3, e4, if e5 == 0 then iconDeselectAndSelect(object) else - local selectedIcons = {} - for i = 2, #object.parent.children do - if object.parent.children[i].selected then - table.insert(selectedIcons, object.parent.children[i]) - end - end + local selectedIcons = getSelectedIcons (object.parent) -- Right click on multiple selected icons if not object.selected then @@ -1505,10 +1511,9 @@ local function gridIconFieldBackgroundObjectEventHandler(workspace, object, e1, if e4 == 28 then -- Если при нажатии энтера была выделенна ровно одна иконка, она попытается открыться local selectedIcon - for i = 2, #iconField.children do - if object.parent.children[i].selected then - if not selectedIcon then + if iconField.children[i].selected then + if selectedIcon ~= nil then -- Больше одной иконки выбрано return end @@ -1518,8 +1523,81 @@ local function gridIconFieldBackgroundObjectEventHandler(workspace, object, e1, end if selectedIcon then - selectedIcon:launch() - workspace:draw() + selectedIcon:launch () + workspace:draw () + end + end + + -- Delete + if e4 == 211 then + -- При нажатии делита, выделенные иконки кидаются в корзину + + selectedIcons = getSelectedIcons (iconField) + if #selectedIcons < 1 then + return + end + + -- Если шифт нажат, удаляем перманентно, спросив пидора о его уверенности + if keyboard.isKeyDown (42) then + local container = GUI.addBackgroundContainer (workspace, true, true, localization.areYouSure .. " " .. tostring (#selectedIcons) .. " " .. localization.filesWillBeRemovedPermanently) + local buttonYes = container.layout:addChild (GUI.button (1, 1, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, localization.yes)) + local buttonNo = container.layout:addChild (GUI.button (1, 3, 30, 1, 0xE1E1E1, 0x2D2D2D, 0xA5A5A5, 0x2D2D2D, localization.no )) + + buttonYes.onTouch = function () + for i = 1, #selectedIcons do + result, reason = filesystem.remove (selectedIcons[i].path) + if not result then + GUI.alert (localization.fileDeletingFailure .. "'" .. selectedIcons[i].path .. "': " .. reason) + end + + -- Отвыделяем иконку, шобы она случайно не открылась + selectedIcons[i].selected = false + end + + computer.pushSignal ("system", "updateFileList") + + container:remove () + workspace:draw () + end + + buttonNo.onTouch = function () + container:remove () + workspace:draw () + end + + container.panel.onTouch = buttonNo.onTouch + + container.eventHandler = function (workspace, object, e1, e2, e3, e4, e5, ...) + if e1 == "key_down" then + if e4 == 28 then + buttonYes.onTouch () + elseif e4 == 15 then + buttonNo.onTouch () + end + end + end + + workspace:draw () + + else + -- Шифт никто не нажал, кидаем в корзинку + for i = 1, #selectedIcons do + if filesystem.path (selectedIcons[i].path) == paths.user.trash then + filesystem.remove (selectedIcons[i].path) + else + local newName = paths.user.trash .. selectedIcons[i].name + local clearName = filesystem.hideExtension(selectedIcons[i].name) + local repeats = 1 + while filesystem.exists(newName) do + newName, repeats = paths.user.trash .. clearName .. string.rep("-copy", repeats) .. (selectedIcons[i].extension or ""), repeats + 1 + end + filesystem.rename(selectedIcons[i].path, newName) + end + + selectedIcons[i].selected = false + end + + computer.pushSignal("system", "updateFileList") end end end @@ -1637,14 +1715,7 @@ function system.listIconField(x, y, width, height, path, ...) if e1 == "touch" then if e5 == 1 then - local selectedIcons = {} - for i = 1, #cell.parent.children - 1, columnCount do - if cell.parent.children[i].selected then - table.insert(selectedIcons, cell.parent.children[i]) - end - end - - iconOnRightClick(selectedIcons, icon, e1, e2, e3, e4, e5, ...) + iconOnRightClick(getSelectedIcons (cell.parent), icon, e1, e2, e3, e4, e5, ...) end elseif e1 == "double_touch" then iconOnDoubleClick(icon) diff --git a/Localizations/Arabic.lang b/Localizations/Arabic.lang index e7a2a1e6..9b5c58d9 100644 --- a/Localizations/Arabic.lang +++ b/Localizations/Arabic.lang @@ -56,6 +56,7 @@ unknown = "غير معروف", calculatingSize = "الحساب ... ", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "الخصائص", newFolderFromChosen = "مجلد جديد من اختيار", create = "جديد", diff --git a/Localizations/Belarusian.lang b/Localizations/Belarusian.lang index bf823a99..01dde34e 100644 --- a/Localizations/Belarusian.lang +++ b/Localizations/Belarusian.lang @@ -57,6 +57,7 @@ unknown = "Невядома", calculatingSize = "ідзе падлік…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Уласцівасці", newFolderFromChosen = "Новая тэчка з вылучанага", diff --git a/Localizations/Bengali.lang b/Localizations/Bengali.lang index 4957a7c1..d82dba54 100644 --- a/Localizations/Bengali.lang +++ b/Localizations/Bengali.lang @@ -55,6 +55,7 @@ unknown = "অজানা", calculatingSize = "গণনা করা হচ্ছে ...", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "বৈশিষ্ট্য", newFolderFromChosen = "নির্বাচিত", create = "নতুন", diff --git a/Localizations/Bulgarian.lang b/Localizations/Bulgarian.lang index eca15bb3..ed071d6e 100644 --- a/Localizations/Bulgarian.lang +++ b/Localizations/Bulgarian.lang @@ -63,6 +63,7 @@ unknown = "Неизвестно", calculatingSize = "изчисляване…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Свойства", newFolderFromChosen = "Нова папка от избраните", diff --git a/Localizations/Chinese.lang b/Localizations/Chinese.lang index 5a0ba511..6fac32e4 100644 --- a/Localizations/Chinese.lang +++ b/Localizations/Chinese.lang @@ -57,6 +57,7 @@ unknown = "未知", calculatingSize = "计算中...", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "属性", newFolderFromChosen = "在所选文件夹里新建一个文件夹", diff --git a/Localizations/Dutch.lang b/Localizations/Dutch.lang index 2178eeb1..e2d89b46 100644 --- a/Localizations/Dutch.lang +++ b/Localizations/Dutch.lang @@ -57,6 +57,7 @@ unknown = "Onbekent", calculatingSize = "Berekenen…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Instellingen", newFolderFromChosen = "Nieuwe map van gekozen", diff --git a/Localizations/English.lang b/Localizations/English.lang index 75ef1a14..d0505144 100755 --- a/Localizations/English.lang +++ b/Localizations/English.lang @@ -57,6 +57,7 @@ unknown = "Unknown", calculatingSize = "calculating…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Properties", newFolderFromChosen = "New folder from chosen", diff --git a/Localizations/Finnish.lang b/Localizations/Finnish.lang index e11309e7..cee8de9a 100644 --- a/Localizations/Finnish.lang +++ b/Localizations/Finnish.lang @@ -57,6 +57,7 @@ unknown = "Tuntematon", calculatingSize = "lasketaan…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Ominaisuudet", newFolderFromChosen = "Uusi kansio valinnasta", diff --git a/Localizations/French.lang b/Localizations/French.lang index bf331f7b..4f215311 100644 --- a/Localizations/French.lang +++ b/Localizations/French.lang @@ -57,6 +57,7 @@ unknown = "Inconnu", calculatingSize = "calcule en cours ...", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Propriétés", newFolderFromChosen = "Nouveau dossier choisi", diff --git a/Localizations/German.lang b/Localizations/German.lang index c45632ee..eb910c73 100755 --- a/Localizations/German.lang +++ b/Localizations/German.lang @@ -57,6 +57,7 @@ unknown = "Unbekannt", calculatingSize = "Berechne Größe...", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Eigenschaften", newFolderFromChosen = "Neuen Ordner wählen.", diff --git a/Localizations/Hindi.lang b/Localizations/Hindi.lang index ea7c2652..29429edf 100644 --- a/Localizations/Hindi.lang +++ b/Localizations/Hindi.lang @@ -56,6 +56,7 @@ unknown = "अज्ञात", calculatingSize = "गणना…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "गुण", newFolderFromChosen = "से नया फ़ोल्डर", create = "नया", diff --git a/Localizations/Italian.lang b/Localizations/Italian.lang index 949a06e9..26759c33 100755 --- a/Localizations/Italian.lang +++ b/Localizations/Italian.lang @@ -57,6 +57,7 @@ unknown = "Sconosciuto", calculatingSize = "calcolo…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Proprieta", newFolderFromChosen = "Nuova cartella selezionata", diff --git a/Localizations/Japanese.lang b/Localizations/Japanese.lang index 2ce1c8ec..d06a1648 100644 --- a/Localizations/Japanese.lang +++ b/Localizations/Japanese.lang @@ -57,6 +57,7 @@ unknown = "不明", calculatingSize = "計算中…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "プロパティ", newFolderFromChosen = "選択したフォルダから新しいフォルダを作成", diff --git a/Localizations/Korean.lang b/Localizations/Korean.lang index 3dc016a6..425a40cd 100644 --- a/Localizations/Korean.lang +++ b/Localizations/Korean.lang @@ -57,6 +57,7 @@ unknown = "알 수 없음", calculatingSize = "계산중…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "속성", newFolderFromChosen = "선택된 파일이 포함된 새 폴더 만들기", diff --git a/Localizations/Lolcat.lang b/Localizations/Lolcat.lang index c3738310..5d93b64f 100644 --- a/Localizations/Lolcat.lang +++ b/Localizations/Lolcat.lang @@ -56,6 +56,7 @@ unknown = "Unknown", calculatingSize = "calculating…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "propertiez", newFolderFromChosen = "nu foldr frum chosen", create = "nu", diff --git a/Localizations/Polish.lang b/Localizations/Polish.lang index 65c1e502..da8b9d4e 100644 --- a/Localizations/Polish.lang +++ b/Localizations/Polish.lang @@ -57,6 +57,7 @@ unknown = "Nieznany", calculatingSize = "obliczanie…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Ustawienia", newFolderFromChosen = "Wybierz Nowy Folder z", diff --git a/Localizations/Portuguese.lang b/Localizations/Portuguese.lang index 3aae73cf..7043c0d9 100644 --- a/Localizations/Portuguese.lang +++ b/Localizations/Portuguese.lang @@ -56,6 +56,7 @@ unknown = "Desconhecido", calculatingSize = "calculando…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Propriedades", newFolderFromChosen = "Nova pasta escolhida", create = "Novo", diff --git a/Localizations/Russian.lang b/Localizations/Russian.lang index 5c858847..2ca7fa1f 100755 --- a/Localizations/Russian.lang +++ b/Localizations/Russian.lang @@ -57,6 +57,7 @@ unknown = "Неизвестно", calculatingSize = "идет подсчет…", filesWillBeRemovedPermanently = "файл(ов) будет удалено безвозвратно", + fileDeletingFailure = "Ошибка при удалении файла", properties = "Свойства", newFolderFromChosen = "Новая папка из выбранного", diff --git a/Localizations/Slovak.lang b/Localizations/Slovak.lang index 50847fbe..7451cf01 100644 --- a/Localizations/Slovak.lang +++ b/Localizations/Slovak.lang @@ -57,6 +57,7 @@ unknown = "Neznáme", calculatingSize = "počítanie…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Vlastnosti", newFolderFromChosen = "Nový priečinok z vybraného", diff --git a/Localizations/Spanish.lang b/Localizations/Spanish.lang index 332d295d..9153fde2 100644 --- a/Localizations/Spanish.lang +++ b/Localizations/Spanish.lang @@ -57,6 +57,7 @@ unknown = "Desconocido", calculatingSize = "calculando…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Propiedades", newFolderFromChosen = "Nueva carpeta desde Directorio", diff --git a/Localizations/Ukrainian.lang b/Localizations/Ukrainian.lang index 5f240f94..f69aafc9 100644 --- a/Localizations/Ukrainian.lang +++ b/Localizations/Ukrainian.lang @@ -57,6 +57,7 @@ unknown = "Невідомо", calculatingSize = "йде підрахунок…", filesWillBeRemovedPermanently = "file(s) will be removed permanently", + fileDeletingFailure = "Failed to delete file", properties = "Властивості", newFolderFromChosen = "Нова папка з обраного",