-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExportCollectionSetGUI.lua
More file actions
100 lines (89 loc) · 3.72 KB
/
Copy pathExportCollectionSetGUI.lua
File metadata and controls
100 lines (89 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
local LrFunctionContext = import 'LrFunctionContext'
local LrBinding = import 'LrBinding'
local LrDialogs = import 'LrDialogs'
local LrView = import 'LrView'
local LrApplication = import 'LrApplication'
local LrTasks = import 'LrTasks'
local ExportCollectionSet = require 'ExportCollectionSet'
local function showExportDialog()
LrFunctionContext.callWithContext( "showExportDialog", function( context )
local f = LrView.osFactory()
local properties = LrBinding.makePropertyTable(context)
LrTasks.startAsyncTask(
function()
local catalog = LrApplication.activeCatalog()
local collectionSets = catalog:getChildCollectionSets()
local items = {}
for _, collectionSet in ipairs(collectionSets) do
table.insert(items, {title = collectionSet:getName(), value = collectionSet})
end
properties.collectionSet = items[1].value
local contents = f:column {
bind_to_object = properties,
spacing = f:control_spacing(),
f:static_text {
title = "Pressing OK will export the selected collection set and all their contents to the selected path.",
fill_horizontal = 1,
},
f:static_text {
title = "Remember that, depending on the number of nested collections, this might take a while:",
fill_horizontal = 1,
},
f:popup_menu {
value = LrView.bind('collectionSet'),
items = items,
},
f:push_button {
title = "Select Folder",
action = function()
local result = LrDialogs.runOpenPanel({canChooseDirectories = true, allowsMultipleSelection = false, canChooseFiles = false})
if result then
properties.rootPath = result[1]
end
end,
},
f:static_text {
title = LrView.bind('rootPath'),
fill_horizontal = 1 -- This makes the text line extend horizontally. Otherwise, it's barely visible
},
f:static_text {
title = "A export settings file is optional, but not providing it will use Lightroom's defaults",
fill_horizontal = 1,
},
f:push_button {
title = "Select Export Settings",
action = function()
local result = LrDialogs.runOpenPanel({canChooseFiles = true, allowsMultipleSelection = false, canChooseDirectories = false, prompt = "Select ExportSettings.lrtemplate"})
if result then
local filePath = result[1]
if filePath:sub(-11) ~= ".lrtemplate" then
LrDialogs.message("Error", "Please select a .lrtemplate file.", "critical")
else
properties.exportSettingsPath = filePath
end
end
end,
},
f:static_text {
title = LrView.bind('exportSettingsPath'),
fill_horizontal = 1,
},
}
local result = LrDialogs.presentModalDialog({
title = "Select and export one Collection Set",
contents = contents,
})
if result == 'ok' then
if properties.rootPath then
LrTasks.startAsyncTask(function()
ExportCollectionSet.exportCollectionSet(properties.collectionSet, properties.rootPath, properties.exportSettingsPath)
end)
else
LrDialogs.message("Error", "Please select a folder before proceeding.", "critical")
end
end
end
)
end)
end
showExportDialog()