Commit Graph

147 Commits

Author SHA1 Message Date
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
evandrocoan
6bd80fef67 Add saveSplitter and restoreSplitter to clayout.py
# Conflicts:
#	qt/aqt/clayout.py
2020-05-30 20:33:57 -03:00
evandrocoan
a5fd8398c4 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
38508c3ad7 use keyword args for calls with more than one argument 2020-05-24 09:12:47 +10:00
Damien Elmes
9baa8530d5 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
16eceb5260 show 'changes saved' in parent window 2020-05-22 10:43:41 +10:00
Damien Elmes
9358c78bad show message when search fails 2020-05-22 10:43:28 +10:00
Damien Elmes
a4efd9910e monospace font in clayout 2020-05-22 09:58:20 +10:00
Damien Elmes
300fba156e fix shortcut keys in clayout 2020-05-21 07:51:35 +10:00
evandrocoan
64a90a457c 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
Damien Elmes
1fc951471c fix python3.7 lint issue 2020-05-18 18:08:57 +10:00
Damien Elmes
f650e5557f 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
00db72e365 show (Deck) when card hasn't been added 2020-05-15 15:01:28 +10:00
Damien Elmes
ed52a4dc3f 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
68e1303880 update replay suppression in clayout 2020-05-15 14:26:00 +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
782911471b add "fill empty" checkbox 2020-05-14 20:58:45 +10:00
Damien Elmes
9a222e620a update Add Field button 2020-05-14 18:01:15 +10:00
Damien Elmes
c5d574e9f4 use group box instead of tabs in card layout screen 2020-05-14 17:26:40 +10:00
Damien Elmes
5167bb57be 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
f23eb350e4 drop availOrds(), and use backend for getting cloze numbers 2020-05-14 12:14:00 +10:00
Damien Elmes
c601dcef24 remove obsolete preview code 2020-05-14 09:22:53 +10:00
Damien Elmes
6680cdf1d3 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
6e6d9ee1a3 check untyped in clayout 2020-05-12 21:13:34 +10:00
Damien Elmes
23586ffe90 catch template errors, and start on discarding changes to fields/cards
This is only a first step - all the current methods that implicitly
save need to be updated.
2020-05-12 21:13:33 +10:00
Damien Elmes
f637ac957d hook up new note and note type handling
- notetypes are fetched from the DB as needed, and cached in Python
- handle note type changes in the backend. Multiple operations can now
be performed in one go, but this is not currently exposed in the GUI.
- extra methods to grab sorted note type names quickly, and fetch by
name
- col.models.save() without a provided notetype is now a no-op
- note loading/saving handled in the backend
- notes with no valid cards can now be added
- templates can now be deleted even if they would previously
orphan notes

a number of fixmes have been left in notes.py and models.py
2020-05-12 21:13:33 +10:00
Damien Elmes
b932333246 fix card layout screen on qt 5.9 regression (#592) 2020-05-05 11:26:13 +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
BlueGreenMagick
be6a5e2f13 Set tab width to 4 spaces
setTabStopWidth is deprecated, and setTabStopDistance is preferred
It's not entirely accurate however, which you can see
when you compare 10 tabs and 40 spaces
2020-04-29 11:34:09 +09:00
Arthur Milchior
80ba217772 hook for initializing clayout 2020-03-01 11:42:41 +01:00
Glutanimate
0e5dea4c9f Assume that web assets without a specified subpath are under /_anki
Maintains compatibility with existing add-ons
2020-02-15 15:03:43 +01:00
Glutanimate
c839cda19f Fix missing "Optional" import and lint 2020-02-12 22:15:44 +01: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
7fcb6b5672 pass instance to webview_did_receive_js_message instead of string 2020-02-09 08:59:29 +10:00
Damien Elmes
218c033104 respond to play button clicks in preview screen + card layout screen 2020-01-25 16:02:21 +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
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
d54f719558 add a webview_did_receive_js_message hook 2020-01-22 11:06:12 +10:00
Damien Elmes
b870abd2d4 include card ordinal in clayout 2020-01-22 10:28:10 +10:00
Damien Elmes
02ec3f149c update qt/ to use the new API 2020-01-20 20:10:38 +10:00
Damien Elmes
8310cb7a0e add qconnect helper and some type hints
The type hints allow mypy to check the gui_hook calls, revealing a
bunch of places that are broken as they expect no arguments like the
legacy hooks.

To make mypy happy about PyQt's signal.connect(func), a qconnect()
helper has been added.
2020-01-16 07:41:23 +10:00
Damien Elmes
b09e7e8247 more tweaks for readability/consistency 2020-01-15 17:45:35 +10:00
Damien Elmes
cab572b63c remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
84c17e1f02 add more hooks, tweak wording for consistency 2020-01-15 12:16:54 +10:00
Damien Elmes
5876866565 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00