Commit graph

1162 commits

Author SHA1 Message Date
Damien Elmes
c6f8854ec8 Revert "Added parameter/return types, fixed possible logic error and typo" 2020-07-13 21:25:44 +10:00
Damien Elmes
9a3a96e599 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
178a8fb29e Update customstudy.py 2020-07-13 21:24:18 +10:00
Damien Elmes
35494414cc 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
98238e1707 Don't call setCurrentRow if row didn't change 2020-07-13 12:33:36 +03:00
zzzz
f6c0560660 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
6ca239a247 Scroll media sync log to the last line 2020-07-13 03:06:44 +03:00
Alexander Presnyakov
3ccc6ce61a Allow to choose note type from list by pressing ctrl + row number 2020-07-12 22:15:58 +03:00
Damien Elmes
4e1bc76596 mediasrv symlink fix
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/39
2020-07-11 10:53:41 +10:00
Glutanimate
ee8696cbf3 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
6e07ab64af formatting 2020-07-07 13:28:30 +10:00
Damien Elmes
a2b4160d60 tidy up logging 2020-07-07 10:50:12 +10:00
Damien Elmes
c5f36ccf08 if webexports does not match, return 403 2020-07-07 10:50:03 +10:00
evandrocoan
af731fa739 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
3628011599 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
85dd611b72 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
17f80e4a7a port previous css workaround to flask 2020-07-03 10:40:23 +10:00
Damien Elmes
d1253bbfa0 Merge pull request #554 from evandroforks/fix_html5_media_support
Fixed HTML5 media tags
2020-07-03 10:25:43 +10:00
evandrocoan
f96e090b72 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
6c5311417f Removed duplicated mediasrv.py security check and fixed invalid
command/path error message.
2020-07-02 20:39:03 -03:00
evandrocoan
2de914267b 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
3ae83a0ec3 Replaced send_from_directory by send_file to simplify the code 2020-07-02 13:52:07 -03:00
evandrocoan
9bd8e494b3 Ensure protection against directory transversal
https://security.openstack.org/guidelines/dg_using-file-paths.html
2020-07-02 13:52:03 -03:00
evandrocoan
11183ac1f3 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
7033329012 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
f093acc0e8 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
313b40f836 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
67cde145b1 add new strings to .po files as part of template update
Pontoon appears to only update existing gettext translations; it
won't add new ones on its own. Fixes
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/6
2020-07-02 10:03:39 +10:00
Damien Elmes
a5e78485f4 fix scrollbars on fields on Windows/Linux 2020-07-02 09:51:50 +10:00
Damien Elmes
4e7ae0969f formatting 2020-07-01 14:01:24 +10:00
Damien Elmes
c5ef40e5ec don't allow table inside field to extend outside of field
https://anki.tenderapp.com/discussions/private/4498-adjust-textbox-geometry-in-add-note-window
2020-07-01 12:13:04 +10:00
Damien Elmes
ed4c74ca4d 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
9bb45673a8 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
c61f52d871 shift+click on the graphs button to access old graphs for now 2020-06-30 20:07:46 +10:00
Damien Elmes
6ad4111723 graphs now work in night mode 2020-06-30 16:23:46 +10:00
Damien Elmes
33317d41b3 update edited/changed column labels
https://github.com/ankitects/anki/pull/674/files
2020-06-29 18:34:03 +10:00
Damien Elmes
78fbaf7724 plug new graphs code into GUI
Still some work to do. Feedback welcome!
2020-06-29 15:53:56 +10:00
Damien Elmes
06d9f64dea lint fixes 2020-06-29 15:53:56 +10:00
Damien Elmes
d3feb931ba add option to webview to skip external browser open 2020-06-29 15:48:01 +10:00
Damien Elmes
94f75f0728 include generated js in aqt_data 2020-06-29 15:48:01 +10:00
Damien Elmes
349eca843b get i18n working in typescript 2020-06-29 15:48:01 +10:00
Damien Elmes
0293f2220c qt's js code now shares ts/node_modules; more graph work 2020-06-29 15:48:01 +10:00
Damien Elmes
27ac65418c update qt ts to prettier 2.0 2020-06-29 15:48:01 +10:00
Damien Elmes
93e1b907ba add top level component and pass search/day limit back from frontend 2020-06-29 15:48:00 +10:00
Damien Elmes
1e9901e9bd experiment with exposing raw card/revlog data to frontend 2020-06-29 15:48:00 +10:00
Damien Elmes
cfb76f8305 Merge pull request #675 from kelciour/mpv-changes-2
A few mpv changes 2
2020-06-29 15:47:09 +10:00
kelciour
66d69c3460 Fix "make check" by defining dummy _register_callbacks method in MPVBase 2020-06-27 13:07:46 +03:00
kelciour
39eec24c3d Fix no sound after mpv restart 2020-06-27 03:46:40 +03:00
kelciour
7518597408 Replace mpv "idle" property with "end-file" event 2020-06-27 03:46:40 +03:00
kelciour
88103d29cf Replace default mpv quit keybindings if mpv version is >= 0.30
4614d432a8
2020-06-27 03:46:40 +03:00
neitrinoweb
460ac4165d add type hints 2020-06-25 17:27:52 +03:00
neitrinoweb
4d9fe86b3c fix missing typing import 2020-06-25 16:53:24 +03:00
Damien Elmes
f38c9b4272 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
3396dc3d18 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
4d16dc243d 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
8e73b77476 Merge pull request #671 from kelciour/mpv-changes
A few mpv changes
2020-06-22 12:12:58 +10:00
Damien Elmes
b43096c535 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
fa635cfe17 Reset pause mode when switching to the next file 2020-06-20 02:04:35 +03:00
kelciour
1283e48603 Replace deprecated "idle" event with "idle-active" property 2020-06-20 02:04:35 +03:00
kelciour
ce3d3a3633 Disable OSC idle message 2020-06-20 02:04:34 +03:00
kelciour
ba9c4a5175 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
5d166f990d 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
7319ab8231 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
f5694a7e4a 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
fc99306d22 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
e0e9b91b92 Merge pull request #666 from BlueGreenMagick/studydeck-name
get deck name after adding deck
2020-06-12 09:12:21 +10:00
Damien Elmes
91fb5c1658 Merge pull request #665 from BlueGreenMagick/remove-a-var
Add type hints to deckchooser
2020-06-12 09:11:54 +10:00
Damien Elmes
154ee7a962 remove ellipsis 2020-06-12 09:04:19 +10:00
BlueGreenMagick
c824d45b2e 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
512a9afed6 refresh deck list when adding deck via deckchooser 2020-06-11 13:00:10 +09:00
BlueGreenMagick
5aa0addca2 get deck name after adding deck 2020-06-11 12:50:17 +09:00
BlueGreenMagick
d1b3897f86 remove self.deck set to mw.col as it isn't used 2020-06-11 11:59:27 +09:00
Quentin Nerden
a3e4449ec7 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
ef5f37efef 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
43fae1cede Merge pull request #662 from gaul/screen/none
Handle None from QApplication.desktop().screen()
2020-06-09 14:42:59 +10:00
Damien Elmes
4e6dbd471c Merge pull request #655 from Arthur-Milchior/history_line
History line
2020-06-09 14:42:45 +10:00
Damien Elmes
87fcaf9bfe remove unused import 2020-06-09 14:14:12 +10:00
Damien Elmes
7a035a7bfa formatting 2020-06-09 14:07:39 +10:00
Damien Elmes
6d7be475e6 catch invalid regex in search
https://github.com/ankitects/anki/pull/652
2020-06-09 11:46:07 +10:00
Damien Elmes
8d3b2aa88f (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
00ca676df5 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
446577d694 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
d62ba1e713 fix mistaken qconnect replacement 2020-06-09 10:20:16 +10:00
Damien Elmes
62307a6651 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
66c9afa031 Moved the utils.py new save/restore functions together 2020-06-08 16:23:32 -03:00
evandrocoan
650d7ddb8b Renamed save_combo_index to save_combo_index_for_session 2020-06-08 16:23:28 -03:00
Arthur Milchior
f9b0f6e7b3 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
75471224fa add progress to db check 2020-06-08 21:07:36 +10:00
evandrocoan
5949f2b7cc Renamed new function on qt/aqt/utils.py to snake case 2020-06-08 01:35:31 -03:00
evandrocoan
a4aa0672e0 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
d2323e4448 Moved restoreComboHistory below saveComboHistory as others 2020-06-08 01:35:31 -03:00
evandrocoan
b351a41f6c 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
9dbbb65570 Added some type checking to utils.py QComboBox restore functions
# Conflicts:
#	qt/aqt/utils.py
2020-06-08 01:35:31 -03:00
evandrocoan
efa8214d8f Moved restoreComboHistory closer to restoreComboIndex on utils.py 2020-06-08 01:35:31 -03:00
evandrocoan
3c8d6eb802 Renamed setupComboBoxHistory to restoreComboHisotory,
saveComboActiveIndex to saveComboIndex, saveComboBoxHistory to
saveComboHistory and restoreComboActiveIndex to restoreComboIndex.
2020-06-08 01:35:31 -03:00
evandrocoan
bada70a7d6 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
074be2bfb5 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
evandrocoan
7095eb41a2 Set to browser.py findreplace.ui remember the last regex/case
by creating the saveIsChecked and restoreIsChecked.

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
8c2cd37501 Created the setupComboBoxHistory and saveComboBoxHistory to remove
duplicated/common code.
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
fc4a3b85cf Set to remember the last replace input for findreplace.ui
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
c27c5a523d Set to remember the last find input for findreplace.ui
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
Damien Elmes
7f54af3d73 Merge pull request #660 from brownbat/tooltip-positioning
Update tooltip() in utils.py
2020-06-08 11:40:43 +10:00
Damien Elmes
919adf0d04 Merge pull request #659 from BlueGreenMagick/paste-typehint
add type hint to paste-related functions
2020-06-08 11:32:16 +10:00
Damien Elmes
3967dd9b78 Merge pull request #657 from BlueGreenMagick/prof-name
don't allow addons21 as profile name
2020-06-08 11:30:27 +10:00
Damien Elmes
2bb93e42c6 pin legacy modules
https://anki.tenderapp.com/discussions/ankidesktop/42248-potentially-serious-image-issue#comment_48388863
2020-06-08 11:12:51 +10:00
Thomas B
6bbddb9639 Update tooltip() in utils.py
Allow x,y offsets to be specified for tooltip(), useful for accomodating longer tooltips.
2020-06-07 16:06:23 -04:00
BlueGreenMagick
9029ea735c add type hint to paste-related functions 2020-06-07 12:06:11 +09:00
BlueGreenMagick
1be62f8cc5 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
c5e65d02e1 add note/card removal to backend 2020-06-04 18:21:04 +10:00
Damien Elmes
80987a34ab add .count() to hooks, and list->sequence in note deletion 2020-06-04 18:20:03 +10:00
evandrocoan
0ca8cd4e4d Add missing quotes to typecheck-setup.sh for paths with spaces on
the name.
2020-06-02 21:37:58 -03:00
Damien Elmes
86689c5e77 more fixes for bundled Qt types 2020-06-03 09:55:30 +10:00
Damien Elmes
56d07fdc49 update qt version pin 2020-06-03 09:55:04 +10:00
Damien Elmes
4d9d51a2af lint fixes 2020-06-02 17:58:14 +10:00
Damien Elmes
2b01c5c607 new stubs don't require as many ignores 2020-06-02 17:56:32 +10:00
Damien Elmes
7716e3b17e Switch to PyQt 5.15's (slightly broken) built-in stubs 2020-06-02 17:52:18 +10:00
Damien Elmes
d2fd4bf39e fix initial login 2020-06-02 15:10:58 +10:00
Damien Elmes
d0a498a564 save browser columns when changed, not on each browser close 2020-06-02 13:39:15 +10:00
Damien Elmes
d7a2e78c0b change sync label to indicate sync state
- blue for normal sync, red for full sync required
- refactor status fetching code so we don't hold a collection lock
during the network request, which slows things down
- fix sync spinner restarting when returning to deck list
2020-06-02 13:23:01 +10:00
Damien Elmes
e8f33e1526 fix media sync progress not updating, and issues closing profile 2020-06-01 13:57:10 +10:00
Damien Elmes
4fb5b22726 make sure browser sidebar refreshes on reset()
if items are modified in a sync, the sidebar needs to reflect it
2020-06-01 13:57:10 +10:00
Damien Elmes
ad3082d1c8 handle aborting normal sync
- Use a separate abort handle, as the media sync is running
in the background and we need to be able to target them separately.
The current progress handling is going to need a rethink if we introduce
any other background tasks in the future.
- Roll back the transaction when interrupting.
2020-06-01 13:57:10 +10:00
Damien Elmes
da1e0527ca report normal sync progress
Also:
- provide a way for the progress handler to skip the throttling so that
we can ensure progress is updated at the end of a stage
- show 'checking' at the end of full sync
2020-06-01 13:57:10 +10:00
Damien Elmes
d422b069de lint fixes 2020-06-01 13:57:10 +10:00
Damien Elmes
f171f74dc3 unify sync error handling; handle interrupted 2020-06-01 13:57:10 +10:00
Damien Elmes
b552dfb986 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
9698cb4f22 update auto-sync code 2020-06-01 13:57:10 +10:00
Damien Elmes
03465173dd show server message if present 2020-06-01 13:57:10 +10:00
Damien Elmes
bbc14b88e4 progress bar tweaks 2020-06-01 13:57:10 +10:00
Damien Elmes
0787381a99 login/full up/full down plugged in 2020-06-01 13:57:10 +10:00
Damien Elmes
aaed0464e5 rework progress handling
- client now polls status instead of backend pushing it
- supports multiple threads
- update throttling happens in one place
2020-06-01 13:57:10 +10:00
Damien Elmes
c4032c0176 another snapshot of sync work
progress handler is going to need to be reworked to function across
threads
2020-06-01 13:57:10 +10:00
Damien Elmes
f8e577367b handle images served from directory + svg content type
https://anki.tenderapp.com/discussions/ankidesktop/41974-win-linux-when-pasting-some-html-i-get-error-in-_run_command-ankirsbackendioerror-ioerror
2020-06-01 13:40:17 +10:00
Damien Elmes
82e7451136 handle unicode hostnames
https://anki.tenderapp.com/discussions/ankidesktop/41915-something-wrong-and-i-cant-start-anki
2020-06-01 13:40:17 +10:00
evandrocoan
c336b70ea5 Set to also print the correct QT log message category 2020-05-31 19:38:02 -03:00
evandrocoan
b72aecee36 Print qt context if it exists
https://stackoverflow.com/questions/42561295/qt-error-is-printed-on-the-console-how-to-see-where-it-originates-from
https://stackoverflow.com/questions/35894171/redirect-qdebug-output-to-file-with-pyqt5
https://anki.tenderapp.com/discussions/ankidesktop/42070-anki-closes-without-warning-when-importing-conflicting-shared-deck
https://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler
2020-05-31 19:38:02 -03:00
Damien Elmes
c172dd3826 add some more names to about.py
If you've contributed and are missing from the list, please send me
a PR!
2020-06-01 06:27:14 +10:00
Damien Elmes
d9a39b565f Merge pull request #645 from evandroforks/resize_clayout_editor_and_preview
Allow to resize clayout.py horizontal space between the text editor and the card preview
2020-06-01 05:53:40 +10:00
evandrocoan
750ccc4bd7 Save and restore the debug console window geometry and splitter 2020-05-30 20:58:55 -03:00
evandrocoan
b6b5c37ab9 Add saveSplitter and restoreSplitter to clayout.py
# Conflicts:
#	qt/aqt/clayout.py
2020-05-30 20:33:57 -03:00
evandrocoan
1d82fadaa0 Allow to resize clayout.py horizontal space between the text editor
and the card preview.

# Conflicts:
#	qt/aqt/clayout.py
2020-05-30 20:33:10 -03:00
Damien Elmes
be6726b19f Merge pull request #641 from glutanimate/add-main-window-did-init-hook
Add main_window_did_init hook
2020-05-29 08:56:47 +10:00
Damien Elmes
6b66dad3b6 Merge pull request #640 from evandroforks/fix_render_card_being_called_twice
Fixed previewer.py::render_card() being called twice in row
2020-05-29 08:48:35 +10:00
Damien Elmes
2b13ec5857 add maximize button to HTML editor
closes ankitects/help-wanted#1
2020-05-29 08:43:33 +10:00
Damien Elmes
32de1ee5f9 fix progress window not disappearing when importing csv 2020-05-29 08:40:25 +10:00
Glutanimate
96b3b29a6f Add main_window_did_init hook and clarify difference to profile_did_open 2020-05-28 13:30:22 +02:00
evandrocoan
a34ecefc96 Fixed previewer.py::render_card() being called twice in row
Related to: https://github.com/ankitects/anki/pull 529
Ensuring "setNote" is called only once during changing of note type

After debugging the code, every time the cards changes, there are
two stacktraces generated and triggered when note cards change:

calling 1590591251.4621403
   File "qt/runanki", line 4, in <module>
  File "F:\anki\qt\aqt\__init__.py", line 365, in run
    _run()
  File "F:\anki\qt\aqt\__init__.py", line 515, in _run
    app.exec()
  File "F:\anki\qt\aqt\webview.py", line 467, in handler
    cb(val)
  File "F:\anki\qt\aqt\editor.py", line 477, in <lambda>
    self.web.evalWithCallback("saveNow(%d)" % keepFocus, lambda res: callback())
  File "F:\anki\qt\aqt\browser.py", line 858, in <lambda>
    self.editor.saveNow(lambda: self._onRowChanged(current, previous))
  File "F:\anki\qt\aqt\browser.py", line 880, in _onRowChanged
    self._renderPreview(True)
  File "F:\anki\qt\aqt\browser.py", line 1576, in _renderPreview
    self._previewer.render_card(cardChanged)
  File "F:\anki\qt\aqt\previewer.py", line 136, in render_card
    print('calling', time.time(), "\n", "".join( traceback.format_stack() ) )

calling 1590591251.4766161
   File "qt/runanki", line 4, in <module>
  File "F:\anki\qt\aqt\__init__.py", line 365, in run
    _run()
  File "F:\anki\qt\aqt\__init__.py", line 515, in _run
    app.exec()
  File "F:\anki\qt\aqt\webview.py", line 467, in handler
    cb(val)
  File "F:\anki\qt\aqt\editor.py", line 453, in oncallback
    gui_hooks.editor_did_load_note(self)
  File "F:\anki\qt\aqt\gui_hooks.py", line 1168, in __call__
    hook(editor)
  File "F:\anki\qt\aqt\browser.py", line 887, in onLoadNote
    self.refreshCurrentCard(editor.note)
  File "F:\anki\qt\aqt\browser.py", line 884, in refreshCurrentCard
    self._renderPreview(False)
  File "F:\anki\qt\aqt\browser.py", line 1576, in _renderPreview
    self._previewer.render_card(cardChanged)
  File "F:\anki\qt\aqt\previewer.py", line 136, in render_card
    print('calling', time.time(), "\n", "".join( traceback.format_stack() ) )
2020-05-27 14:41:07 -03:00
sandersantema
79cfe3914e remove unused variable 'w' from '_onHtmlEdit' 2020-05-27 12:04:49 +02:00
sandersantema
94e6078fcd add saveGeom and restoreGeom to htmlEditor 2020-05-27 12:04:00 +02:00
Damien Elmes
e40f507a87 Merge pull request #637 from BlueGreenMagick/field-drag-drop-fix
fix drag drop field repositioning
2020-05-27 10:24:07 +10:00
Damien Elmes
fa8a9499ce Merge pull request #636 from BlueGreenMagick/typing-contextmenuevent
add evt type for contextMenuEvent method
2020-05-27 10:23:44 +10:00
Damien Elmes
4e23460bda Merge pull request #635 from BlueGreenMagick/typing
add typehint for eventFilter method
2020-05-27 10:23:28 +10:00
Damien Elmes
833faf1e63 try mpv on Windows again
https://github.com/ankitects/anki/pull/621
2020-05-27 09:21:41 +10:00
Damien Elmes
eb49062617 apply mpv fix
c0d9544812
2020-05-27 09:19:20 +10:00
Damien Elmes
9e5dad86a8 fix typechecking breaking with latest mypy_protobuf
the change that caused it:
https://github.com/dropbox/mypy-protobuf/issues/118

This is more awkward to handle now, as the types are only available
at type-checking time. Python's static typing is such a mess :-(
2020-05-27 09:14:02 +10:00
BlueGreenMagick
26a8353664 do nothing if dropPos == idx
since such move won't change the field position
and when trying to move the field below itself
may lead to it being moved below the next field
2020-05-26 18:59:53 +09:00
BlueGreenMagick
3ee66375da fix drag drop field repositioning 2020-05-26 18:27:38 +09:00
BlueGreenMagick
60501852c2 add evt type for contextMenuEvent method 2020-05-26 17:12:39 +09:00
BlueGreenMagick
b8f73fee2f add typehint for eventFilter method 2020-05-26 17:08:55 +09:00
Damien Elmes
74d3b2ed41 allow hook to modify search text 2020-05-25 16:54:57 +10:00
Damien Elmes
5a790b4d35 Merge pull request #633 from hgiesel/dconf_hooks
Add three deck config hooks
2020-05-24 09:53:22 +10:00
Damien Elmes
e9fea26d1c use keyword args for calls with more than one argument 2020-05-24 09:12:47 +10:00
Damien Elmes
bbcc566e6d migrate the remaining methods 2020-05-24 08:36:50 +10:00
Henrik Giesel
91d7cd29b2 Satisfy black reformatter 2020-05-23 11:14:52 +02:00
Damien Elmes
927ed25b02 more methods 2020-05-23 14:01:36 +10:00
Henrik Giesel
ae57c6fbeb Add three deck config hooks
- gui_hooks.deck_conf_did_add_config
- gui_hooks.deck_conf_will_remove_config
- gui_hooks.deck_conf_will_rename_config
2020-05-22 21:24:05 +02:00
Damien Elmes
d57ded706f migrate more methods to service 2020-05-22 22:09:33 +10:00
Damien Elmes
a512cbfd5d EMPTY_CARDS should not be translatable 2020-05-22 11:45:14 +10:00
Damien Elmes
7eff75f5f3 hook expected an int, not a str 2020-05-22 11:27:40 +10:00
Damien Elmes
b90d20a3c1 fix custom study not saving 2020-05-22 11:25:11 +10:00
Damien Elmes
7676748e6c fix deletion of decks; allow deleting cards from default
https://anki.tenderapp.com/discussions/beta-testing/1967-2126-189-g7384df8f-crash-at-note-types-fields-save#comment_48353232
2020-05-22 11:24:56 +10:00
Damien Elmes
d31f2d8c23 move deck/notetype update hooks to gui
We need to migrate away from firing hooks in libanki, since libanki
methods may be running on a background thread, and hook consumers
typically expect the code to run in the main thread. We could document
it, but it would frequently be forgotten about, and could lead to
crashes.

https://anki.tenderapp.com/discussions/ankidesktop/41748-qobject-cannot-create-children-for-a-parent-that-is-in-a-different-thread-when-hitting-the-save-button-on-clayoutpy-window
2020-05-22 10:47:14 +10:00
Damien Elmes
59d3473149 show 'changes saved' in parent window 2020-05-22 10:43:41 +10:00
Damien Elmes
dcbfa23eed show message when search fails 2020-05-22 10:43:28 +10:00
Damien Elmes
40dc633d7f monospace font in clayout 2020-05-22 09:58:20 +10:00
Damien Elmes
e5f32e2f4e use context manager in retrieveURL 2020-05-21 10:58:42 +10:00
Damien Elmes
238ec0e4cb clearer variable names in retrieveURL 2020-05-21 09:22:34 +10:00
Damien Elmes
32016bc02b Merge pull request #630 from evandroforks/close_http_client_connections
Fixed HttpClient session not being closed
2020-05-21 09:17:07 +10:00
evandrocoan
fbfe611f03 Added missing Anki icon to debug window 2020-05-20 19:21:31 -03:00
evandrocoan
04dc65ef78 Fixed HttpClient session not being closed 2020-05-20 19:20:41 -03:00
Damien Elmes
0b04658920 fix shortcut keys in clayout 2020-05-21 07:51:35 +10:00
Damien Elmes
75570683db left-align radio buttons in clayout 2020-05-20 19:56:53 +10:00
Damien Elmes
b3e8c63d65 update missed storage._Collection references 2020-05-20 19:45:46 +10:00
Damien Elmes
068cc43095 storage->collection 2020-05-20 17:58:28 +10:00
Damien Elmes
4f5fc9a63d 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
Damien Elmes
bac4232829 fix progress bar getting stuck on image paste 2020-05-20 16:12:41 +10:00
Damien Elmes
883d9a8851 deprecate removeTempNote() 2020-05-20 15:01:05 +10:00
Damien Elmes
1376c829db fix HTML editor in add screen 2020-05-20 14:59:22 +10:00
Damien Elmes
96a4b65cb0 drop mw.weakref usage in models.py for now
https://anki.tenderapp.com/discussions/beta-testing/1967-2126-189-g7384df8f-crash-at-note-types-fields-save
2020-05-20 13:53:34 +10:00
Damien Elmes
1e3080ebdc update empty cards hook
Closes #515
2020-05-20 13:41:09 +10:00
Damien Elmes
7f011bd26f tidy up Qt import 2020-05-20 13:38:55 +10:00
Damien Elmes
f27128418c Merge pull request #625 from evandroforks/fixed_check_box_called_twice
Fixed clayout.py rendering the contents twice when clicked
2020-05-20 12:48:48 +10:00
Damien Elmes
bb9da63433 Merge pull request #626 from evandroforks/fix_previewer_button
Fixed previewer button not resetting the state when the preview
2020-05-20 12:48:17 +10:00
evandrocoan
0292bea4d1 Fixed clayout.py rendering the contents twice when clicked
https://stackoverflow.com/questions/36808257/pyqt-radiobutton-ischecked-is-executed-twice
2020-05-19 20:17:20 -03:00
evandrocoan
1261266a4b Added missing Anki icon to qt/aqt/previewer.py 2020-05-19 19:43:18 -03:00
evandrocoan
b690a51a5c Fixed previewer button not resetting the state when the preview
window is closed by its X button
2020-05-19 19:24:54 -03:00
evandrocoan
1faf7450e4 Explicitly close the importer file descriptor
https://github.com/ankitects/anki/pull 613
2020-05-18 15:54:20 -03:00
evandrocoan
4fe92bfc6b Add missing close file descriptors using context managers 2020-05-18 15:54:20 -03:00
Damien Elmes
e8f0fd4d3b simplify the migration popup
Avoid presenting the user with a wall of text they may not understand,
default to proceeding, and quit if the user cancels.
2020-05-18 20:15:59 +10:00
Damien Elmes
bcb71bbf2d Merge pull request #610 from evandroforks/ask_confirmation_before_moving_anki_collection
Ask user confirmation before moving the Anki directory
2020-05-18 19:44:27 +10:00
Damien Elmes
b7489cdb75 Merge pull request #619 from evandroforks/fix_empty_sound_tags
Also fix legacy.py::anki.sound._soundReg accepting empty tags
2020-05-18 19:31:22 +10:00
Damien Elmes
349c5b378d Merge pull request #620 from evandroforks/remove_unused_var
Remove unused t = time.time() variable on qt/aqt/browser.py
2020-05-18 19:20:08 +10:00
Damien Elmes
8a83eaebdc fix python3.7 lint issue 2020-05-18 18:08:57 +10:00
Damien Elmes
3e156fdb49 bump version 2020-05-18 12:50:20 +10:00
Damien Elmes
6728da62c5 fix shared deck conf warning 2020-05-17 14:37:59 +10:00
Damien Elmes
ab97eaaf15 use deck tree for new/review count calculation
- wins back the performance lost by the decks and dconf not being
in memory, and the overhead of serializing data for DB calls
- card counts are no longer capped to 1000
- learn counts are currently still calculated separately - can't merge
v1 counts without changing the existing behaviour
- partially rendering the tree may yield more savings
2020-05-16 20:28:03 +10:00
Damien Elmes
f76b82d8ae add find_deck_in_tree() 2020-05-16 13:05:20 +10:00
Damien Elmes
afdab1beef save profile stats to file instead of generating report
Can use an external tool like snakeviz to query them after a run.
2020-05-16 12:53:01 +10:00
Damien Elmes
2183e16152 fix lint issues 2020-05-16 12:20:20 +10:00
Damien Elmes
875d638c29 fix+speed up deck list from Filters button
I don't think it makes much sense to keep these lists that largely
duplicate the sidebar functionality, but they remain for now.
2020-05-16 11:54:08 +10:00
Damien Elmes
c60229779c switch to new deck tree in deck browser
Saves us having to look up collapsed/filtered as we render, and gives
us type completion.
2020-05-16 10:52:14 +10:00
Damien Elmes
6c3157a028 drop usage of nameMap in deckbrowser
It was unnecessary, and being called multiple times as we recursed
downwards, slowing things down.
2020-05-16 10:02:08 +10:00
Damien Elmes
6d4e98c13b avoid duplicate reset in overview 2020-05-15 21:54:56 +10:00
Damien Elmes
cbfc9d5a87 handle default deck and filtered deck suppression in the backend 2020-05-15 21:21:10 +10:00
Damien Elmes
dc6471ad40 fetch stock notetypes from backend 2020-05-15 17:08:24 +10:00
Damien Elmes
fd9fc8701c add back card deletion count
cheaper to look up now that there's an index on notes.mid
2020-05-15 15:28:07 +10:00
Damien Elmes
91e71ae044 show (Deck) when card hasn't been added 2020-05-15 15:01:28 +10:00
Damien Elmes
1769cef549 when previewing cards, use the default deck for now
Replay code needs to be able to retrieve deck options. We should
probably use the current deck or pass it in in the future.
2020-05-15 14:50:57 +10:00
Damien Elmes
548f266618 update replay suppression in clayout 2020-05-15 14:26:00 +10:00
Damien Elmes
6c4d6ad933 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
8b7ba99f6e no longer need to check addNote's return value 2020-05-14 21:59:42 +10:00
Damien Elmes
8dcb7fd2ba check for empty cloze cards when rendering as well 2020-05-14 21:56:45 +10:00
Damien Elmes
6dd31341f8 add "fill empty" checkbox 2020-05-14 20:58:45 +10:00
Damien Elmes
aed2eb2cc2 update Add Field button 2020-05-14 18:01:15 +10:00
Damien Elmes
4c52d41632 use group box instead of tabs in card layout screen 2020-05-14 17:26:40 +10:00
Damien Elmes
b2b33d9ad8 start reworking card layout screen
- front/back/css shown in tabs
- front/back preview switchable; only one webview needs to be loaded
- dropdown to select cloze number in preview
- search box to search in front/back/css
2020-05-14 15:24:29 +10:00
Damien Elmes
4a00ad075c drop availOrds(), and use backend for getting cloze numbers 2020-05-14 12:14:00 +10:00
Damien Elmes
b08613e37d remove obsolete preview code 2020-05-14 09:22:53 +10:00
Damien Elmes
257e893d95 update the card layout screen
- changes are now committed in bulk when closing the dialog,
and can be canceled
- it's not necessary to save the note to the database to preview it
- duplicate fields are now shown as duplicates in the top list
- redraw preview more quickly
- use + instead of _ when deduplicating names, as the latter is a
glob character
2020-05-13 17:24:49 +10:00
Damien Elmes
4815010da0 don't hide static template text when card is empty 2020-05-13 11:17:44 +10:00
evandrocoan
d113e85bc8 Remove unused t = time.time() variable on qt/aqt/browser.py 2020-05-12 15:09:22 -03:00
evandrocoan
e4ad1c80eb Also fix legacy.py::anki.sound._soundReg accepting empty tags 2020-05-12 12:43:35 -03:00
Damien Elmes
21ac2c14a7 handle scheduling preferences in the backend 2020-05-12 21:13:34 +10:00
Damien Elmes
d7f9bccd1e 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
667f9e6554 bulk tag add/remove/update; canonify on note save
also remove the tag list updated hook - we'll need a better solution in
the future than having the library code call back into the GUI code
2020-05-12 21:13:34 +10:00
Damien Elmes
0a87b1ef2c support disabling unicode normalization in notes 2020-05-12 21:13:34 +10:00
Damien Elmes
866231f661 add pep8 name for findReplace 2020-05-12 21:13:34 +10:00
Damien Elmes
70e404b517 update extract-po-string to handle plurals again 2020-05-12 21:13:34 +10:00
Damien Elmes
8c04718541 update find&replace in browser
sadly the UI still stutters on large selections - the calls
to get the selected rows from Qt are really slow.
2020-05-12 21:13:34 +10:00
Damien Elmes
6b4a40f774 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
b757d3db65 check untyped in clayout 2020-05-12 21:13:34 +10:00
Damien Elmes
1a6e28a05d remove an unused import 2020-05-12 21:13:34 +10:00
Damien Elmes
2641862b56 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
a21e2abca0 add helper to run background task with progress 2020-05-12 21:13:34 +10:00
Damien Elmes
2b937acf29 reuse existing use count in note types screen 2020-05-12 21:13:33 +10:00
Damien Elmes
0bab292ff5 mypy/isort fixes 2020-05-12 21:13:33 +10:00
Damien Elmes
7ef72aba04 use the backend for the deck due tree
- approx 3x faster on a large test deck
- counts are no longer capped to 1000 in the tree
2020-05-12 21:13:33 +10:00
Damien Elmes
97e857a41c add browserCollapsed as part of tree build 2020-05-12 21:13:33 +10:00
Damien Elmes
1d01418b21 fix mypy issues 2020-05-12 21:13:33 +10:00
Damien Elmes
13d23cd24b speed up browser load by rendering deck tree in Rust and skipping counts 2020-05-12 21:13:33 +10:00