Skip to content
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

Add "open image" option to editor #3431

Merged
merged 8 commits into from
Oct 4, 2024
Merged

Add "open image" option to editor #3431

merged 8 commits into from
Oct 4, 2024

Conversation

user1823
Copy link
Contributor

No description provided.

@user1823
Copy link
Contributor Author

user1823 commented Sep 20, 2024

The name of the function "openFolder" is misleading because it can also be used to open files. Do you have any suggestion that is clear yet succint?

Edit:
Does openPath look good?

@dae
Copy link
Member

dae commented Sep 22, 2024

openFolder is existing code that may be used by add-ons, so simplest to just leave the name alone.

The code at present is incorrect, and will print an error message when there's no media URL on the clipboard.

qt/aqt/editor.py Outdated Show resolved Hide resolved
Copy link
Contributor

@bpnguyen107 bpnguyen107 left a comment

Choose a reason for hiding this comment

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

Hey @user1823, I was able to replicate @dae's error. I believe the suggestions I left you should fix those errors. Your open image feature still doesn't work for me though.

Also, I suggest manually testing all your code changes to Anki using ./run if you aren't already. It allows you to catch these bugs!

qt/aqt/editor.py Outdated Show resolved Hide resolved
qt/aqt/editor.py Outdated Show resolved Hide resolved
@user1823
Copy link
Contributor Author

Also, I suggest manually testing all your code changes to Anki using ./run if you aren't already. It allows you to catch these bugs!

Sorry. But, that is too much for me because I am not really a developer.

Also, because my previous PR (#3412) also includes url = webview.lastContextMenuRequest().mediaUrl(), I wonder why it is a problem in this PR but not in that PR. Or does the same problem exist in that PR too and it was just left undiscovered?

@bpnguyen107
Copy link
Contributor

I don't know. Did you test your previous PR?

@user1823
Copy link
Contributor Author

Did you test your previous PR?

Sorry, but I didn't (because I don't know how to).

@user1823
Copy link
Contributor Author

The error should be fixed now (thanks Ben). I would appreciate if someone could test whether the feature works correctly.

@user1823
Copy link
Contributor Author

user1823 commented Sep 27, 2024

Well, I tested this by creating an add-on that patches the function in Anki's latest beta. The open image function seems to work correctly after these changes. However, nothing happens when I click on the show in folder option. I will try to investigate the issue in the show in folder option tomorrow.

@user1823
Copy link
Contributor Author

user1823 commented Sep 28, 2024

With the latest change, the "show in folder" option also works. However, I am now directly using subprocess rather than using call.

@dae
Copy link
Member

dae commented Oct 2, 2024

I've pushed a fix for macOS. The change you've made to call() is not something I can accept, as passing multiple arguments in a single string is a security issue. I'd also expect the previous usage to work. Does the original call not work for you @user1823 @abdnh?

@user1823
Copy link
Contributor Author

user1823 commented Oct 2, 2024

I'd also expect the previous usage to work. Does the original call not work for you

It didn't work. Probably, there is a trivial error but I couldn't find it.

user1823 and others added 8 commits October 4, 2024 16:10
Co-authored-by: Ben Nguyen <105088397+bpnguyen107@users.noreply.github.com>
- Avoid reusing call(), as the startupinfo we were passing in was
breaking the explorer invocation
- Attempt to bring explorer to the front after the window has been show,
as it otherwise appears under Anki (at least when running from source)
@user1823
Copy link
Contributor Author

user1823 commented Oct 4, 2024

This works for me. Thanks!

@dae
Copy link
Member

dae commented Oct 4, 2024

Damn, I'd intended to merge this in for beta 2. Oh well.

@dae dae merged commit de3b175 into ankitects:main Oct 4, 2024
1 check passed
@user1823 user1823 deleted the open_image branch October 4, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants