-
Notifications
You must be signed in to change notification settings - Fork 251
[Feature Request] Make “View added note” button open Edit card dialog, not Browse #2070
Comments
This could probably be added as a configuration option to Yomichan, or as some sort click modifier like shift+click, but I think backwards compatibility would be the primary factor here. Since you already have some base code, if you want to create a PR on https://github.com/FooSoft/anki-connect for changes, I can provide some pointers: AnkiConnect API changesThe function here: def guiBrowse(self, query=None, options=None):
if isinstance(options, dict) and 'editNoteId' in options:
# Your changes, but using options['editNoteId']
from . import edit
aqt.dialogs.open("Edit", aqt.mw, int(options['editNoteId']))
return []
# Remainder of original contents (Test this, I haven't tested this myself) This would provide backwards compatibility, and forwards compatibility would fall-back to using the old behavior. AnkiConnect README changesUpdate https://github.com/FooSoft/anki-connect/blob/master/README.md#graphical-actions with info about the new Yomichan changesSubsequently, the changes in Yomichan's anki.js would be something like this: // ...
return await this._invoke('guiBrowse', {
query: `nid:${noteId}`,
options: {
editNoteId: noteId
}
}); There would be other changes to UI/settings, but that should all come after AnkiConnect actually supports the UI. So IMO I would start by creating a PR on AnkiConnect and let @FooSoft hash out the implementation details on there, then proceed to determine the Yomichan implementation. |
I don't see any need to overload the existing |
Yeah I was thinking of a new API. I could try making a PR but the thing is, while i made this work on my machine and on the current stable version of Anki, I'm just not sure how fragile is the code posted above. Anki's browser previewer is strongly tied to the browser so I made a new one but I had to use private methods; I added the preview button by copying stuff from browser.py but using any id other than p.s. the POC uses |
That's the reality of AnkiConnect... It's not using any public APIs, just poking at the internals. Things break over time, important things get fixed sooner rather than later. |
I guess my thought was to make compatibility as easy as possible. If someone has a new version of Yomichan which uses the new |
There's no good way to see if an action is available in AnkiConnect. That being said, you can just try calling the API and seeing if it errors out on the action not being available. This doesn't introduce any perceivable delay to the user. |
So... Edit dialog has now been merged into Anki-Connect (here's the API method). I find the dialog very satisfying, if I do say so myself. How about an option in Yomichan to use it? I could try making a PR but JavaScript is not my forte 🙏 I imagine a drop-down list with an option to either use Browser or this dialog. I'm not sure if something like Shift-clicking for the alternative would be useful, as you can always open Browser from the Edit dialog. (Or just switch everyone to the Edit dialog. Who wants the ugly bulky browser? Ugh!) |
See #2143 for example. This is not complete, but it should allow testing. First thing I notice about the AnkiConnect plugin is that the |
Thanks for bringing it up! Window activation is behaving very erratically in Qt, or maybe it's Windows to blame. I think I have figured out some of it at least now. (Somehow opening PyCharm screws it up, too! Took some time to catch that.) I have a fix that works for me on my machine. (I'm running Windows 10, and am not using the registry hack.) In fact, it works even better than Browser does! Can you perhaps try it and see if it works for you as well? Only Barring that, in the comment above the fix, I listed the cases in which the window wasn't properly activated. Can you confirm that this is what you saw? If you saw the window not being activated in other circumstances, could you please describe them? |
Windows has a bunch of restrictions related to when windows are allowed to become the foreground window, see this link for some details. This is probably because Windows has had a checkered past with malware taking advantage of APIs like this and being a nuisance, so Windows has had to lock them down quite a bit. That being said, if a window isn't allowed to become the foreground window, it usually will flash its tab on the taskbar. Testing your latest update looks more consistent with the behaviour of the how the old GUI browser is opened (taskbar flashes or becomes foreground window). I might suggest adding a link to your comment in edit.py to the SetForegroundWindow page, since I believe that's largely what causes all of the "odd" behaviour. |
By the way, Ubuntu does the same, only instead of flashing the taskbar it shows a toast on the top of the screen saying “Window is ready”. Pretty awful. Anyway, I call the behavior erratic since, well, it's inconsistent and doesn't work as advertised. The behavior depends on stuff like whether PyCharm was opened since boot or not, whether the main window is minimized or not, which of the Anki windows gets focus last. I think the windows are supposed to never “steal focus” from Yomichan, but they sometimes do, both on Ubuntu and Windows. I suppose the issue is with Qt, it has had a lot of issues with window activation. (Opened one myself the other week!) Or perhaps the moon wobble was especially strong at that moment. I just don't see how it can be explained with the comment in It might be worth getting down to the real issue, but for the time being I suppose it should be good enough that Edit dialog behaves no worse than Browser with regards to activation. But yeah, a few links won't hurt. As for #2143, yeah I can test on my machine, thanks. I suppose this needs an option, though? |
Yep, this is what I was looking for. I don't expect us to fix issues that aren't directly related to how the OS handles things, so just making the two consistent is sufficient. #2143 is updated now with a setting. |
Resolved by #2143. |
I use the button “View added note” a lot to add finishing touches to my cards. This opens the browser. Some parts of the browser, such as the sidebar and the note list, take a lot of space and cannot be collapsed fully. I suggest adding an option to open Edit card dialog instead.
I imagine that the “Edit card” dialog, which doesn't exist at the moment, should look just like the existing “Edit Current” dialog, perhaps sans the “Close” button. This would require changes in AnkiConnect, and perhaps in Anki itself. I'm opening an issue here as if this doesn't get a green light, there's no point in asking for changes elsewhere.
The text was updated successfully, but these errors were encountered: