mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
added image copy...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f14cb36aa0
commit
a948275934
@ -333,6 +333,29 @@ var ElectronHostActions = actions.Actions({
|
|||||||
splash.destroy()
|
splash.destroy()
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
// XXX should this support resizing???
|
||||||
|
copy: ['Image|Edit/Copy image',
|
||||||
|
core.doc`Copy image
|
||||||
|
|
||||||
|
Copy current image (original ref)...
|
||||||
|
.copy()
|
||||||
|
|
||||||
|
Copy best matching preview of current image...
|
||||||
|
.copy(size)
|
||||||
|
|
||||||
|
`,
|
||||||
|
function(size){
|
||||||
|
var url = this.images.getBestPreview(this.current, size, true).url
|
||||||
|
electron.clipboard.write({
|
||||||
|
title: this.images.getImageFileName(),
|
||||||
|
text: url,
|
||||||
|
image: electron.nativeImage.createFromPath(url),
|
||||||
|
}) }],
|
||||||
|
paste: ['- Image|Edit/Paste image',
|
||||||
|
function(){
|
||||||
|
// XXX
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
|
|
||||||
var ElectronHost =
|
var ElectronHost =
|
||||||
@ -400,6 +423,46 @@ var BrowserHostActions = actions.Actions({
|
|||||||
that.dom[0].style.visibility = '' }, 150)
|
that.dom[0].style.visibility = '' }, 150)
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
|
||||||
|
|
||||||
|
// XXX these do not work from file://
|
||||||
|
// XXX should this support resizing???
|
||||||
|
copy: ['Image|Edit/Copy image',
|
||||||
|
core.doc`Copy image
|
||||||
|
|
||||||
|
Copy current image (original ref)...
|
||||||
|
.copy()
|
||||||
|
|
||||||
|
Copy best matching preview of current image...
|
||||||
|
.copy(size)
|
||||||
|
|
||||||
|
NOTE: this must be called from within an event handler...
|
||||||
|
NOTE: this will not work with file:// paths...
|
||||||
|
`,
|
||||||
|
function(size){
|
||||||
|
var img = new Image;
|
||||||
|
var c = document.createElement("canvas");
|
||||||
|
var ctx = c.getContext("2d");
|
||||||
|
|
||||||
|
img.onload = function(){
|
||||||
|
c.width = this.naturalWidth
|
||||||
|
c.height = this.naturalHeight
|
||||||
|
ctx.drawImage(this, 0, 0)
|
||||||
|
c.toBlob(function(blob){
|
||||||
|
// copy...
|
||||||
|
// XXX would be nice to add a path/title here...
|
||||||
|
navigator.clipboard.write([
|
||||||
|
new ClipboardItem({
|
||||||
|
[blob.type]: blob,
|
||||||
|
}) ]) },
|
||||||
|
"image/png") }
|
||||||
|
img.crossOrigin = ''
|
||||||
|
img.src = this.images.getBestPreview(this.current, size, true).url
|
||||||
|
}],
|
||||||
|
paste: ['- Image|Edit/Paste image',
|
||||||
|
function(){
|
||||||
|
// XXX
|
||||||
|
}],
|
||||||
})
|
})
|
||||||
|
|
||||||
// NOTE: keep this defined last as a fallback...
|
// NOTE: keep this defined last as a fallback...
|
||||||
@ -626,8 +689,7 @@ module.WindowedAppControl = core.ImageGridFeatures.Feature({
|
|||||||
this.size = [w, h]
|
this.size = [w, h]
|
||||||
|
|
||||||
cfg.devtools
|
cfg.devtools
|
||||||
&& this.showDevTools()
|
&& this.showDevTools() }
|
||||||
}
|
|
||||||
|
|
||||||
// restore actual window state...
|
// restore actual window state...
|
||||||
this.restoreWindowGeometry()
|
this.restoreWindowGeometry()
|
||||||
|
|||||||
@ -3132,6 +3132,9 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
|
|
||||||
// Export presets...
|
// Export presets...
|
||||||
//
|
//
|
||||||
|
// XXX would be nice to be able to "export" (copy) single images as well...
|
||||||
|
// ...and it would be logical to have separate presets for single
|
||||||
|
// images and lists... (???)
|
||||||
// XXX UI:
|
// XXX UI:
|
||||||
// - element format:
|
// - element format:
|
||||||
// TITLE
|
// TITLE
|
||||||
|
|||||||
@ -434,9 +434,13 @@ module.GLOBAL_KEYBOARD = {
|
|||||||
// do the default copy thing...
|
// do the default copy thing...
|
||||||
// NOTE: this stops the default: handler from getting the ctrl:
|
// NOTE: this stops the default: handler from getting the ctrl:
|
||||||
// key case...
|
// key case...
|
||||||
ctrl_C: 'NEXT',
|
//ctrl_C: 'NEXT',
|
||||||
ctrl_V: 'NEXT',
|
ctrl_V: 'NEXT',
|
||||||
|
|
||||||
|
// copy/paste image...
|
||||||
|
ctrl_C: 'copy',
|
||||||
|
//ctrl_V: 'paste',
|
||||||
|
|
||||||
|
|
||||||
// sort...
|
// sort...
|
||||||
//shift_S: 'sortImages: "Date" -- Sort images by date',
|
//shift_S: 'sortImages: "Date" -- Sort images by date',
|
||||||
|
|||||||
@ -43,7 +43,7 @@ core.ImageGridFeatures.Feature('imagegrid-ui-minimal', [
|
|||||||
'keyboard',
|
'keyboard',
|
||||||
'ui-cursor',
|
'ui-cursor',
|
||||||
'ui-control',
|
'ui-control',
|
||||||
'ui-copy-image',
|
//'ui-copy-image',
|
||||||
'ui-drag-n-drop',
|
'ui-drag-n-drop',
|
||||||
|
|
||||||
// XXX use one...
|
// XXX use one...
|
||||||
|
|||||||
@ -2199,6 +2199,8 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
'99:$Edit',
|
'99:$Edit',
|
||||||
'Edit/90:Undo',
|
'Edit/90:Undo',
|
||||||
'Edit/90:Redo',
|
'Edit/90:Redo',
|
||||||
|
'Edit/85:.*copy.*',
|
||||||
|
'Edit/85:.*paste.*',
|
||||||
'Edit/85:.*base.*',
|
'Edit/85:.*base.*',
|
||||||
'Edit/80:.*sort.*',
|
'Edit/80:.*sort.*',
|
||||||
'Edit/80:.*order.*',
|
'Edit/80:.*order.*',
|
||||||
@ -2212,6 +2214,8 @@ var BrowseActionsActions = actions.Actions({
|
|||||||
'Navigate/80:.*screen.*',
|
'Navigate/80:.*screen.*',
|
||||||
'Navigate/70:.*ribbon.*',
|
'Navigate/70:.*ribbon.*',
|
||||||
'$Image',
|
'$Image',
|
||||||
|
'Image/98:.*copy.*',
|
||||||
|
'Image/98:.*paste.*',
|
||||||
'Image/98:.*editor.*',
|
'Image/98:.*editor.*',
|
||||||
'Image/98:.*folder.*',
|
'Image/98:.*folder.*',
|
||||||
'Image/95:.*metadata.*',
|
'Image/95:.*metadata.*',
|
||||||
|
|||||||
@ -1149,6 +1149,36 @@ module.Cursor = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************************/
|
||||||
|
// Copy...
|
||||||
|
|
||||||
|
// XXX implement internal copy/paste...
|
||||||
|
var CopyImiage =
|
||||||
|
module.CopyImiage = core.ImageGridFeatures.Feature({
|
||||||
|
title: '',
|
||||||
|
doc: '',
|
||||||
|
|
||||||
|
tag: 'ui-copy-image',
|
||||||
|
depends: [
|
||||||
|
'ui'
|
||||||
|
],
|
||||||
|
|
||||||
|
actions: actions.Actions({
|
||||||
|
// XXX mark copied image(s)...
|
||||||
|
copy: ['- Image|Edit/Copy image',
|
||||||
|
function(size){
|
||||||
|
// XXX
|
||||||
|
}],
|
||||||
|
// XXX if pasted image(s) is the one(s) marked by copy, do a shift action...
|
||||||
|
paste: ['- Image|Edit/Paste image',
|
||||||
|
function(){
|
||||||
|
// XXX
|
||||||
|
}],
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
// Touch/Control...
|
// Touch/Control...
|
||||||
//
|
//
|
||||||
|
|||||||
@ -554,8 +554,7 @@ module.ImagesPrototype = {
|
|||||||
: '')
|
: '')
|
||||||
+ url,
|
+ url,
|
||||||
size: preview_size,
|
size: preview_size,
|
||||||
}
|
} },
|
||||||
},
|
|
||||||
|
|
||||||
// Get image filename...
|
// Get image filename...
|
||||||
//
|
//
|
||||||
@ -563,14 +562,11 @@ module.ImagesPrototype = {
|
|||||||
getImageFileName: function(gid, do_unescape){
|
getImageFileName: function(gid, do_unescape){
|
||||||
do_unescape = do_unescape == null ? true : do_unescape
|
do_unescape = do_unescape == null ? true : do_unescape
|
||||||
if(!this[gid] || !this[gid].path){
|
if(!this[gid] || !this[gid].path){
|
||||||
return gid
|
return gid }
|
||||||
}
|
|
||||||
if(do_unescape){
|
if(do_unescape){
|
||||||
return unescape(this[gid].path.split('/').pop())
|
return unescape(this[gid].path.split('/').pop())
|
||||||
} else {
|
} else {
|
||||||
return this[gid].path.split('/').pop()
|
return this[gid].path.split('/').pop() } },
|
||||||
}
|
|
||||||
},
|
|
||||||
// Get the first sequence of numbers in the file name...
|
// Get the first sequence of numbers in the file name...
|
||||||
//
|
//
|
||||||
// NOTE: if no filenmae (.path) is set, this will return gid... (???)
|
// NOTE: if no filenmae (.path) is set, this will return gid... (???)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user