Commit Graph

111 Commits

Author SHA1 Message Date
Damien Elmes
40aff4447a undo support for note adding 2021-03-10 11:47:53 +10:00
Damien Elmes
b466f0ce90 rework undo
- use dataclasses for the review/checkpoint undo cases, instead of the
nasty ad-hoc list structure
- expose backend review undo to Python, and hook it into GUI
- redo is not currently exposed on the GUI, and the backend can only
cope with reviews done by the new scheduler at the moment
- the initial undo prototype code was bumping mtime/usn on undo, but
that was not ideal, as it was breaking the queue handling which expected
the mtime to match. The original rationale for bumping mtime/usn was
to avoid problems with syncing, but various operations like removing
a revlog can't be synced anyway - so we just need to ensure we clear the
undo queue prior to syncing
2021-03-10 11:47:53 +10:00
Damien Elmes
35840221bb tweak search wording and tidy up API
- SearchTerm -> SearchNode
- Operator -> Joiner; share between messages
- build_search_string() supports specifying AND/OR as a convenience
- group_searches() makes it easier to negate
2021-02-11 19:57:19 +10:00
Damien Elmes
88c002f4eb convert qt strings to f-strings with flynt
Also revealed an incorrect type def in editor.py that mypy wasn't
noticing before :-(
2021-02-11 10:09:06 +10:00
Damien Elmes
bb29ce88f3 minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
4a5ef69068 add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
RumovZ
c18af2a0a9 Merge branch 'master' into dyn-deckconf 2021-02-01 23:33:41 +01:00
Damien Elmes
a56b09b987 add a bunch of return types 2021-02-01 23:53:23 +10:00
Damien Elmes
f15715fb07 add types to various other files
Mainly automated with MonkeyType
2021-02-01 22:08:56 +10:00
RumovZ
6de6e5f339 Make browser accept optional args and add reopen
That way, the caller doesn't have to hold a reference to the browser and
explicitly call it again, if it wants to search for something specific.
Also, if the browser was closed and opened for a single-card-search, it
now won't perform a redundant current-deck-search first.
2021-02-01 11:54:28 +01:00
RumovZ
5425b00d2b Import SearchTerm from collection in aqt 2021-01-30 12:51:24 +01:00
Damien Elmes
cb6b88da0f simplify nid/nids searches, and ditch helper function
- IdList could be re-used for a cids: search in the future if required.
- Embedding the message means it's easy to access from Python as
an attribute of SearchTerm.
2021-01-30 11:37:00 +10:00
RumovZ
c299e271e8 Refactor search_string() and FilterToSearchIn
See #955.
2021-01-29 18:27:33 +01:00
RumovZ
f04228990d Add browser_search helper in mw 2021-01-28 20:51:32 +01:00
RumovZ
251fe50660 Fix search calls in addcards 2021-01-28 20:01:20 +01:00
RumovZ
a930aa41f0 Use backend nid filter in addcards and mediacheck 2021-01-28 18:59:20 +01:00
Arthur Milchior
e0a2d90a68 NF: HelpPage in an enum
Hopefully, this can help with updating on next manual update and maybe even linking to manual translation
2021-01-26 02:16:37 +01:00
Damien Elmes
94064b8230 convert setWindowFlags call into helper, and fix invalid variables
"type: ignore" was masking the invalid references to self in places
like showText()
2021-01-07 14:24:49 +10:00
Damien Elmes
5c08bd8fb8
Merge pull request #899 from BlueGreenMagick/remove-context-help-btn
remove context help button
2021-01-07 09:52:12 +10:00
wallgrenen
78601d29ba replace broken link 2021-01-06 17:03:39 +01:00
BlueGreenMagick
6224658c0d remove context help button 2021-01-06 22:15:48 +09:00
Damien Elmes
ffa26fe4bc fix remaining _() references; remove unused imports 2020-11-18 12:43:46 +10:00
Damien Elmes
ba336d5de3 update multi-line _() references 2020-11-18 11:32:22 +10:00
Damien Elmes
2453e5c488 update temporary val="%s" references to standard ftl 2020-11-17 22:00:44 +10:00
Damien Elmes
6418993840 merge bulk of qt/ - designer files still to do 2020-11-17 17:42:43 +10:00
RumovZ
aaf5770db9 Work around Qt's focus bug (fix help-wanted#22)
Manually hide the editor's completer popup before accepting a short cut which changes the focus widget. Thus, work around the bug in PyQt 5.15 where a QLineEdit with open QCompleter popup won't get notified about focus changes handled by the Main Window, leading to inconsistent focus.
2020-10-24 10:47:25 +02:00
johan456789
06f1aeb052 fix help url paths 2020-10-10 00:38:07 +08:00
Damien Elmes
bf72773531 fix IndexError when switching notetypes
Closes #780
https://github.com/ankitects/anki/pull/780
2020-10-05 13:33:54 +10:00
Henrik Giesel
7f503895d7 Create ResetReason enum 2020-08-16 18:56:32 +02:00
Henrik Giesel
db0a18106f Reorder + make all parameters optional 2020-08-16 18:56:32 +02:00
Henrik Giesel
ccc56d4355 Satisfy formatter 2020-08-16 18:56:32 +02:00
Henrik Giesel
dd515e65e7 Add new use of requireReset 2020-08-16 18:56:32 +02:00
Arthur Milchior
c81a9b3d61 hook: history_line
I expect to use this hook to create an add-on which will simply remove
the ",,". By ignoring empty fields I expect to make this easier to
use.
2020-06-08 20:47:01 +02:00
Damien Elmes
6ae55a7a77 deprecate removeTempNote() 2020-05-20 15:01:05 +10:00
Damien Elmes
f1c5c88c10 no longer need to check addNote's return value 2020-05-14 21:59:42 +10:00
Damien Elmes
24ffb6ab76 check for empty cloze cards when rendering as well 2020-05-14 21:56:45 +10:00
Damien Elmes
08f894735a
Merge pull request #607 from Arthur-Milchior/remove_a_try
Simplify the copying of field contents when resetting
2020-05-05 11:36:17 +10:00
Damien Elmes
9502fe790f
Merge pull request #584 from Arthur-Milchior/onModelchangeUsed
On modelchange used
2020-05-04 14:06:35 +10:00
Damien Elmes
eec3fcf87a use qconnect everywhere, and fix some typing issues
a step towards check_untyped_defs in aqt, but there's still 100+
issues to resolve
2020-05-04 13:23:08 +10:00
Arthur Milchior
f2fbf667cd onModelChange: replacing try by if 2020-05-03 01:53:00 +02:00
Arthur Milchior
d427e1028b single try in onModelChange 2020-05-03 01:53:00 +02:00
Arthur Milchior
936bb31997 onModelChange save note
I like the way onModelChange is done. Except that you forget to use
the note you computed.
2020-05-03 01:53:00 +02:00
Arthur Milchior
3378daeca3 remove an useless asignment
Because fields of new notes are empty by default
2020-04-28 00:31:30 +02:00
Arthur Milchior
93d83e760b remove a try, for code clarity 2020-04-28 00:31:24 +02:00
Damien Elmes
0c8f6ced09 Revert "Merge pull request #583 from Arthur-Milchior/remove_a_try"
This reverts commit e9ca61d1eb, reversing
changes made to abb80231a5.
2020-04-28 07:38:23 +10:00
Arthur Milchior
e4a0ccc059 remove an useless asignment
Because fields of new notes are empty by default
2020-04-26 14:49:16 +02:00
Arthur Milchior
1771be8f1e remove a try, for code clarity 2020-04-26 14:49:11 +02:00
BlueGreenMagick
aa86bc8088 use model type to detect cloze notes 2020-04-07 14:02:53 +09:00
Arthur Milchior
657fa9758b hook add_card_did_init 2020-04-03 11:03:08 +02:00
Arthur Milchior
0b633dbf40 Ensuring "setNote" is called only once during changing of note type
Initially, I wanted to solve the bug reported on
https://github.com/Arthur-Milchior/anki-html-src-in-field/issues/1

After some research, I finally discovered that the trouble was that,
when we change the note type in add card, the method
`aqt.editor.Editor.loadNote` is called twice. In itself, it would not
be a problem, but given the way callback works, its call back is
called twice on the last version of the webview. Which means that
`gui_hooks.editor_did_load_note` is called twice, which breaks this
add-on.

The reason why loadNote is called twice is because `setNote` is called
twice in `aqt.modelchooser.onModelChange`. The first time through
`gui_hooks.current_note_type_did_change` which calls
`addcards.AddCards.onModelChange` which calls `loadNote`, the second
time through `self.mw.reset()` which calls
`gui_hooks.state_did_reset()` which calls `addcards.AddCards.onReset`
which calls `setAndFocusNote` which calls `setNote`.

I should note furthermore that currently,
`gui_hooks.current_note_type_did_change` is called only when the model
chooser change a model. And `addCards.onModelChange` is never called,
only added to the hook `gui_hooks.current_note_type_did_change`. So
removing the line of code removed in this commit will have no side
effect in Anki itself. It will only affect the fact that this method
is called twice.

I do not know of any add-on calling `onModelChange` or
`gui_hooks.current_note_type_did_change`, but it means little, so of
course, it may always mean an add-on will break because of this
change. No way of being sure.
2020-03-26 21:26:13 +01:00
Damien Elmes
0d43e9dca3 tweak add-on wording 2020-03-20 21:00:21 +10:00
Arthur Milchior
e4ae41340f Hook to decide whether a note should be added. 2020-03-19 03:39:53 +01:00
Arthur Milchior
66e1f876d7 "unused" variable become optional.
Adding this parameter broke one of my add-on, see
https://github.com/Arthur-Milchior/anki-keep-model-in-add-cards/issues/1

Since those parameters are not used, setting them to None by default,
as was done in some other method, seems acceptable
2020-01-23 21:46:42 -08:00
Damien Elmes
02ec3f149c update qt/ to use the new API 2020-01-20 20:10:38 +10:00
Damien Elmes
8310cb7a0e add qconnect helper and some type hints
The type hints allow mypy to check the gui_hook calls, revealing a
bunch of places that are broken as they expect no arguments like the
legacy hooks.

To make mypy happy about PyQt's signal.connect(func), a qconnect()
helper has been added.
2020-01-16 07:41:23 +10:00
Damien Elmes
b09e7e8247 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
89fce1f6b7 migrate addHook/remHook calls 2020-01-15 13:49:26 +10:00
Damien Elmes
660685375f migrate most of the remaining runHook() calls 2020-01-15 12:46:53 +10:00
Glutanimate
cda296748d Add hook for AddCards.addNote 2020-01-08 21:29:28 +01:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00