mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Фича недавних файлов
This commit is contained in:
parent
d6644783aa
commit
b98a4f39fd
@ -13,11 +13,12 @@ local MineOSInterface = require("MineOSInterface")
|
|||||||
|
|
||||||
local resourcesPath = MineOSCore.getCurrentScriptDirectory()
|
local resourcesPath = MineOSCore.getCurrentScriptDirectory()
|
||||||
local toolsPath = resourcesPath .. "Tools/"
|
local toolsPath = resourcesPath .. "Tools/"
|
||||||
local configPath = MineOSPaths.applicationData .. "Picture Edit/Config.cfg"
|
local configPath = MineOSPaths.applicationData .. "Picture Edit/Config2.cfg"
|
||||||
local savePath
|
local savePath
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
recentColors = {},
|
recentColors = {},
|
||||||
|
recentFiles = {},
|
||||||
transparencyBackground = 0xFFFFFF,
|
transparencyBackground = 0xFFFFFF,
|
||||||
transparencyForeground = 0xD2D2D2,
|
transparencyForeground = 0xD2D2D2,
|
||||||
}
|
}
|
||||||
@ -51,6 +52,17 @@ local function loadConfig()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function addRecentFile(path)
|
||||||
|
for i = 1, #config.recentFiles do
|
||||||
|
if config.recentFiles[i] == path then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(config.recentFiles, 1, path)
|
||||||
|
saveConfig()
|
||||||
|
end
|
||||||
|
|
||||||
loadConfig()
|
loadConfig()
|
||||||
|
|
||||||
local mainContainer = GUI.fullScreenContainer()
|
local mainContainer = GUI.fullScreenContainer()
|
||||||
@ -318,6 +330,7 @@ local function loadImage(path)
|
|||||||
local result, reason = image.load(path)
|
local result, reason = image.load(path)
|
||||||
if result then
|
if result then
|
||||||
savePath = path
|
savePath = path
|
||||||
|
addRecentFile(path)
|
||||||
mainContainer.image.data = result
|
mainContainer.image.data = result
|
||||||
mainContainer.image.reposition()
|
mainContainer.image.reposition()
|
||||||
else
|
else
|
||||||
@ -329,12 +342,12 @@ local function saveImage(path)
|
|||||||
local result, reason = image.save(path, mainContainer.image.data, 6)
|
local result, reason = image.save(path, mainContainer.image.data, 6)
|
||||||
if result then
|
if result then
|
||||||
savePath = path
|
savePath = path
|
||||||
|
addRecentFile(path)
|
||||||
else
|
else
|
||||||
GUI.error(reason)
|
GUI.error(reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
mainContainer.menu:addItem("PE", 0x00B6FF)
|
mainContainer.menu:addItem("PE", 0x00B6FF)
|
||||||
|
|
||||||
local fileItem = mainContainer.menu:addItem("File")
|
local fileItem = mainContainer.menu:addItem("File")
|
||||||
@ -358,6 +371,15 @@ fileItem.onTouch = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local subMenu = menu:addSubMenu("Open recent", #config.recentFiles == 0)
|
||||||
|
for i = 1, #config.recentFiles do
|
||||||
|
subMenu:addItem(string.limit(config.recentFiles[i], 32, "left")).onTouch = function()
|
||||||
|
loadImage(config.recentFiles[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
menu:addSeparator()
|
||||||
|
|
||||||
menu:addItem("Save", not savePath).onTouch = function()
|
menu:addItem("Save", not savePath).onTouch = function()
|
||||||
saveImage(savePath)
|
saveImage(savePath)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1482,8 +1482,8 @@ local function contextMenuAddSeparator(menu, ...)
|
|||||||
return dropDownMenuAddSeparator(menu, ...)
|
return dropDownMenuAddSeparator(menu, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function contextMenuAddSubMenu(menu, text)
|
local function contextMenuAddSubMenu(menu, text, disabled)
|
||||||
local item = menu:addItem(text, false, "►")
|
local item = menu:addItem(text, disabled, "►")
|
||||||
item.subMenu = GUI.contextMenu(1, 1)
|
item.subMenu = GUI.contextMenu(1, 1)
|
||||||
item.subMenu.colors = menu.colors
|
item.subMenu.colors = menu.colors
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user