Commit Graph

46 Commits

Author SHA1 Message Date
Damien Elmes
2a93355824 PEP8 cards.py 2021-06-27 12:12:23 +10:00
Damien Elmes
f5fbad2c20 fix CSV import ignoring selected deck
This is a stop-gap - once the importing code is refactored, we
should pass in the desired deck directly.

https://forums.ankiweb.net/t/anki-2-1-45-alpha/10061/102
2021-06-04 20:37:45 +10:00
Damien Elmes
b7587cb8d2 update TR references that contain arguments 2021-03-26 14:21:04 +10:00
Damien Elmes
0c338bfd53 update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
Damien Elmes
efb1ce46d4 switch the Importers global to a callable for i18n
I18n is not set up at init time, so the strings can't be generated
at import.

@kelciour you have a few importing add-ons, so wanted to give you a
heads-up. The importing code is likely to change more in
future months, but for now this should be the only change
2021-03-26 13:28:21 +10:00
Damien Elmes
87801668e9 fix .csv import not using faster QPlainTextEdit 2021-03-22 11:26:49 +10:00
Damien Elmes
ce243c2cae Simplify note adding and the deck/notetype choosers
The existing code was really difficult to reason about:

- The default notetype depended on the selected deck, and vice versa,
and this logic was buried in the deck and notetype choosing screens,
and models.py.
- Changes to the notetype were not passed back directly, but were fired
via a hook, which changed any screen in the app that had a notetype
selector.

It also wasn't great for performance, as the most recent deck and tags
were embedded in the notetype, which can be expensive to save and sync
for large notetypes.

To address these points:

- The current deck for a notetype, and notetype for a deck, are now
stored in separate config variables, instead of directly in the deck
or notetype. These are cheap to read and write, and we'll be able to
sync them individually in the future once config syncing is updated in
the future. I seem to recall some users not wanting the tag saving
behaviour, so I've dropped that for now, but if people end up missing
it, it would be simple to add as an extra auxiliary config variable.
- The logic for getting the starting deck and notetype has been moved
into the backend. It should be the same as the older Python code, with
one exception: when "change deck depending on notetype" is enabled in
the preferences, it will start with the current notetype ("curModel"),
instead of first trying to get a deck-specific notetype.
- ModelChooser has been duplicated into notetypechooser.py, and it
has been updated to solely be concerned with keeping track of a selected
notetype - it no longer alters global state.
2021-03-10 11:53:27 +10:00
Benjamin K
5d880f6e31 Clean up imports 2021-03-04 19:55:35 +01:00
Benjamin K
a066cee326 The old delimiter is now kept, when cancel button is clicked 2021-03-04 19:39:43 +01: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
Damien Elmes
7fc32db0c9 fix: slowdowns after import; hard to read popup
QTextEdit() will pin the CPU at 100% for seconds to minutes when
fed a large string to display - work around it by switching to
QPlainTextEdit().

Also strip HTML before showing the user - easier to read, and less
text to display. And turn off word wrap, as it makes it easier to skim,
and further reduces the work the widget needs to do.

https://forums.ankiweb.net/t/big-issue-where-anki-gets-slow-when-you-import-this-deck/7050
2021-02-02 15:49:47 +10: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
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
BlueGreenMagick
6224658c0d remove context help button 2021-01-06 22:15:48 +09:00
Damien Elmes
ba336d5de3 update multi-line _() references 2020-11-18 11:32:22 +10:00
Damien Elmes
b49805fef5 more ngettext references 2020-11-18 10:52:13 +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
Damien Elmes
81b9a3194e fix some unwanted leading space in i18n keys 2020-11-12 08:55:26 +10:00
abdo
d91f2a27b2 Remove unused code 2020-10-15 16:14:14 +03:00
abdo
236a6071d4 Save importing model in any case
https://forums.ankiweb.net/t/bug-notes-are-imported-to-the-wrong-deck-in-certain-cases/4318
2020-10-15 15:14:55 +03:00
Damien Elmes
727ddd74b6 fixes for latest mypy 2020-10-10 19:02:59 +10:00
Matt Krump
a844a8b0c5 Add type hints to importing
* Add type hints to importing
* Turn on type checking for aqt.importing
2020-07-24 12:38:34 -06:00
Damien Elmes
a8ad4abf37 add "immediate" progress back
on ops which we know are going to take time, it makes the interface
look more responsive to pop up the progress more quickly
2020-06-01 13:57:10 +10:00
Damien Elmes
f3a8bb28d5 fix progress window not disappearing when importing csv 2020-05-29 08:40:25 +10:00
evandrocoan
200bad3714 Explicitly close the importer file descriptor
https://github.com/ankitects/anki/pull 613
2020-05-18 15:54:20 -03:00
evandrocoan
efb62b9528 Add missing close file descriptors using context managers 2020-05-18 15:54:20 -03: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
Damien Elmes
8d429cd192 import .colpkg in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
ad9dad8748 import .apkg files in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
231fa30a86 import mapped files like csv in a background thread 2020-03-20 21:15:23 +10:00
Damien Elmes
33f312315e must close progress before displaying error, or user can't click it away 2020-03-14 18:42:03 +10:00
Damien Elmes
43f5d13ed6 migrate strings with trailing newlines to fluent 2020-02-27 20:36:40 +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
967b8a038d
Merge pull request #421 from ErezVolk/tag-changed-grooming
Tag modified grooming
2020-01-15 20:25:51 +10:00
Erez Volk
bd9aaa9296 Small fixes and tweaks to "Tag Modified":
- No need for the checkbox, as an unchecked box is equal to an empty
`QLineEdit`.
- The value was saved to the profile but not loaded.
- And the real pièce de résistance: I've figured out how to "Promote"
the `QLineEdit` to a `TagEdit`.

Hope you like it! :)
2020-01-15 10:46:05 +02: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
Erez Volk
b4facdf650 BUGFIX: QLineEdit doesn't have .toPlainText() 2020-01-05 07:54:45 +02:00
Erez Volk
46a24812ce Enable Tag Modified iff importMode is Update 2020-01-03 08:32:44 +02:00
Erez Volk
e481cce816 Merge remote-tracking branch 'upstream/master' into add-tags-on-update 2020-01-03 08:13:04 +02:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00