diff --git a/Applications/Picture View.app/Extensions/.pic/Context menu.lua b/Applications/Picture View.app/Extensions/.pic/Context menu.lua new file mode 100644 index 00000000..d1ebe992 --- /dev/null +++ b/Applications/Picture View.app/Extensions/.pic/Context menu.lua @@ -0,0 +1,21 @@ + +local filesystem = require("Filesystem") +local GUI = require("GUI") +local paths = require("Paths") +local system = require("System") + +local workspace, icon, menu = select(1, ...), select(2, ...), select(3, ...) +local localization = system.getSystemLocalization() + +menu:addItem(localization.setAsWallpaper).onTouch = function() + local userSettings = system.getUserSettings() + + userSettings.interfaceWallpaperPath = icon.path + userSettings.interfaceWallpaperEnabled = true + system.updateWallpaper() + workspace:draw() + + system.saveUserSettings() +end + +system.addUploadToPastebinMenuItem(menu, icon.path) diff --git a/Applications/Picture View.app/Extensions/.pic/Icon.pic b/Applications/Picture View.app/Extensions/.pic/Icon.pic new file mode 100644 index 00000000..269a6401 Binary files /dev/null and b/Applications/Picture View.app/Extensions/.pic/Icon.pic differ diff --git a/Applications/Viewer.app/Icon.pic b/Applications/Picture View.app/Icon.pic similarity index 100% rename from Applications/Viewer.app/Icon.pic rename to Applications/Picture View.app/Icon.pic diff --git a/Applications/Viewer.app/Icons/arrowLeft.pic b/Applications/Picture View.app/Icons/ArrowLeft.pic similarity index 100% rename from Applications/Viewer.app/Icons/arrowLeft.pic rename to Applications/Picture View.app/Icons/ArrowLeft.pic diff --git a/Applications/Viewer.app/Icons/arrowRight.pic b/Applications/Picture View.app/Icons/ArrowRight.pic similarity index 100% rename from Applications/Viewer.app/Icons/arrowRight.pic rename to Applications/Picture View.app/Icons/ArrowRight.pic diff --git a/Applications/Viewer.app/Icons/play.pic b/Applications/Picture View.app/Icons/Play.pic similarity index 100% rename from Applications/Viewer.app/Icons/play.pic rename to Applications/Picture View.app/Icons/Play.pic diff --git a/Applications/Viewer.app/Icons/setWallpaper.pic b/Applications/Picture View.app/Icons/SetWallpaper.pic similarity index 100% rename from Applications/Viewer.app/Icons/setWallpaper.pic rename to Applications/Picture View.app/Icons/SetWallpaper.pic diff --git a/Applications/Viewer.app/Localizations/English.lang b/Applications/Picture View.app/Localizations/English.lang similarity index 100% rename from Applications/Viewer.app/Localizations/English.lang rename to Applications/Picture View.app/Localizations/English.lang diff --git a/Applications/Viewer.app/Localizations/Russian.lang b/Applications/Picture View.app/Localizations/Russian.lang similarity index 100% rename from Applications/Viewer.app/Localizations/Russian.lang rename to Applications/Picture View.app/Localizations/Russian.lang diff --git a/Applications/Viewer.app/Main.lua b/Applications/Picture View.app/Main.lua similarity index 81% rename from Applications/Viewer.app/Main.lua rename to Applications/Picture View.app/Main.lua index 9ae68659..6c266dec 100644 --- a/Applications/Viewer.app/Main.lua +++ b/Applications/Picture View.app/Main.lua @@ -11,14 +11,14 @@ local currentNum = 1 local workspace, window, menu = system.addWindow(GUI.titledWindow(1, 1, 70, 30, 'Viewer', true)) -local locale = system.getCurrentScriptLocalization() +local localization = system.getCurrentScriptLocalization() local iconsPath = fs.path(system.getCurrentScript())..'Icons/' -local arrowLeftPic = image.load(iconsPath .. "arrowLeft.pic") -local arrowRightPic = image.load(iconsPath .. "arrowRight.pic") -local playPic = image.load(iconsPath .. "play.pic") -local setWallpaperPic = image.load(iconsPath.."setWallpaper.pic") +local arrowLeftPic = image.load(iconsPath .. "ArrowLeft.pic") +local arrowRightPic = image.load(iconsPath .. "ArrowRight.pic") +local playPic = image.load(iconsPath .. "Play.pic") +local setWallpaperPic = image.load(iconsPath.."SetWallpaper.pic") local layout = window:addChild(GUI.layout(1, 2, window.width, window.height, 1, 1)) @@ -36,11 +36,20 @@ local function scanDir() end local function loadImg() - if imageObj then imageObj:remove() end + if imageObj then + imageObj:remove() + end + local newImg, ifErr = image.load(dirFiles[currentNum]) - if not newImg then GUI.alert(ifErr) window:remove() return end + + if not newImg then + GUI.alert(ifErr) + window:remove() + return + end + imageObj = layout:addChild(GUI.image(1, 1, newImg)) - window.titleLabel.text = 'Viewer - '..text.limit(dirFiles[currentNum], 30, "center") + window.titleLabel.text = 'Viewer - ' .. text.limit(dirFiles[currentNum], 30, "center") workspace:draw() end @@ -55,18 +64,18 @@ end local play = panelLay:addChild(GUI.image(2, 1, playPic)) play.eventHandler = function(_, _, typ) if typ == 'touch' then - local container = GUI.addBackgroundContainer(workspace, true, true, locale.slideShow) + local container = GUI.addBackgroundContainer(workspace, true, true, localization.slideShow) container.panel.eventHandler = nil container.layout:setSpacing(1, 1, 2) - local delay = container.layout:addChild(GUI.slider(1, 1, 50, 0x66DB80, 0x0, 0xFFFFFF, 0xFFFFFF, 3, 30, 0, true, locale.delay, locale.seconds)) + local delay = container.layout:addChild(GUI.slider(1, 1, 50, 0x66DB80, 0x0, 0xFFFFFF, 0xFFFFFF, 3, 30, 0, true, localization.delay, localization.seconds)) delay.roundValues = true - local onFull = container.layout:addChild(GUI.switchAndLabel(1, 1, 27, 8, 0x66DB80, 0x1D1D1D, 0xEEEEEE, 0xFFFFFF, locale.fullScreen..":", false)) + local onFull = container.layout:addChild(GUI.switchAndLabel(1, 1, 27, 8, 0x66DB80, 0x1D1D1D, 0xEEEEEE, 0xFFFFFF, localization.fullScreen..":", false)) local buttonsLay = container.layout:addChild(GUI.layout(1, 1, 30, 7, 1, 1)) - buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.start)).onTouch = function() + buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.start)).onTouch = function() local slDelay = delay.value if onFull.switch.state then local w, h = screen.getResolution() @@ -90,7 +99,9 @@ play.eventHandler = function(_, _, typ) else panel.hidden = true panelLay.hidden = true + local strTim = system.getTime() + layout.eventHandler = function(_, _, typ) if typ == 'touch' or typ == 'key_down' then layout.eventHandler = nil @@ -107,30 +118,36 @@ play.eventHandler = function(_, _, typ) container:remove() end - buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.cancel)).onTouch = function() + buttonsLay:addChild(GUI.button(1, 1, 30, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.cancel)).onTouch = function() container:remove() end end end + panelLay:setPosition(2, 1, play) +-- Arrow right local arrowRight = panelLay:addChild(GUI.image(1, 1, arrowRightPic)) + arrowRight.eventHandler = function(_, _, typ) if typ == 'touch' then currentNum = currentNum == #dirFiles and 1 or currentNum+1 loadImg() end end + panelLay:setPosition(3, 1, arrowRight) +-- Set wallpaper local setWallpaper = panelLay:addChild(GUI.image(1, 1, setWallpaperPic)) + setWallpaper.eventHandler = function(_, _, typ) if typ == 'touch' then - local container = GUI.addBackgroundContainer(workspace, true, true, locale.setWallpaper) + local container = GUI.addBackgroundContainer(workspace, true, true, localization.setWallpaper) container.panel.eventHandler = nil local buttLay = container.layout:addChild(GUI.layout(1, 1, 24, 6, 2, 1)) - buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.yes)).onTouch = function() + buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.yes)).onTouch = function() local sets = system.getUserSettings() sets.interfaceWallpaperPath = dirFiles[currentNum] system.saveUserSettings() @@ -139,24 +156,24 @@ setWallpaper.eventHandler = function(_, _, typ) container:remove() end - local cancel = buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, locale.no)) + local cancel = buttLay:addChild(GUI.button(1, 1, 10, 3, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, localization.no)) cancel.onTouch = function() container:remove() end buttLay:setPosition(2, 1, cancel) end end + panelLay:setPosition(4, 1, setWallpaper) -local hsPanel = menu:addItem(locale.hidePanel) +local hsPanel = menu:addItem(localization.hidePanel) hsPanel.onTouch = function() - hsPanel.text = panel.hidden and locale.hidePanel or locale.showPanel + hsPanel.text = panel.hidden and localization.hidePanel or localization.showPanel panel.hidden = not panel.hidden panelLay.hidden = not panelLay.hidden end -local flScreen = menu:addItem(locale.fullScreen) -flScreen.onTouch = function() +menu:addItem(localization.fullScreen).onTouch = function() local w, h = screen.getResolution() local flScr = workspace:addChild(GUI.window(1, 1, w, h)) flScr:addChild(GUI.panel(1, 1, w, h, 0xFFFFFF)) @@ -179,14 +196,17 @@ end if (options.o or options.open) and args[1] then currentDir = fs.path(args[1]) + scanDir() + for i=1, #dirFiles do if dirFiles[i] == args[1] then currentNum = i loadImg() break end end else scanDir() + if #dirFiles == 0 then - layout:addChild(GUI.text(1, 1, 0x4B4B4B, locale.noPictures)) + layout:addChild(GUI.text(1, 1, 0x4B4B4B, localization.noPictures)) panel.hidden = true panelLay.hidden = true hsPanel.disabled = true diff --git a/Installer/Files.cfg b/Installer/Files.cfg index 4425d39a..1a2da751 100644 --- a/Installer/Files.cfg +++ b/Installer/Files.cfg @@ -134,6 +134,16 @@ "Applications/Picture Edit.app/Localizations/English.lang", "Applications/Picture Edit.app/Localizations/Russian.lang", "Applications/Picture Edit.app/Extensions/.pic/Icon.pic", + -- Picture View + { path="Applications/Picture View.app/Main.lua" }, + "Applications/Picture View.app/Icon.pic", + "Applications/Picture View.app/Icons/ArrowLeft.pic", + "Applications/Picture View.app/Icons/ArrowRight.pic", + "Applications/Picture View.app/Icons/Play.pic", + "Applications/Picture View.app/Icons/SetWallpaper.pic", + "Applications/Picture View.app/Localizations/English.lang", + "Applications/Picture View.app/Localizations/Russian.lang", + "Applications/Picture View.app/Extensions/.pic/Icon.pic", -- Finder { path="Applications/Finder.app/Main.lua", id=175 }, "Applications/Finder.app/Icon.pic",