8000 Add creating image from clipboard by Czaki · Pull Request #6532 · napari/napari · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add creating image from clipboard #6532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Dec 31, 2023
Merged

Conversation

Czaki
Copy link
Collaborator
@Czaki Czaki commented Dec 12, 2023

References and relevant issues

closes #6531

Description

Add option to create image layer from clipboard

@github-actions github-actions bot added the qt Relates to qt label Dec 12, 2023
@Czaki
Copy link
Collaborator Author
Czaki commented Dec 12, 2023

@psobolewskiPhD As requested. Any shortcut suggestions?

Copy link
codecov bot commented Dec 12, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (8b10df9) 92.30% compared to head (4cdd3be) 92.20%.

Files Patch % Lines
napari/_qt/qt_viewer.py 12.12% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6532      +/-   ##
==========================================
- Coverage   92.30%   92.20%   -0.10%     
==========================================
  Files         601      601              
  Lines       53707    53741      +34     
==========================================
- Hits        49573    49554      -19     
- Misses       4134     4187      +53     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@brisvag
Copy link
Contributor
brisvag commented Dec 12, 2023

@psobolewskiPhD As requested. Any shortcut suggestions?

ctrl+v? :P

@Czaki
Copy link
Collaborator Author
Czaki commented Dec 14, 2023

ctrl+v? :P

I'm not sure. For example, if I have selected point label, I expect to add something to this layer rather than insert new layer.

@brisvag
Copy link
Contributor
brisvag commented Dec 15, 2023

I think we can assume that people only want to paste into a label if they copied from a label. This also won't generalize to nD if you want to somehow convert the image to labels.

Copy link
Member
@psobolewskiPhD psobolewskiPhD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! A life changer! Highlight feature for me!
Made a small suggestion in the code to the name of the menu item, plus one more here because I can't suggest it:
I checked a number of GUI apps and New Foo... in their File menus is always at the top, before Open, so I would request the same pattern here to be consistent.
e.g. see Apple UX guidelines:
https://developer.apple.com/design/human-interface-guidelines/the-menu-bar#File-menu
and windows ones:
https://learn.microsoft.com/en-us/windows/win32/uxguide/cmd-menus#standard-menus

For the shortcut, I would suggest Command+N or Command-Shift+N which are common for variants of New Foo... in most apps (and is used by Apple Preview for this), but ImageJ uses Command-Shift+V which also makes sense to me--either is fine.

@psobolewskiPhD psobolewskiPhD added feature New feature or request highlight PR that should be mentioned in next release notes UI/UX labels Dec 18, 2023
@psobolewskiPhD
Copy link
Member

Yeah IMO definitely not straight Command-V (or Control-V), this action is creating a layer, not pasting an image into an existing layer, so it's not just paste. So I'd prefer a variant with N for new. But if we do want to go with V then Command-Shift-V is what ImageJ uses, which I think is fine.

Czaki and others added 2 commits December 18, 2023 19:02
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
@Czaki Czaki requested a review from psobolewskiPhD December 18, 2023 18:07
@psobolewskiPhD
Copy link
Member

@Czaki Sorry if I wasn't clear in my review comment. I'd also like to see the new menu item moved to the top of File menu, like the Apple and Windows UX guidelines.

@Czaki
Copy link
Collaborator Author
Czaki commented Dec 18, 2023

moved

@psobolewskiPhD
Copy link
Member

Beautiful!
Seriously love it.
Probably deserves mention here in the docs:
https://napari.org/stable/tutorials/fundamentals/viewer.html#main-menu-or-top-bar-menu
I can make a PR for that later if you'd like.

@Czaki
Copy link
Collaborator Author
Czaki 8000 commented Dec 18, 2023

I can make a PR for that later if you'd like.

please do this.

@Czaki Czaki added the ready to merge Last chance for comments! Will be merged in ~24h label Dec 18, 2023
@Czaki Czaki added this to the 0.5.0 milestone Dec 18, 2023
@psobolewskiPhD
Copy link
Member

Seriously killer feature -- this is like a universal image importer 🤣

@DragaDoncila
Copy link
Contributor

I'd also like to see the new menu item moved to the top of File menu, like the Apple and Windows UX guidelines.

@psobolewskiPhD is that to say that, regarding menu contributions, you would also want our default empty layers and plugin contributions for new layers to live under File > New? Currently they would be under Layers > New but if these are the guidelines I'll update NAP6

@psobolewskiPhD
Copy link
Member
8000 psobolewskiPhD commented Dec 19, 2023

@DragaDoncila Hmm. Tricky!
File > Open ... etc. currently makes new layers, yet layers themselves are not files--not necessarily anyways--so Layer > New ... certainly makes sense.
So in a Layers top-level menu world it seems like this menu item should be moved there?

I will note that in my browser New Tab is also under File even though a tab isn't a file....

Edit: also to be clear, In a new top-level Layers menu, I would expect New Foo... to be at the top of the menu, to be consistent with the UX guidelines I linked.

@DragaDoncila
Copy link
Contributor

File > Open ... etc. currently makes new layers, yet layers themselves are not files

I think in other software this is also true. So like, idk, Google docs opens .docx files but Google documents are not themselves .docx files. The more I think about it the more File > New seems like the place to put stuff that creates new layers not from file.

I guess it could be confusing if you imagine having other New things like idk File > New Canvas, but then I think we could do File > New Layer and File > New Canvas? Do we like that better than Layers > New and Canvas > New? It seems like the File location is closer to expected behaviour from other software.

@psobolewskiPhD
Copy link
Member

Makes sense. At the moment we don't have any sort of Project or whatever--some sort of napari multi-layer file-type--that would clearly belong in File.

@kephale
Copy link
Contributor
kephale commented Dec 20, 2023

Talked about this in community meeting, but linking the plugin implementation I made. It looks like the same implementation so all is good to me!
https://github.com/kephale/napari-clipboard/blob/main/src/napari_clipboard/_widget.py

@psobolewskiPhD
Copy link
Member

Oo! nice! never saw that plugin 😭
The show info is nice I think e.g. for the case of not-image data.

@Czaki
Copy link
Collaborator Author
Czaki commented Dec 20, 2023

I have added information about lack of image, and added the option to paste copied files.

@psobolewskiPhD
Copy link
Member
psobolewskiPhD commented Dec 22, 2023

I love the uRL behavior! copy zarr link, Command-N, boom in napari (with the ome-zarr plugin).
I wonder how discoverable it is, would having that be under Open URL... be better?

Edit3: Interestingly it has to be a link--text of a URL is not sufficient.

Edit: also, what about updating the splash/welcome screen? I made a PR to your branch:
https://github.com/Czaki/napari/pull/32/files

Edit2: removed ready to merge because there really isn't a rush on this (with it being 0.5.0) and getting everything clear is best

@psobolewskiPhD psobolewskiPhD removed the ready to merge Last chance for comments! Will be merged in ~24h label Dec 22, 2023
Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
@Czaki
Copy link
Collaborator Author
Czaki commented Dec 22, 2023

Edit3: Interestingly it has to be a link--text of a URL is not sufficient.

Should I fix this? The required change is to not depend only on hasUrl but also check if text in clipboard is url.

@psobolewskiPhD
Copy link
Member

is there an easy way to validate a string as URL? if not then maybe not worth it? Current functionality covers most use cases that could be considered "from Clipboard" vs. a "File > Open URL..." functionality.

@Czaki
Copy link
Collaborator Author
Czaki commented Dec 26, 2023

Now you could store a list of your project files in some note (split by line) and just open them all with Ctrl+N

Co-authored-by: Peter Sobolewski <76622105+psobolewskiPhD@users.noreply.github.com>
@psobolewskiPhD
Copy link
Member

Love it! Small comment above I ran into with end-of-line/new-line characters.

@Czaki Czaki added the ready to merge Last chance for comments! Will be merged in ~24h label Dec 28, 2023
@Czaki Czaki merged commit 0e54d85 into napari:main Dec 31, 2023
@Czaki Czaki deleted the image_from_clipboard branch December 31, 2023 16:29
@Czaki Czaki removed the ready to merge Last chance for comments! Will be merged in ~24h label Dec 31, 2023
kne42 added a commit to kne42/napari that referenced this pull request Jan 4, 2024
* main:
  Use blobs instead of random integers (napari#6527)
  Set default dtype for empty `_ImageSliceResponse` (napari#6552)
  Add creating image from clipboard (napari#6532)
  Fix check if plugin is available from conda (napari#6545)
  Fix generation of layer creation functions docstrings (napari#6558)
  Print a whole stack if throttler is not finished (napari#6549)
  Update `app-model`, `babel`, `coverage`, `dask`, `fsspec`, `hypothesis`, `imageio`, `ipython`, `lxml`, `magicgui`, `pandas`, `pint`, `psutil`, `pydantic`, `pyqt6`, `pytest-qt`, `tensorstore`, `tifffile`, `virtualenv`, `xarray` (napari#6478)
  Minimal changes for mlx (and jax) compatibility for Image layers (napari#6553)
  [pre-commit.ci] pre-commit autoupdate (napari#6528)
  Moving IntensityVisualizationMixin from _ImageBase to Image (napari#6548)
GenevieveBuckley added a commit to napari/docs that referenced this pull request Mar 7, 2024
# References and relevant issues
Depends on napari/napari#6532

# Description
This PR adds mentions of the new feature: File menu item `New Image from
Clipboard` to the `viewer tutorial` as well as the `getting started` and
`quick start` guides.

---------

Co-authored-by: Lucy Liu <jliu176@gmail.com>
Co-authored-by: Genevieve Buckley <30920819+GenevieveBuckley@users.no
7878
reply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request highlight PR that should be mentioned in next release notes qt Relates to qt UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a New Image from Clipboard feature to add an image layer
5 participants
0