mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
refactored collections UI + added several convinience actions...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
7a66aa6c07
commit
45eadeff76
@ -2230,6 +2230,19 @@ module.AutoCollections = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
// NOTE: if n > 1 and <n args are given then the given args will get
|
||||||
|
// passed to func with an appended title...
|
||||||
|
var mixedModeCollectionAction = function(func, n){
|
||||||
|
return widgets.uiDialog(function(){
|
||||||
|
var args = [].slice.call(arguments)
|
||||||
|
// check if minimum number of arguments is reached...
|
||||||
|
return args.length < (n || 1) ?
|
||||||
|
//this.browseCollections(func)
|
||||||
|
this.browseCollections(function(title){
|
||||||
|
return func.call(this, ...args.concat([title])) })
|
||||||
|
: func.apply(this, args) }) }
|
||||||
|
|
||||||
|
|
||||||
// XXX show collections in image metadata... (???)
|
// XXX show collections in image metadata... (???)
|
||||||
// XXX might be nice to indicate if a collection is loaded -- has .data???
|
// XXX might be nice to indicate if a collection is loaded -- has .data???
|
||||||
// XXX might be nice to add collection previews to the collection list...
|
// XXX might be nice to add collection previews to the collection list...
|
||||||
@ -2539,39 +2552,57 @@ var UICollectionActions = actions.Actions({
|
|||||||
//
|
//
|
||||||
// XXX should we warn the user when overwriting???
|
// XXX should we warn the user when overwriting???
|
||||||
saveAsCollection: ['Collections/$Save as collection...',
|
saveAsCollection: ['Collections/$Save as collection...',
|
||||||
widgets.uiDialog(function(){
|
mixedModeCollectionAction(function(title){
|
||||||
return this.browseCollections(function(title){
|
this.saveCollection(title, 'current')
|
||||||
this.saveCollection(title, 'current')
|
// XXX should we be doing this manually here or in .saveCollection(..)
|
||||||
// XXX should we be doing this manually here or in .saveCollection(..)
|
title == this.collection
|
||||||
title == this.collection
|
&& this.loadCollection('!')
|
||||||
&& this.loadCollection('!')
|
})],
|
||||||
}) })],
|
|
||||||
addToCollection: ['Collections|Image/Add $image to collection...',
|
addToCollection: ['Collections|Image/Add $image to collection...',
|
||||||
widgets.uiDialog(function(gids){
|
mixedModeCollectionAction(function(gids, title){
|
||||||
return this.browseCollections(function(title){
|
if(title == null){
|
||||||
this.collect(gids || 'current', title) }) })],
|
title = gids
|
||||||
|
gids = null
|
||||||
|
}
|
||||||
|
this.collect(gids || 'current', title) }, 2)],
|
||||||
addRibbonToCollection: ['Collections|Ribbon/Add $ribbon to collection...',
|
addRibbonToCollection: ['Collections|Ribbon/Add $ribbon to collection...',
|
||||||
widgets.uiDialog(function(){ return this.addToCollection('ribbon') })],
|
widgets.uiDialog(function(){ return this.addToCollection('ribbon') })],
|
||||||
addLoadedToCollection: ['Collections/$Add loaded images to collection...',
|
addLoadedToCollection: ['Collections/$Add loaded images to collection...',
|
||||||
widgets.uiDialog(function(){ return this.addToCollection('loaded') })],
|
widgets.uiDialog(function(){ return this.addToCollection('loaded') })],
|
||||||
joinToCollection: ['Collections/$Merge view to collection...',
|
joinToCollection: ['Collections/$Merge view to collection...',
|
||||||
widgets.uiDialog(function(){
|
mixedModeCollectionAction(function(title){ this.joinCollect(title) })],
|
||||||
return this.browseCollections(function(title){ this.joinCollect(title) }) })],
|
|
||||||
|
|
||||||
// XXX should this be here or in marks???
|
cropOutImagesInCollection: ['Collections/Crop $out images in collection...',
|
||||||
|
mixedModeCollectionAction(function(title){
|
||||||
|
var that = this
|
||||||
|
this.ensureCollection(title)
|
||||||
|
.then(function(collection){
|
||||||
|
var to_remove = collection.data.getImages('all')
|
||||||
|
var images = that.data.getImages('loaded')
|
||||||
|
.filter(function(gid){ return to_remove.indexOf(gid) < 0 })
|
||||||
|
that.crop(images, false)
|
||||||
|
})
|
||||||
|
})],
|
||||||
|
|
||||||
|
// XXX should these be here or in marks-specific feature???
|
||||||
|
markImagesInCollection: ['Collections|Mark/$Mark images in collection...',
|
||||||
|
{browseMode: function(){
|
||||||
|
return (!this.collections
|
||||||
|
|| Object.keys(this.collections).length == 0)
|
||||||
|
&& 'disabled' }},
|
||||||
|
mixedModeCollectionAction(function(title){
|
||||||
|
var that = this
|
||||||
|
this.ensureCollection(title)
|
||||||
|
.then(function(collection){
|
||||||
|
var images = collection.data.getImages('all')
|
||||||
|
|
||||||
|
that.toggleMark(images, 'on')
|
||||||
|
})
|
||||||
|
})],
|
||||||
addMarkedToCollection: ['Collections|Mark/Add marked to $collection...',
|
addMarkedToCollection: ['Collections|Mark/Add marked to $collection...',
|
||||||
{browseMode: function(){
|
{browseMode: function(){
|
||||||
return this.marked.length == 0 && 'disabled' }},
|
return this.marked.length == 0 && 'disabled' }},
|
||||||
widgets.uiDialog(function(){
|
mixedModeCollectionAction(function(title){ this.collectMarked(title) })],
|
||||||
var that = this
|
|
||||||
return this.browseCollections(function(title){ this.collectMarked(title) })
|
|
||||||
.run(function(){
|
|
||||||
var title = that.config['collection-last-used']
|
|
||||||
title
|
|
||||||
&& this.select(`"${title}"`) })
|
|
||||||
.open(function(_, title){
|
|
||||||
that.config['collection-last-used'] = title })
|
|
||||||
})],
|
|
||||||
|
|
||||||
// XXX should this be in Collections/ ???
|
// XXX should this be in Collections/ ???
|
||||||
editDefaultCollections: ['Interface|Collections/Edit default collections...',
|
editDefaultCollections: ['Interface|Collections/Edit default collections...',
|
||||||
|
|||||||
@ -402,7 +402,7 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
ctrl_A: 'toggleMark!: "ribbon" "on" -- Mark all images in ribbon',
|
ctrl_A: 'toggleMark!: "ribbon" "on" -- Mark all images in ribbon',
|
||||||
ctrl_shift_A: 'toggleMarkBlock!',
|
ctrl_shift_A: 'toggleMarkBlock!',
|
||||||
ctrl_D: 'toggleMark!: "ribbon" "off" -- Unmark all images in ribbon',
|
ctrl_D: 'toggleMark!: "ribbon" "off" -- Unmark all images in ribbon',
|
||||||
ctrl_I: 'toggleMark!: "ribbon" -- Invert marks in ribbon',
|
ctrl_I: 'invertRibbonMarks',
|
||||||
',': 'prevMarked',
|
',': 'prevMarked',
|
||||||
'.': 'nextMarked',
|
'.': 'nextMarked',
|
||||||
alt_M: 'browseActions: "/Mark/" -- Mark menu...',
|
alt_M: 'browseActions: "/Mark/" -- Mark menu...',
|
||||||
|
|||||||
@ -342,6 +342,14 @@ var ImageMarkEditActions = actions.Actions({
|
|||||||
return this.toggleMark(block, state ? 'off' : 'on')
|
return this.toggleMark(block, state ? 'off' : 'on')
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// shorthands...
|
||||||
|
invertRibbonMarks: ['Mark/$Invert marks in ribbon',
|
||||||
|
{browseMode: 'cropMarked'},
|
||||||
|
'toggleMark: "ribbon"'],
|
||||||
|
invertLoadedMarks: ['Mark/$Invert marks',
|
||||||
|
{browseMode: 'cropMarked'},
|
||||||
|
'toggleMark: "loaded"'],
|
||||||
|
|
||||||
unmarkAll: ['Mark/$Unmark all',
|
unmarkAll: ['Mark/$Unmark all',
|
||||||
{browseMode: 'cropMarked'},
|
{browseMode: 'cropMarked'},
|
||||||
function(){ this.toggleMark(this.marked) }],
|
function(){ this.toggleMark(this.marked) }],
|
||||||
|
|||||||
@ -1306,6 +1306,7 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
'Collections/-70:---',
|
'Collections/-70:---',
|
||||||
'Collections/-70:.*remove.*',
|
'Collections/-70:.*remove.*',
|
||||||
'$Mark',
|
'$Mark',
|
||||||
|
'Mark/-75:.*collection...',
|
||||||
'Mark/-80:---',
|
'Mark/-80:---',
|
||||||
'Mark/-80:.*remove.*',
|
'Mark/-80:.*remove.*',
|
||||||
'Mark/-90:.*unmark.*',
|
'Mark/-90:.*unmark.*',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user