Commit Graph

1145 Commits

Author SHA1 Message Date
Henrik Giesel
89caa6ef75 Remove unnecessary import 2020-08-31 13:35:18 +02:00
Henrik Giesel
a1b5acd46a Fix type signature: models is passed because it's a method 2020-08-31 13:35:18 +02:00
Henrik Giesel
90f0df2a52 Remove duplicated buttons 2020-08-31 13:35:18 +02:00
Henrik Giesel
3287c42ace Don't import models in gui_hooks to avoid circular import 2020-08-31 13:35:18 +02:00
Henrik Giesel
ea787c73a5 Fix uninitialized buttons object 2020-08-31 13:35:18 +02:00
Henrik Giesel
633d769490 Add compiled hook model_did_init_buttons 2020-08-31 13:35:18 +02:00
Henrik Giesel
ad27e0149a Add usage in models.py 2020-08-31 13:35:18 +02:00
Henrik Giesel
0c3fad7386 Add unused add_button method 2020-08-31 13:33:59 +02:00
Damien Elmes
a517accee3 update to latest black 2020-08-31 13:29:28 +10:00
Damien Elmes
603210149c update to latest isort, pylint and pytest 2020-08-31 12:05:36 +10:00
Damien Elmes
20432ccecf fix new pylint raise-missing-from lint 2020-08-31 12:04:14 +10:00
ANH
9eb11b53d5 remove unicode isolation markers from add-on config editor title 2020-08-31 00:35:17 +03:00
Damien Elmes
3f403040db fix card.template() in card layout screen
https://forums.ankiweb.net/t/card-template-does-not-work-when-called-in-card-will-show-hook-in-template-editor/2798
2020-08-30 11:23:44 +10:00
Damien Elmes
3bd85bf180 add some names to about screen
a reminder that anyone who's contributed is welcome - please just
send a PR adding yourself
2020-08-27 11:24:13 +10:00
Damien Elmes
9aa3d7867e
Merge pull request #749 from ANH25/editor-media-autoplay
Only autoplay added media when recording in editor
2020-08-27 10:37:42 +10:00
Damien Elmes
c3a1acb524
Merge pull request #745 from ANH25/reviewer-context-menu-shortcut
add shortcut for reviewer context menu
2020-08-27 10:33:22 +10:00
ANH
28d86ab8d1 editor: only autoplay added media when recording 2020-08-26 14:49:19 +03:00
Damien Elmes
05efefeff9
Merge pull request #748 from ANH25/drag-and-drop
fix drag & drop issue when dropping things over existing content
2020-08-26 08:38:48 +10:00
Damien Elmes
2e328fd6cb formatting 2020-08-26 08:36:08 +10:00
Damien Elmes
5355c3c25e fix description in export screen (thanks to ANH)
https://forums.ankiweb.net/t/anki-2-1-31-exporting-display-bug/2669/3
2020-08-26 08:33:35 +10:00
ANH
cc17b4db62 fix drag & drop issue when dropping things over existing content 2020-08-25 17:28:13 +03:00
Damien Elmes
dee7d45d8b fix signup link 2020-08-25 13:29:02 +10:00
ANH
9cf07a98c2 add shortcut for reviewer context menu 2020-08-23 17:46:47 +03:00
Damien Elmes
2291f9a9fb 'cards' instead of 'notes' in export
thanks to hgiesel; closes #744
2020-08-23 13:48:20 +10:00
Damien Elmes
2a8a4e9780 fix formatting & lint 2020-08-21 12:36:18 +10:00
Damien Elmes
45fd52d49a
Merge pull request #735 from brownbat/master
Add hook for initializing answer buttons
2020-08-21 12:34:14 +10:00
Damien Elmes
b47654fed7 fix formatting 2020-08-21 11:45:14 +10:00
Damien Elmes
5d8c9c8948
Merge pull request #740 from kelciour/mpv-restart-fix
Fix no sound after restarting mpv
2020-08-21 11:10:46 +10:00
Damien Elmes
095df2f6f8
Add comment 2020-08-21 11:10:30 +10:00
kelciour
8cac607588 Reset av_player.current_player after mpv restart 2020-08-21 02:17:21 +03:00
Damien Elmes
75e721f4ad
Merge pull request #739 from ANH25/add-custom-study-ftl
Add custom-study-must-rename-deck to Fluent
2020-08-21 08:56:17 +10:00
Thomas B
c920dee638 Remove conflict- Sequence type no longer needed 2020-08-20 10:34:08 -04:00
Thomas B
fe6144ff61 Clarify docstring 2020-08-20 10:30:31 -04:00
Damien Elmes
290efb9e92 need to invalidate notetype cache on sync completion
basicCheck() was populating it on startup sync, leading to
https://forums.ankiweb.net/t/error-when-adding-a-new-note/1664
2020-08-20 15:35:23 +10:00
Thomas B
67e3f25ad1 Add both Union and Sequence to typing import
Resolve conflict.
2020-08-19 16:19:15 -04:00
Thomas B
73883f3f21 Update gui_hooks.py 2020-08-19 16:15:56 -04:00
Thomas B
897ec72608 Fixing type hints
Matched all type hints, changed the original Sequence[] type hint for _answerButtonList() in reviewer.py on mypy's recommendation.
2020-08-19 16:15:49 -04:00
ANH
94b80cfb94 add custom-study-must-rename-deck to Fluent 2020-08-19 18:27:14 +03:00
ANH
680b5e4b50 work around editor freeze issue after external drag & drop 2020-08-19 18:14:07 +10:00
Thomas B
649142e5b3 Update as part of previous commit 2020-08-18 10:38:59 -04:00
Thomas B
e92b0f8d63 Bugfix proposed filter post-testing
Mirrored filter more closely on _ReviewerWillAnswerCardFilter, including taking and returning the value to be modified.
2020-08-18 10:37:45 -04:00
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
Damien Elmes
06275478e0 close edit current window when card deleted
https://forums.ankiweb.net/t/bug-report-editor-updating-non-existing-card/2117
2020-08-17 20:07:48 +10:00
Damien Elmes
3d0d21e4bc fix duplicates not escaping html
https://forums.ankiweb.net/t/bug-report-showdupes-not-html-escaping-field-content/2167
2020-08-17 17:50:27 +10:00
Henrik Giesel
e3d01de2ba Reorder gui_hooks imports 2020-08-16 23:34:24 +02:00
Henrik Giesel
85d6145482 Add Union import 2020-08-16 19:11:11 +02: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
f1286a0ce3 Update signature of main_window_will_require_reset hook 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
Henrik Giesel
bff42d55db Add main_window_will_require_reset hook 2020-08-16 18:56:32 +02:00
Thomas B
7be08919e2 Add hook for initializing answer buttons 2020-08-14 13:52:20 -04:00
Arthur Milchior
ae078d4fd0 Search_model has context
I have an add-on which allow to open multiple windows. So would like to know which browser has done the search. This
would allow me to have browser with various setting. In particular, I've an add-on which allow to show a single line by
note, and I would like for some browser to have this feature on and for some other to have this feature off.
2020-08-13 19:46:14 +02:00
Arthur Milchior
c4db4bd291 Any removed 2020-08-12 01:37:21 +02:00
Arthur Milchior
c3b2b8625e NF: childMapNode 2020-08-12 00:42:42 +02:00
Damien Elmes
d079307536
Merge pull request #728 from hgiesel/mungehtml
Move "remove null bytes" and "reverse url formatting" functionality to editor_will_munge_html hook
2020-08-10 16:33:56 +10:00
Henrik Giesel
17f23221e4 Add newlines 2020-08-09 11:16:19 +02:00
Henrik Giesel
ee3d4f5ad8 Avoid extra assignment 2020-08-09 10:38:31 +02:00
Henrik Giesel
f5479edacc Move reverse url quoting functionality to editor_will_munge_html hook 2020-08-09 10:37:38 +02:00
Henrik Giesel
1b9bd70bb1 Move remove null bytes functionality to editor_will_munge_html hook 2020-08-09 10:35:52 +02:00
Damien Elmes
6a0faac407 deauth -> log out 2020-08-09 14:44:03 +10:00
Damien Elmes
fbdd72817e
Merge pull request #727 from hgiesel/mungehtml
Add editor_will_munge_html hook
2020-08-09 13:38:39 +10:00
Damien Elmes
44fd50facb make sure to reset after deleting empty cards
https://anki.tenderapp.com/discussions/private/5067-anki-was-unable-to-open-your-file
2020-08-09 12:42:58 +10:00
Damien Elmes
05e90bcd23 find/replace completer should be case sensitive
https://forums.ankiweb.net/t/bug-report-search-and-replace/2037
2020-08-09 12:10:34 +10:00
Henrik Giesel
4720645d1c Replace functionality of mungeHTML with call to new gui_hook 2020-08-08 23:59:01 +02:00
Henrik Giesel
7f9e560396 Add editor_will_munge_html hook 2020-08-08 23:27:58 +02:00
ANH
7dcd6abba9 add card layout save shortcut 2020-08-06 13:23:17 +03:00
Damien Elmes
2eee4cb04e avoid internal URLs in alert titlebar
https://forums.ankiweb.net/t/anki-stats-no-longer-displaying-invalid-data-found-please-use-check-database-to-fix-the-problem/1902
2020-08-06 09:50:12 +10:00
Damien Elmes
3019d0dfdf fix Windows packages failing to start 2020-08-06 09:05:26 +10:00
Damien Elmes
18c59c60a4 unnecessary f-string 2020-08-04 17:52:49 +10:00
Damien Elmes
440aa129d9 disable media get / posts when collection closed
https://forums.ankiweb.net/t/countdown-to-events-exams-addon-official-thread/1093/4?u=dae
2020-08-04 10:03:17 +10:00
Damien Elmes
d97f6d21b8 fix mobile class emulation
should be set on html element
2020-08-03 13:32:10 +10:00
Damien Elmes
d9b6793616 fix automatic logout on auth failure not working 2020-08-03 10:24:49 +10:00
Damien Elmes
2a36455e88 fix untyped def issues in aqt/utils.py 2020-08-02 10:25:48 +10:00
Damien Elmes
c1ecb7b827 fix untyped def issues in aqt/mediasrv.py 2020-08-02 10:22:21 +10:00
Damien Elmes
5c176b23c4 fix untyped def issues in aqt/__init__.py 2020-08-02 10:22:08 +10:00
Damien Elmes
0787a5d1da
Merge pull request #723 from phwoo/typehints-for-qt-addons
Typehints for qt addons
2020-08-02 10:08:48 +10:00
Fabian Wood
d27e33a206 Fixed runtime error from changes in qt addons.py
Changes to meet returning of Iterable (rather than List), meant
returning a different variable, but that may not have been created.
Reverted, changing to return List.
2020-08-01 17:50:37 +10:00
Fabian Wood
3da0737a57 Updated qt addons with more extensive typehints 2020-08-01 15:50:27 +10:00
Matt Krump
f529124bbf Turn on check_untyped_defs for aqt.progress 2020-07-31 21:00:08 -06:00
Matt Krump
83449e35ad Turn on check_untyped_defs for aqt.main 2020-07-31 20:34:14 -06:00
Damien Elmes
a8139ebb40 force stdout/stderr encoding to utf8
As a GUI app, Anki only uses these for debugging info, and we've been
bitten numerous times in the past by bugs caused by printing Unicode
when the console only supported ASCII. An ens var might have been
a better approach, but Pyinstaller does not support defining them before
Python is initialized from what I can tell.

Latest issue:
https://forums.ankiweb.net/t/crashing-anki-version-2-1-29-bbff62bf/1650
2020-08-01 11:31:22 +10:00
Damien Elmes
06a0b1ee73 pass night mode into body_class() instead of changing globally 2020-07-31 14:47:17 +10:00
Damien Elmes
e2425d3b0d remove 'invert', as night mode is on when checkbox is on 2020-07-31 14:35:18 +10:00
Damien Elmes
0ed50394e7
Merge branch 'master' into master 2020-07-31 14:14:10 +10:00
Damien Elmes
f497682e9b
Merge branch 'master' into help-wanted-4-add-type-hints-6 2020-07-31 14:07:59 +10:00
Damien Elmes
628d961ad6
Merge pull request #719 from ANH25/reviewer-hooks
Add reviewer_will_play_question_sounds and reviewer_will_play_answer_sounds hooks
2020-07-31 14:06:28 +10:00
Damien Elmes
e759e6ef83
Merge pull request #718 from phwoo/typehints-for-qt-profiles
Added typehints for qt profiles
2020-07-31 14:04:29 +10:00
Damien Elmes
0edb043f53 i18n some card template strings
https://forums.ankiweb.net/t/untranslated-strings/1623
2020-07-31 13:33:41 +10:00
Damien Elmes
cd72d6807a refresh tag list after clearing unused 2020-07-31 13:33:41 +10:00
ANH
9b0d509e74 just forgot to regenerate gui_hooks.py to fix typo 2020-07-31 04:47:31 +03:00
Matt Krump
10f2f9c037 Turn on check_untyped_defs for aqt.emptycards 2020-07-30 18:43:57 -06:00
Matt Krump
7d8f856060 Turn on check_untyped_defs for aqt.addons 2020-07-30 18:43:57 -06:00
Matt Krump
a56690bc08 Turn on check_untyped_defs for aqt.webview 2020-07-30 18:43:57 -06:00
ANH
b4604873c4 document hooks 2020-07-31 03:06:13 +03:00
ANH
b4b12f1642 add reviewer_will_play_question_sounds and reviewer_will_play_answer_sounds hooks 2020-07-30 22:20:19 +03:00
ANH
43620b0a30 use 'Preview Settings' as a label for the new options button 2020-07-30 18:04:50 +03:00
Fabian Wood
79e8076685 Added typehints for qt profiles
* `Any` used for pickle methods, this could probably be improved
with some kind of Callable
* str used for self.base, though this may be a problem for
different OSes. Some type of os.PathLike might be good.
* Line 75, type ignored: mypy was complaining about no. of args,
and kwargs there didn't seem to be needed. Separate issue to test,
though.
2020-07-31 00:56:48 +10:00
ANH
03a80e596a add night mode and mobile class toggles in card layout screen 2020-07-30 15:39:02 +03:00
Damien Elmes
215413ce25
Merge pull request #715 from phwoo/typehints-for-qt-modelchooser
Added typehints to qt/aqt/modelchooser.py, updated qt/mypy.ini
2020-07-30 17:00:58 +10:00
Damien Elmes
f52a25d80a
Merge branch 'master' into add-type-hints-for-qt-models 2020-07-30 16:05:55 +10:00
Fabian Wood
c4f9bf62fd added typehints to modelchooser, updated mypy.ini 2020-07-30 15:25:25 +10:00
Fabian Wood
e49a00fdeb added type hints to qt models 2020-07-30 13:28:52 +10:00
Adam Plaice
d6fb4acd38 Re-add previously supported file extensions for media
(They had been removed in 2ae342592c).
2020-07-29 15:08:33 +02:00
Damien Elmes
93ada5d374
Merge pull request #703 from ANH25/master
fix help-wanted#13
2020-07-29 14:14:57 +10:00
Damien Elmes
6d0d210130
Merge branch 'master' into help-wanted-4-add-type-hints-5 2020-07-29 13:56:57 +10:00
Damien Elmes
7e7f2d0be4 clearer message when template error is preventing save 2020-07-29 12:53:03 +10:00
Matt Krump
24e7156991 Turn on check_untyped_defs for aqt.editor
* Turn on check_untyped_defs for aqt.browser
* Add type hints
2020-07-28 18:42:22 -06:00
Damien Elmes
a239b9330d
Merge pull request #706 from mkrump/help-wanted-4-add-type-hints-4
Turn on check_untyped_defs for aqt.taglimit, aqt.update and aqt.browser
2020-07-28 13:16:49 +10:00
Damien Elmes
f45627dbd3 don't throw error on empty path
https://forums.ankiweb.net/t/anki-2-1-28-error-message-when-reviewing-cards/1439
2020-07-27 11:28:32 +10:00
Matt Krump
baa033bc78 Fix browser.py import sorting 2020-07-26 13:16:06 -06:00
Matt Krump
4239c2dfdc Cast set to list to fix mypy failure in browser.py 2020-07-26 13:00:06 -06:00
Damien Elmes
dbbdd16f0f apply AltGr workaround on qt 5.14 as well 2020-07-26 10:13:53 +10:00
Matt Krump
b5222f935d Turn on check_untyped_defs for aqt.browser
* Turn on check_untyped_defs for aqt.browser
* Add type hints to browser
2020-07-25 17:31:49 -06:00
Matt Krump
b2cbe10d7e Turn on check_untyped_defs for aqt.update
* Turn on check_untyped_defs for aqt.update
2020-07-25 17:31:44 -06:00
Matt Krump
7356756868 Turn on check_untyped_defs for aqt.taglimit
* Add type hints taglimit
* Turn on check_untyped_defs for aqt.taglimit
2020-07-25 15:45:31 -06:00
ANH
671b1c76cb
Merge branch 'master' into master 2020-07-25 05:24:45 +03:00
Damien Elmes
b3ec8046bf
Merge branch 'master' into help-wanted-4-add-type-hints-3 2020-07-25 11:43:46 +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
Matt Krump
186f1c7720 Add type hints to errors
* Add type hints to errors
* Turn on type checking for aqt.errors
2020-07-24 11:20:54 -06:00
Matt Krump
b0dd85f87e Add type hints to aqt.models
* Add type hints to aqt.models
* Turn on type checking for aqt.models
2020-07-24 10:59:45 -06:00
ANH
fd0c3cf57e add missing string r flag 2020-07-24 09:18:05 +03:00
ANH
da3761341e formatting 2020-07-24 09:00:34 +03:00
ANH
e122534ba4 avoid string concatenation 2020-07-24 08:12:46 +03:00
Matt Krump
b3b4d23f9d Add type hints for apt.deckconf
* Add type hints for apt.deckconf
* Turn on check_untyped_defs for apt.deckconf
2020-07-23 21:53:12 -06:00
ANH
eaf935c3ff fix ankitects/help-wanted#13 2020-07-24 06:00:55 +03:00
Damien Elmes
61e8611b7b fix lint issue in previewer, and drop unused code
No add-ons appear to be using the removed code, and Anki wasn't
using it either.
2020-07-24 12:18:37 +10:00
Damien Elmes
2cba721702 formatting and debug statement tweak 2020-07-24 11:57:37 +10:00
Damien Elmes
26426cb11e fix preview not updating on edit
https://forums.ankiweb.net/t/modification-and-preview/1331
2020-07-24 11:57:22 +10:00
Damien Elmes
c3266ea060 enable AltGr workaround by default
5.15.1 may still be another month away
2020-07-24 10:32:50 +10:00
Damien Elmes
80a2bfa642 ask user to check db when graphs fail to load 2020-07-24 09:56:28 +10:00
Damien Elmes
ad628d0f36
Merge pull request #702 from mkrump/help-wanted-4-add-type-hints
Add type hints for apt.dyndeckconf
2020-07-24 09:01:07 +10:00
Matt Krump
4bc98cd0ca Add type hints for apt.dyndeckconf
* Add type hints for apt.dyndeckconf
* Turn on check_untyped_defs for apt.dyndeckconf
2020-07-23 16:04:46 -06:00
kelciour
f2027cca96 Add --no-autoload-files option to mpv 2020-07-23 14:28:47 +03:00
Damien Elmes
2ff1a27b04 fix misaligned deck heading in RTL languages
https://forums.ankiweb.net/t/anki-2-1-29-beta/1220/2?u=dae
2020-07-22 11:00:39 +10:00
Damien Elmes
1b441f5050 fix pylint failing in CI 2020-07-21 16:16:34 +10:00
Damien Elmes
86fc7446b0 protect against exception on initial recording wait 2020-07-21 16:07:58 +10:00
Damien Elmes
3337c96fdb trigger recording permission on newer macOS SDKs 2020-07-21 15:54:04 +10:00
Damien Elmes
1e6a37e0e6 formatting 2020-07-21 14:17:56 +10:00
Damien Elmes
01ff6ab55d apply rtl dir to webviews
https://forums.ankiweb.net/t/gui-problems-with-right-to-left-languages/1205
2020-07-21 11:52:25 +10:00
Damien Elmes
b5cbfe3bbb full sync terminates media sync; start it again afterwards
https://forums.ankiweb.net/t/media-files-not-downloaded-in-first-full-sync-v2-1-28/1198/3
2020-07-21 11:26:41 +10: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
c203410307 split add-ons window title from menu bar action
https://anki.tenderapp.com/discussions/private/4781-print-mistake
2020-07-19 09:49:36 +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
f741b05f56
Merge pull request #690 from glutanimate/stats-will-show-hooks
Add a couple of hooks to trigger add-on actions before showing stats
2020-07-17 14:38:41 +10:00
Glutanimate
0fedf5c825 Fix type annotation for old stats dialog class 2020-07-17 03:08:09 +02:00
Glutanimate
b89811bfba Add a couple of hooks to trigger add-on actions before showing stats 2020-07-16 21:48:46 +02:00
Glutanimate
fe81da9b8a Make sure to set domDone to False before loading URLs
Fixes an issue where JS would be evaluated prematurely in views
directly loaded from URLs.
2020-07-16 19:56:57 +02:00
Damien Elmes
2824be25f0 formatting 2020-07-16 13:55:53 +10:00
Damien Elmes
fa239be124 add platform version back into sync metadata 2020-07-16 10:12:41 +10:00
Damien Elmes
320b56ae43 can't rely on stdout to handle unicode 2020-07-15 09:36:29 +10:00
Damien Elmes
eb91ff7421
Revert "Added parameter/return types, fixed possible logic error and typo" 2020-07-13 21:25:44 +10:00
Damien Elmes
5c6ca55e42
Merge pull request #686 from zerrs/master
Added parameter/return types, fixed possible logic error and typo
2020-07-13 21:25:16 +10:00
Damien Elmes
2af1d68b05
Update customstudy.py 2020-07-13 21:24:18 +10:00
Damien Elmes
c3800b6f9a
Merge pull request #684 from flagist0/select-note-type-with-ctrl-plus-digit-key
Allow to choose note type from list by pressing ctrl + row number
2020-07-13 21:23:35 +10:00
Alexander Presnyakov
364725a528 Don't call setCurrentRow if row didn't change 2020-07-13 12:33:36 +03:00
zzzz
d6d952d0fd Added some return and parameter types in customstudy.py, also fixed a possible logic error in plus function and a small typo 2020-07-13 01:32:08 -04:00
kelciour
ef1d61e35c Scroll media sync log to the last line 2020-07-13 03:06:44 +03:00
Alexander Presnyakov
e092dadc9a Allow to choose note type from list by pressing ctrl + row number 2020-07-12 22:15:58 +03:00
Damien Elmes
bc5b6dfb63 mediasrv symlink fix
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/39
2020-07-11 10:53:41 +10:00
Glutanimate
15fd3a4856 Add top_toolbar_did_redraw hook
Notifies add-ons of the top toolbar being redrawn
2020-07-10 17:38:40 +02:00
Damien Elmes
93425be839 formatting 2020-07-07 13:28:30 +10:00
Damien Elmes
85cbd263da tidy up logging 2020-07-07 10:50:12 +10:00
Damien Elmes
4ab9d04c95 if webexports does not match, return 403 2020-07-07 10:50:03 +10:00
evandrocoan
121725390d Fix _addons/ URL prefix not being removed on Windows systems
Anki 2.1.28 Beta
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/26

> Did the requirements on how to expose resources on the internal server change? Because scripts, css files and the like, registered with setWebExports, do not work anymore with beta2.
> A look at the console shows the following for all resources:
> Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)

**\Anki2\addons21\someaddon\__init__.py**
```py
from aqt import mw
import aqt

# assuming add-on folder is named "test"
# and assuming a 'test.js' is in the same folder
addon_id = "someaddon"
port = mw.mediaServer.getPort()
mw.addonManager.setWebExports(addon_id, ".*\\.js$")

print("Hello")

aqt.editor._html += f"""
<script>
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://127.0.0.1:{port}/_addons/{addon_id}/test.js';
    document.body.appendChild(script);
</script>"""
```
2020-07-06 13:51:37 -03:00
Andreas Reis
e8ddd17fec Always use standard QT color dialog on Linux
On Linux only Gnome uses its own color dialog, and it's inferior to QT's own: See the same issue @ https://github.com/OpenShot/openshot-qt/pull/2425

(This is/was visible only on some distributions' packaged versions of Anki, not via ./run.)

isLin check since QT on Windows already uses the default, whereas Mac's own picker seems superior (from what I can judge by screenshots).
2020-07-05 13:21:38 +02:00
Damien Elmes
4033f00988 don't stuff mw into function objects
Using the global is preferable to fighting against mypy to insert mw
into a function object.
2020-07-03 10:55:29 +10:00
Damien Elmes
14602be0ca port previous css workaround to flask 2020-07-03 10:40:23 +10:00
Damien Elmes
e45c939649
Merge pull request #554 from evandroforks/fix_html5_media_support
Fixed HTML5 media tags
2020-07-03 10:25:43 +10:00
evandrocoan
476b881987 Replaced flask.Response by flask.make_response to simplify the
implementation and because make_response is preferred over Response
as it respects the server defined Response type.
2020-07-02 20:39:03 -03:00
evandrocoan
a99e455414 Removed duplicated mediasrv.py security check and fixed invalid
command/path error message.
2020-07-02 20:39:03 -03:00
evandrocoan
1218d109e8 Fix jest unit tests after merge
# Conflicts:
#	qt/aqt/mediasrv.py
#	qt/ts/src/ankimedia.ts
#	qt/ts/src/reviewer-exceptions.test.ts
#	qt/ts/src/reviewer.test.ts
#	ts/package.json
2020-07-02 14:30:43 -03:00
evandrocoan
0142ac3ca2 Replaced send_from_directory by send_file to simplify the code 2020-07-02 13:52:07 -03:00
evandrocoan
1e6fa5f8eb Ensure protection against directory transversal
https://security.openstack.org/guidelines/dg_using-file-paths.html
2020-07-02 13:52:03 -03:00
evandrocoan
be10da58d9 Fixed aqt/mediasrv.py:14: error: unused 'type: ignore' comment
from waitress.server import create_server  # type: ignore
https://github.com/evandroforks/anki/runs/743801391#step:25:1129
2020-07-02 13:51:59 -03:00
evandrocoan
020415efb9 Replaced the mediasrv.py SimpleHttp server by flask and waitress,
fixing HTML5 media support.
https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime
https://stackoverflow.com/questions/21956683/enable-access-control-on-simple-http-server
https://stackoverflow.com/questions/5052635/what-is-relation-between-content-length-and-byte-ranges-in-http-1-1
https://stackoverflow.com/questions/16725907/google-app-engine-serving-mp3-for-audio-element-needs-content-range-header

I was trying to use HTML5 audio tag to display audios like:
```html
<audio id="elem_audio" src="myfile.mp3" controls></audio>
```
![image](https://user-images.githubusercontent.com/5332158/79063321-565b5500-7c77-11ea-9f8d-6e1df6f07892.png)

But the progress bar seek was not working. After researching, I found the problem was the HTML server not properly responding to the HTML5 header requests. The HTML server should respond to quite complicated things as 206 partial, properly handle keep-alive, provide media ranges and other HTTP headers: https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime

To implement all these on the Simple HTTP server would be quite complicated. Then, instead, I imported the `flask` web server, which is quite simple and straight forward to use. Now, the back-end is using a secure complaint HTTP back-end:
1. https://palletsprojects.com/p/flask/
    > Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.
    >
    > Flask offers suggestions, but doesn't enforce any dependencies or project layout. It is up to the developer to choose the tools and libraries they want to use. There are many extensions provided by the community that make adding new functionality easy.

1. https://docs.pylonsproject.org/projects/waitress/en/latest/
    > Waitress is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in the Python standard library. It runs on CPython on Unix and Windows under Python 2.7+ and Python 3.5+. It is also known to run on PyPy 1.6.0 on UNIX. It supports HTTP/1.0 and HTTP/1.1.

Right now, anki does not support fields passing file names directly to HTML audio tags, but this can be easily done with (https://github.com/ankitects/anki/pull 540 - Added arguments to the sound tag) plus the commit 826a97df61, the HTML5 audio tag can be used like this:
```html
// Audio = [sound:myfile.mp3|onlyfilename]
<audio id="elem_audio" src="{{Audio}}" controls controlsList="nodownload"></audio>
```
![image](https://user-images.githubusercontent.com/5332158/79063736-c539ad80-7c79-11ea-8420-40b72185f4e7.png)

# Conflicts:
#	qt/aqt/mediasrv.py
2020-07-02 13:51:49 -03:00
Damien Elmes
48b6510aef dump error on profile load fail
may help diagnose
https://forums.ankiweb.net/t/i-couldnt-open-anki-resetting-corrupt-global/190
2020-07-02 10:35:01 +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
4d23a69e9a formatting 2020-07-01 14:01:24 +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
05fb67d409 show clearer error when media db locked
should not happen frequently during a sync, but may happen during
the initial change checking stage

https://forums.ankiweb.net/t/error-when-adding-audio-file/495/2
2020-07-01 11:19:06 +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
101deb002b graphs now work in night mode 2020-06-30 16:23:46 +10:00
Damien Elmes
f3febea4b0 update edited/changed column labels
https://github.com/ankitects/anki/pull/674/files
2020-06-29 18:34:03 +10:00
Damien Elmes
52cd9fc4b8 plug new graphs code into GUI
Still some work to do. Feedback welcome!
2020-06-29 15:53:56 +10:00
Damien Elmes
d4cd4535e6 lint fixes 2020-06-29 15:53:56 +10:00
Damien Elmes
72609bee18 add option to webview to skip external browser open 2020-06-29 15:48:01 +10:00
Damien Elmes
41d77b0255 get i18n working in typescript 2020-06-29 15:48:01 +10:00
Damien Elmes
329186f140 qt's js code now shares ts/node_modules; more graph work 2020-06-29 15:48:01 +10:00
Damien Elmes
dcff5e28fa add top level component and pass search/day limit back from frontend 2020-06-29 15:48:00 +10:00
Damien Elmes
82568a1f3e experiment with exposing raw card/revlog data to frontend 2020-06-29 15:48:00 +10:00
Damien Elmes
35975b142b
Merge pull request #675 from kelciour/mpv-changes-2
A few mpv changes 2
2020-06-29 15:47:09 +10:00
kelciour
696f7e4373 Fix "make check" by defining dummy _register_callbacks method in MPVBase 2020-06-27 13:07:46 +03:00
kelciour
d1b74dfcb6 Fix no sound after mpv restart 2020-06-27 03:46:40 +03:00
kelciour
422e313c16 Replace mpv "idle" property with "end-file" event 2020-06-27 03:46:40 +03:00
kelciour
610f9eb236 Replace default mpv quit keybindings if mpv version is >= 0.30
4614d432a8
2020-06-27 03:46:40 +03:00
neitrinoweb
69f73b57e7 add type hints 2020-06-25 17:27:52 +03:00
neitrinoweb
c7db6331cf fix missing typing import 2020-06-25 16:53:24 +03:00
Damien Elmes
5e5dc517ca work around yet another qt bug
https://anki.tenderapp.com/discussions/beta-testing/2017-httpsforumsankiwebnettrestore-defaults-config-not-visually-updated420
2020-06-24 11:12:45 +10:00
Damien Elmes
ef55c0a2ee remove the script-message commands that older mpv version don't support
https://github.com/ankitects/anki/pull/671#issuecomment-647798343
2020-06-23 14:30:42 +10:00
Damien Elmes
c3e007f069 remove mpv keybindings on init
On a machine here, they cause the following error:

    raise MPVCommandError("%r: %s" % (message["command"], e))
aqt.mpv.MPVCommandError: ['keybind', 'q', 'stop']: invalid parameter
2020-06-22 13:22:57 +10:00
Damien Elmes
f24321dc65
Merge pull request #671 from kelciour/mpv-changes
A few mpv changes
2020-06-22 12:12:58 +10:00
Damien Elmes
2cd86f38f4
Merge pull request #670 from evandroforks/print_version
Create the command line argument -v/--version to print version
2020-06-22 12:06:18 +10:00
kelciour
678b751010 Reset pause mode when switching to the next file 2020-06-20 02:04:35 +03:00
kelciour
d64c26f20a Replace deprecated "idle" event with "idle-active" property 2020-06-20 02:04:35 +03:00
kelciour
9aee8085e0 Disable OSC idle message 2020-06-20 02:04:34 +03:00
kelciour
ae533fce71 Replace default mpv "quit" keybindings with "stop"
https://github.com/mpv-player/mpv/blob/master/etc/input.conf
2020-06-20 02:04:34 +03:00
evandrocoan
9867e5e1f7 Create the command line argument -v/--version to print version
https://forums.ankiweb.net/t/i-couldnt-open-anki-resetting-corrupt-global/190
2020-06-19 13:13:10 -03:00
Arthur Milchior
3eabe4c3f7 Strip name of added deck
There is currently what I believe to be a bug: create a deck "   ".
The creation is accepted and the name is renamed to "blank". Instead,
I believe you'd want to strip the deck name before testing its
emptiness.
2020-06-17 11:58:33 +02:00
Damien Elmes
b51f03085e migrate card stats to backend
Currently this renders the HTML directly like the previous Python
implementation - doing it in JS would probably make more sense in the
future.
2020-06-15 17:22:16 +10:00
Damien Elmes
2845941a28
Merge pull request #667 from BlueGreenMagick/refresh-deck-list
refresh deck list when adding deck via deckchooser
2020-06-12 09:12:51 +10:00
Damien Elmes
9e0494047e
Merge pull request #666 from BlueGreenMagick/studydeck-name
get deck name after adding deck
2020-06-12 09:12:21 +10:00
Damien Elmes
8f36a0fbb0
Merge pull request #665 from BlueGreenMagick/remove-a-var
Add type hints to deckchooser
2020-06-12 09:11:54 +10:00
Damien Elmes
37bf56c56e
remove ellipsis 2020-06-12 09:04:19 +10:00
BlueGreenMagick
e3889d49c9 add typehint to deckchooser.py
every occurunce of self.widget is type ignored
because QHBoxLayout has a method named widget
renaming this property will allow type hints
2020-06-11 14:19:36 +09:00
BlueGreenMagick
20da11f57e refresh deck list when adding deck via deckchooser 2020-06-11 13:00:10 +09:00
BlueGreenMagick
4e6ba4df78 get deck name after adding deck 2020-06-11 12:50:17 +09:00
BlueGreenMagick
552db2b94d remove self.deck set to mw.col as it isn't used 2020-06-11 11:59:27 +09:00
Quentin Nerden
86713d110e
Update message to match gui
The Change Note Type... command is under the Notes menu, not the Edit menu
2020-06-09 11:49:47 +02:00
Damien Elmes
f44597bb3a
Merge pull request #650 from evandroforks/remember_last_inputs
Remember last inputs for Find and Replace and Duplicates Find
2020-06-09 14:43:58 +10:00
Damien Elmes
3275aff335
Merge pull request #662 from gaul/screen/none
Handle None from QApplication.desktop().screen()
2020-06-09 14:42:59 +10:00
Damien Elmes
30a8d3260b
Merge pull request #655 from Arthur-Milchior/history_line
History line
2020-06-09 14:42:45 +10:00
Damien Elmes
62ab2ed36d remove unused import 2020-06-09 14:14:12 +10:00
Damien Elmes
1aaf1059b4 formatting 2020-06-09 14:07:39 +10:00
Damien Elmes
c77d017135 catch invalid regex in search
https://github.com/ankitects/anki/pull/652
2020-06-09 11:46:07 +10:00
Damien Elmes
43da12a445 (un)escape image references in HTML editor to fix ampersand handling
https://anki.tenderapp.com/discussions/ankidesktop/41479-image-names-with-are-breaking
2020-06-09 11:22:07 +10:00
Andrew Gaul
e366b86af2 Handle None from QApplication.desktop().screen()
This prevents a crash when Anki is open for multiple days.  Reference:
https://anki.tenderapp.com/discussions/ankidesktop/41879-qt-cannot-create-window-no-screens-available
2020-06-09 09:57:35 +09:00
Damien Elmes
5f2987d0f8 allow input.conf in Anki data folder
https://anki.tenderapp.com/discussions/beta-testing/1964-anki-2128-alpha#comment_48382756
2020-06-09 10:26:25 +10:00
Damien Elmes
4033f6d37e fix mistaken qconnect replacement 2020-06-09 10:20:16 +10:00
Damien Elmes
20ee0a8b1b fix 'NoneType' object has no attribute 'latest_progress'
https://anki.tenderapp.com/discussions/beta-testing/1964-anki-2128-alpha#comment_48382636
2020-06-09 09:07:41 +10:00
evandrocoan
947f58032f Moved the utils.py new save/restore functions together 2020-06-08 16:23:32 -03:00
evandrocoan
38fba41fb2 Renamed save_combo_index to save_combo_index_for_session 2020-06-08 16:23:28 -03: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
7c444b4d35 add progress to db check 2020-06-08 21:07:36 +10:00
evandrocoan
1d32873869 Renamed new function on qt/aqt/utils.py to snake case 2020-06-08 01:35:31 -03:00
evandrocoan
b23b404f68 Created the profiles.py session attribute for things to forgot
each time Anki restarted and set to only fill the find and replace
dialogs when they were filled on the actual session.
2020-06-08 01:35:31 -03:00
evandrocoan
4bc895f7df Moved restoreComboHistory below saveComboHistory as others 2020-06-08 01:35:31 -03:00
evandrocoan
87d051fa71 Set to browser.py finddupes.ui remember the last selected field
https://anki.tenderapp.com/discussions/ankidesktop/39468-find-and-replace-does-not-remember-the-input-from-last-time
2020-06-08 01:35:31 -03:00
evandrocoan
bf55ebbd8a Added some type checking to utils.py QComboBox restore functions
# Conflicts:
#	qt/aqt/utils.py
2020-06-08 01:35:31 -03:00
evandrocoan
f27ad0c524 Moved restoreComboHistory closer to restoreComboIndex on utils.py 2020-06-08 01:35:31 -03:00
evandrocoan
6047c6ecc0 Renamed setupComboBoxHistory to restoreComboHisotory,
saveComboActiveIndex to saveComboIndex, saveComboBoxHistory to
saveComboHistory and restoreComboActiveIndex to restoreComboIndex.
2020-06-08 01:35:31 -03:00
evandrocoan
a78b3d522e Set to browser.py finddupes.ui remember the last search text
https://anki.tenderapp.com/discussions/ankidesktop/39468-find-and-replace-does-not-remember-the-input-from-last-time
2020-06-08 01:35:31 -03:00
evandrocoan
a74e43a515 Set to browser.py findreplace.ui remember the last selected field
by creating saveComboActiveIndex and restoreComboActiveIndex.

https://anki.tenderapp.com/discussions/ankidesktop/39468-find-and-replace-does-not-remember-the-input-from-last-time
2020-06-08 01:35:31 -03:00