Commit Graph

272 Commits

Author SHA1 Message Date
Henrik Giesel
4e43d27fb8 Remove ResetReason.BrowserDeleteNote 2020-08-17 12:50:40 +02:00
Henrik Giesel
dcf82fb403
Merge branch 'master' into resethook 2020-08-17 12:39:09 +02:00
Damien Elmes
177ced7a31 clear undo queue on sync
https://forums.ankiweb.net/t/ios-ipad-sync-failure-with-filtered-decks/1617/34
2020-08-17 20:09:07 +10:00
Henrik Giesel
7f503895d7 Create ResetReason enum 2020-08-16 18:56:32 +02:00
Henrik Giesel
97a4a0ef34 Rename to should_require_reset 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
Henrik Giesel
31323719bc Insert gui_hook main_window_will_require_reset
* into AnkiQt.requireReset method
2020-08-16 18:56:32 +02:00
Arthur Milchior
c4db4bd291 Any removed 2020-08-12 01:37:21 +02:00
Matt Krump
83449e35ad Turn on check_untyped_defs for aqt.main 2020-07-31 20:34:14 -06:00
Damien Elmes
67abb98993
Merge pull request #692 from Arthur-Milchior/remove_useles_variables
Remove useless variables
2020-07-20 11:35:40 +10:00
Damien Elmes
f22aa4c199 catch SIGTERM, and respond more quickly 2020-07-18 11:26:04 +10:00
Arthur Milchior
452daf8d80 Remove useless variables 2020-07-17 08:38:48 +02:00
Damien Elmes
bfbab8b498 i18n downgrade&quit button 2020-07-17 15:06:14 +10:00
Damien Elmes
04b1ca7559 defer top toolbar drawing until after add-ons loaded
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/13
2020-07-02 10:23:14 +10:00
Damien Elmes
bedd9dadb1 add option to disable media syncing
https://forums.ankiweb.net/t/error-when-adding-audio-file/495/2
2020-07-01 11:35:24 +10:00
Damien Elmes
40f270c386 shift+click on the graphs button to access old graphs for now 2020-06-30 20:07:46 +10:00
Damien Elmes
7c444b4d35 add progress to db check 2020-06-08 21:07:36 +10:00
Damien Elmes
26330da119
Merge pull request #657 from BlueGreenMagick/prof-name
don't allow addons21 as profile name
2020-06-08 11:30:27 +10:00
BlueGreenMagick
7df3c9f0b1 don't allow addons21 as profile name
because addons21 and profiles directory are stored in same directory
2020-06-05 22:44:59 +09:00
Damien Elmes
4a69b55a90 add note/card removal to backend 2020-06-04 18:21:04 +10:00
Damien Elmes
b3752e8618 fix initial login 2020-06-02 15:10:58 +10:00
Damien Elmes
49971d0235 fix media sync progress not updating, and issues closing profile 2020-06-01 13:57:10 +10:00
Damien Elmes
6bf9f5bc6c lint fixes 2020-06-01 13:57:10 +10: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
7e221f0acf update auto-sync code 2020-06-01 13:57:10 +10:00
Damien Elmes
0e5b7da62a login/full up/full down plugged in 2020-06-01 13:57:10 +10:00
evandrocoan
9257e75762 Save and restore the debug console window geometry and splitter 2020-05-30 20:58:55 -03:00
Glutanimate
6147356330 Add main_window_did_init hook and clarify difference to profile_did_open 2020-05-28 13:30:22 +02:00
Damien Elmes
50fdf9b03d storage->collection 2020-05-20 17:58:28 +10:00
Damien Elmes
c49c378296 move storage logic into collection.py; fix export bug
https://anki.tenderapp.com/discussions/ankidesktop/41495-using-file-export-closes-the-collection-on-mwcoldb-if-the-browser-window-is-open
2020-05-20 17:43:34 +10:00
evandrocoan
efb62b9528 Add missing close file descriptors using context managers 2020-05-18 15:54:20 -03:00
Damien Elmes
83adfb60cf avoid duplicate reset in overview 2020-05-15 21:54:56 +10:00
Damien Elmes
964a69e54e handle default deck and filtered deck suppression in the backend 2020-05-15 21:21:10 +10:00
Damien Elmes
46c363d4aa track changes in fields dialog as well
And avoid bumping schema until user actually saves, but warn at
start.
2020-05-15 13:59:44 +10:00
Damien Elmes
70cc1699a6 rewrite DB check
- notes with wrong field count are now recovered instead of
being deleted
- notes with missing note types are now recovered
- notes with missing cards are now recovered
- recover_missing_deck() still needs implementing
- checks required
2020-05-12 21:13:34 +10:00
Damien Elmes
c51ca666c3 catch schema mod in background
If the schema confirmation dialog is shown on a background thread it
will crash the app, so we convert this to an assertion error that gets
caught by the error handler. Code still needs to be updated to modify
the schema prior to moving to the background, but at least this way
it doesn't crash.
2020-05-12 21:13:34 +10:00
Damien Elmes
25f122bf5c update fields and models diags
- field changes are now applied when user closes dialog with save
button, in bulk
- models diag now fetches note type and saves it as required, instead
of holding on top a copy that can grow stale as changes are made in
subdialogs
- both dialogs now perform operations in the backend
- note.model() now fetches the note type on the fly, instead of
holding on to a copy that may become stale
2020-05-12 21:13:34 +10:00
Damien Elmes
f6931197d2 add helper to run background task with progress 2020-05-12 21:13:34 +10:00
Damien Elmes
0bb80329e8 ensure collection doesn't get stuck open if loading fails 2020-05-12 21:13:33 +10:00
Damien Elmes
6e8860cafa hook the empty cards code up to the GUI 2020-05-12 21:13:33 +10:00
Damien Elmes
1ca7fb4a80 use quick check instead of full integrity check on collection close 2020-05-12 21:13:33 +10:00
Damien Elmes
5236e20a7a
Merge pull request #580 from Arthur-Milchior/debug_diag
mw.debug_diag is the dialog and not the window
2020-05-04 14:07:15 +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
e86817305a mw.debug_diag is the dialog and not the window
This will allow, for example, for add-ons to do self.debugDiag.text
and access the debugger text. I see very little reason to have a
direct access to the dialog window.

I should note that self.debugDiag is never used anywhere in the code,
so I think it should be deleted; unless you've heard of some add-on
using it.
2020-04-27 11:55:33 +02:00
Damien Elmes
a7d5d27778 catch and report issues when downgrading 2020-04-16 10:11:16 +10:00
Damien Elmes
07343f6c9f show a clearer error if the schema is too new
will hold off on making it translatable for now
2020-04-16 09:47:34 +10:00
Damien Elmes
d24cb66be9 downgrade manually
- A regular collection open/close no longer goes through the
upgrade/downgrade steps each time. This avoids wasted cycles, and will
become more important in the future when decks and note types are
split into separate tables.
- Added a downgrade button to the profiles screen to downgrade all
profiles and close the app.
- Downgrading is still automatic when exporting/doing a full sync.
2020-04-16 09:00:49 +10:00
Damien Elmes
a6b676039b work around full sync on start closing the app
This is just a temporary solution until the syncing code can be
reworked.

https://anki.tenderapp.com/discussions/ankidesktop/39761-anki-crashing-after-sync-and-download
2020-04-16 08:10:17 +10:00
Damien Elmes
16be20e2fa don't write log files when exporting 2020-04-15 21:45:32 +10:00
Damien Elmes
698bf9c780
Merge pull request #550 from BlueGreenMagick/debugDiag-contextMenu
add clear actions to context menu in debug console
2020-04-11 14:19:46 +10:00
Damien Elmes
a068fcdc9f
Update main.py 2020-04-11 14:19:27 +10:00
BlueGreenMagick
653f5765b8 add clear actions to context menu in debug console 2020-04-10 15:45:25 +09:00
Damien Elmes
8f7ef6ed2c make sure progress stops when collection corrupt message shown 2020-04-09 14:19:20 +10:00
Damien Elmes
55b99511c0 print exception on close 2020-04-08 10:05:33 +10:00
Damien Elmes
7375a0389a add flag to skip downgrade on collection close
Disabled for now; when enabled it will allow faster collection
open and close in the normal case, while continuing to downgrade
when exporting or doing a full sync.

Also, when downgrading is disabled, the journal mode is no longer
changed back to delete.
2020-04-04 17:21:45 +10:00
Damien Elmes
fe327e32ca fix progress dialog preventing schema mod
https://anki.tenderapp.com/discussions/beta-testing/1868-anki-2124-beta#comment_48183062

This is an ugly hack - in the future the calling code should be updated
to perform the check prior to starting the operation instead.
2020-03-26 21:07:53 +10:00
Damien Elmes
65b8988817 reduce the chances of add-ons preventing collections from loading
https://anki.tenderapp.com/discussions/ankidesktop/39953-sync-fail-with-images#comment_48182205
2020-03-26 09:53:15 +10:00
evandrocoan
b1b3e5b87c Merge remote-tracking branch 'danielelmes/master' into fix_tests_on_windows
# Conflicts:
#	.github/scripts/trailing-newlines.sh
2020-03-23 18:44:11 -03:00
Damien Elmes
f429986246 fix collection_did_load() not being called, and remove dead code
https://anki.tenderapp.com/discussions/ankidesktop/39765-_colloadingstate-is-never-run-thus-collection_did_load-hook-is-never-triggered
2020-03-23 18:57:23 +10:00
Damien Elmes
7a4f3d0318 dump more info in card()/bcard() 2020-03-23 18:39:00 +10:00
Damien Elmes
55c9f5dbeb wait for media sync to complete before unloading collection 2020-03-20 21:15:23 +10:00
Damien Elmes
d03e13a1bd reuse the existing backend instead of creating a new one 2020-03-20 21:15:23 +10:00
Damien Elmes
ba17567617 drop the separate i18n backend 2020-03-20 21:15:23 +10:00
Damien Elmes
fa12213e98 move .reopen() to mw; fix exporting 2020-03-20 21:15:23 +10:00
Damien Elmes
0f38514ad7 drop the DB progress handler code
This code was an awful hack to provide some semblance of UI
responsiveness while executing DB statements on the main thread.
Instead, we can just run DB statements in a background thread now,
keeping the UI responsive.
2020-03-20 21:15:23 +10:00
Damien Elmes
32555b2857 run Check DB in a background thread
Since the DB is now stored behind a mutex, we're no longer limited
to accessing the database on the main thread.
2020-03-20 21:15:23 +10:00
Damien Elmes
6db4418f05 drop log= argument from Collection 2020-03-20 21:15:23 +10:00
Damien Elmes
f4d4078537 drop named sql arguments 2020-03-20 21:15:23 +10:00
Damien Elmes
0d43e9dca3 tweak add-on wording 2020-03-20 21:00:21 +10:00
Arthur Milchior
bfc305fa26 hook backup_is_done
I expect to use this hook in add-on 529955533. It'll serve me to
create long term backup at the same time than your backup
2020-03-19 13:21:00 +01:00
evandrocoan
1ade1a1a0f Fixed moved comment line on qt/aqt/main.py, long variables names on
pylib/Makefile and qt/Makefile, and rg --version not going to /dev/null
on .github/scripts/trailing-newlines.sh
2020-03-18 11:36:50 -03:00
evandrocoan
034ac10cf4 Fixed error: Incompatible types in assignment on qt/aqt/main.py
aqt\main.py:1437: error: Incompatible types in assignment (expression has type Module, variable has type "LibraryLoader[WinDLL]")  [assignment]
                _dummy = wintypes
                         ^
2020-03-17 19:48:16 -03:00
Arthur Milchior
5adbc33d4c hook debug_ran_hook 2020-03-06 15:01:22 +01:00
Arthur Milchior
3319b114de hook debug_will_show_hook 2020-03-06 15:01:02 +01:00
Damien Elmes
43f5d13ed6 migrate strings with trailing newlines to fluent 2020-02-27 20:36:40 +10:00
Alan Du
a63c9e5a9a Apply mypy improvements to aqt 2020-02-26 22:27:58 -05:00
Arthur Milchior
5ff1f3890f Add a hook to change empty cards to delete 2020-02-26 10:59:34 -08:00
Damien Elmes
49cda5ffbb rename aqt/media.py to mediacheck.py 2020-02-17 08:40:17 +10:00
Damien Elmes
6f158c8555 plug new media check in 2020-02-17 08:40:17 +10:00
Damien Elmes
d38c2c12d5 autosync media every ~15 minutes 2020-02-17 08:40:17 +10:00
Damien Elmes
12d009e503 autosync media on close 2020-02-17 08:40:17 +10:00
Damien Elmes
59a7993011 autosync media on startup 2020-02-17 08:40:17 +10:00
Damien Elmes
93c768cab9 move more logic into mediasync.py, handle auth errors 2020-02-17 08:40:16 +10:00
Damien Elmes
347ac80086 remove unused code 2020-02-17 08:40:16 +10:00
Damien Elmes
cb0ce4146f show spinner when media sync active, click to reveal dialog 2020-02-17 08:40:16 +10:00
Glutanimate
bbd667b0ff Add webview_will_set_content hook & update supporting code accordingly 2020-02-12 22:00:13 +01:00
Glutanimate
df2a7b06ef Refactor web view title setting and add titles to all web views
Simplifies debugging web views
2020-02-12 21:03:11 +01:00
Damien Elmes
af26922493 fix error when double-clicking open profile button
https://anki.tenderapp.com/discussions/ankidesktop/38670-bug-when-auto-sync-is-enabled-and-open-profile-button-is-double-clicked
2020-02-10 09:32:56 +10:00
Damien Elmes
7fcb6b5672 pass instance to webview_did_receive_js_message instead of string 2020-02-09 08:59:29 +10:00
Arthur Milchior
fc5c1fd16a correct missing french translation 2020-02-05 20:48:30 -08:00
Damien Elmes
5d91580ce2 add option to disable audio interrupting 2020-02-03 08:55:14 +10:00
Damien Elmes
f6ef553ba5 move strip_av_refs() into anki.sound 2020-01-24 15:48:40 +10:00
Damien Elmes
17ebdfc099 extract and flag AV tags as part of the render process
We can now show replay buttons for the audio contained in {{FrontSide}}
without having to play it again when the answer is shown.

The template code now always defers FrontSide rendering, as it wasn't
a big saving, and meant the logic had to be implemented twice.
2020-01-24 11:06:11 +10:00
Damien Elmes
406c58a109 inject legacy funcs referencing aqt in GUI load 2020-01-23 18:20:19 +10:00
Damien Elmes
7dcbc7efec basic night mode support
Forces the Fusion theme when running night mode, so we don't need
to work around platform themes that don't respond to the defined
palette.

Feedback/suggestions on the chosen colours welcome - _vars.scss is the
file to change if you want to experiment with adjustments.
2020-01-23 17:27:07 +10:00
Damien Elmes
cfa0f65311 add a hook for when playback begins 2020-01-22 14:41:32 +10:00
Damien Elmes
d54f719558 add a webview_did_receive_js_message hook 2020-01-22 11:06:12 +10:00
Damien Elmes
f92bb55c25 add option in prefs to hide replay audio buttons 2020-01-21 21:00:17 +10:00
Damien Elmes
d4d16d35a8 spawn a new slave mode mplayer for each file
This solves a few problems:

- We no longer need to write temporary files to disk, as files
passed on the command line with non-Latin text can be read by mplayer.
- We no longer need to deal with mplayer processes left around in
the background that have failed to terminate.
- We don't need to deal with the added complexity that comes with
polling mplayer's status output to determine when the file has finished
playing.

Also add seek_relative(), toggle_pause() and shutdown() as optional
methods on AVPlayer.
2020-01-21 08:55:15 +10:00
Damien Elmes
1beae4f858 pass task manager in instead of creating a new one 2020-01-21 06:49:09 +10:00
Damien Elmes
a6e6ffae06 get mpv slave mode working with new API
Also move the mpv-specific hooks into AVPlayer
2020-01-20 22:01:38 +10:00
Damien Elmes
707ac587ec rework the audio player API and add a simpler player implementation
- the new API operates on AVTags so it can support TTS as well as
audio files
- added a simple "run for each file" implementation for mpv and mplayer.
- will need to test handling of unicode filenames on Windows
- the old mpv and mplayer code is currently not active
2020-01-20 20:07:11 +10:00
Damien Elmes
09e47fbc36 check for add-on updates once a day 2020-01-19 11:31:09 +10:00
Damien Elmes
a47db0d609 add helper for background execution 2020-01-19 10:06:01 +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
237c0791f8 more hook tweaks, and merge the pre-render field and template hooks 2020-01-15 17:18:11 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
b2f756f1b7 tweak the hook names in anki/
still a work in progress
2020-01-15 16:43:22 +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
Damien Elmes
67a3223623 remove unused function 2020-01-15 12:17:29 +10:00
Damien Elmes
4bb3d7a958 add separate file for gui hooks 2020-01-13 14:38:05 +10:00
Damien Elmes
dd61389319 New type-safe approach to hooks/filters
Still todo:
- Add separate module for GUI hooks
- Update the remaining runHook/runFilter() calls
- Document the changes, including defensive registration
2020-01-13 13:57:51 +10:00
Glutanimate
7348e9c69e Further tweak messaging depending on Anki's state at installation time 2020-01-04 04:45:43 +01:00
Glutanimate
6a7f11b172 When possible, install add-on before add-ons are loaded
Removes the need to restart Anki if it is not running when
user launches .ankiaddon file
2020-01-04 04:34:16 +01:00
Glutanimate
54253e2108 Make sure to pass pending imports on to installAddon
also: refactor add-on check
2020-01-04 04:30:33 +01:00
Glutanimate
1b236acb3d Fix mypy and black checks 2020-01-03 18:23:28 +01:00
Glutanimate
e3b7096db5 Extend CLI with the ability to install .ankiaddon packages
Allows Anki to register a mime-type handler for .ankiaddon files

Other small collateral changes:

+ fix positioning issues with some prompts and progress dialog
+ add prompt titles where they were missing
+ add type annotations for AddonManager installation methods
+ explicitly import os in main (used to be imported via aqt.qt)
2020-01-03 17:57:33 +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