Commit Graph

185 Commits

Author SHA1 Message Date
RumovZ
bbba21126f Improve clarity in card info code a tiny little bit 2021-10-18 09:01:25 +02:00
RumovZ
ec02a4218e Keep Card Info Dialog open even if no card is set 2021-10-18 09:01:24 +02:00
RumovZ
5062024974 Move update logic into CardInfo.svelte 2021-10-18 09:01:24 +02:00
RumovZ
1d63253b4f Make window titles more user-friendly 2021-10-18 09:01:23 +02:00
RumovZ
7eec241c82 Add utility func for setting window icon 2021-10-18 09:01:23 +02:00
RumovZ
f0d7e6f4d1 Use updating card infos in browser and reviewer 2021-10-18 09:01:23 +02:00
RumovZ
13024fcccc Add update handler for Card Info Dialog 2021-10-18 09:01:22 +02:00
RumovZ
859b1d1a39 Make Card Info Dialog non-modal 2021-10-18 09:01:22 +02:00
Damien Elmes
a7812dedc0 switch to new-style PyQt scoped enums and Qt6
The enum changes should work on PyQt 5.x, and are required in PyQt 6.x.
They are not supported by the PyQt5 typings however, so we need to run
our tests with PyQt6.
2021-10-15 12:57:19 +10:00
RumovZ
3672b0fe73
Switch CardInfoDialog to ts page (#1414)
* Only collect card stats on the backend ...

... instead of rendering an HTML string using askama.

* Add ts page Card Info

* Update test for new `col.card_stats()`

* Remove obsolete CardStats code

* Use new ts page in `CardInfoDialog`

* Align start and end instead of left and right

Curiously, `text-align: start` does not work for `th` tags if assigned
via classes.

* Adopt ts refactorings after rebase

#1405 and #1409

* Clean up `ts/card-info/BUILD.bazel`

* Port card info logic from Rust to TS

* Move repeated field to the top

https://github.com/ankitects/anki/pull/1414#discussion_r725402730

* Convert pseudo classes to interfaces

* CardInfoPage -> CardInfo

* Make revlog in card info optional

* Add legacy support for old card stats

* Check for undefined instead of falsy

* Make Revlog separate component

* drop askama dependency (dae)

* Fix nightmode for legacy card stats
2021-10-14 19:22:47 +10:00
Damien Elmes
aabf693bb8 Revert "Allow <audio> to play without user interaction in accordance to autoplay setting"
This reverts commit 54f51da944.

This breaks in the PyQt6 upgrade. There are no globals anymore, only
page profiles - but the code should probably be modifying a specific
webview instead of globals anyway.
2021-10-12 16:18:24 +10:00
Damien Elmes
69c196b409 .exec_() -> .exec()
The former is not supported in PyQt6
2021-10-12 16:17:37 +10:00
Damien Elmes
e357dbf6b3 use Qt search path instead of resource system
Means URLs like :/icons/foo.jpg should become icons:foo.jpg

This is part of the prep work for a PyQt6 update. PyQt6 has dropped
pyrcc, so we can longer generate the icons_qrc.py file we did previously.

Qt Designer expects us to use the resource system, so we continue to
generate the icons.qrc file to make editing the UI files easier. But at
runtime, we no longer use that file.
2021-10-12 16:17:08 +10:00
Ren Tatsumoto
48f8427592
Keep the list of duplicates up-to-date before tagging (#1404)
* keep the list of dupes up-to-date before tagging

* get rid of a redundant parameter

* unnecessary lambda
2021-10-07 12:49:41 +10:00
Damien Elmes
b9251290ca run pyupgrade over codebase [python upgrade required]
This adds Python 3.9 and 3.10 typing syntax to files that import
attributions from __future___. Python 3.9 should be able to cope with
the 3.10 syntax, but Python 3.8 will no longer work.

On Windows/Mac, install the latest Python 3.9 version from python.org.
There are currently no orjson wheels for Python 3.10 on Windows/Mac,
which will break the build unless you have Rust installed separately.

On Linux, modern distros should have Python 3.9 available already. If
you're on an older distro, you'll need to build Python from source first.
2021-10-04 15:05:48 +10:00
Damien Elmes
7c70d26fe7 update Python deps 2021-10-02 23:52:23 +10:00
Damien Elmes
0000a3b302
Merge pull request #1402 from RumovZ/row-changed
Connect `currentChanged()` and add legacy alias for `onRowChanged()`
2021-10-02 09:06:05 +10:00
RumovZ
c146f33faa Add legacy alias browser.onRowChanged() 2021-10-01 18:36:12 +02:00
RumovZ
3a5d86c344 React to currentChanged() signal
Decouples changes of the current element and changes of the selection.
Introduces `browser.current_card` which has previously been amalgamated
with the previewer card `browser.card`.
2021-10-01 16:40:25 +02:00
Damien Elmes
a174c41801
Merge pull request #1397 from RumovZ/column-tooltips
Add tooltips for some browser columns
2021-10-01 19:12:59 +10:00
Damien Elmes
7a81a1c7b6
Merge pull request #1400 from RumovZ/revert-hide-completer
Remove workaround for Qt completer bug
2021-10-01 15:30:37 +10:00
Damien Elmes
ee99578c06
Merge pull request #1392 from RumovZ/missing-row-handling
Handle missing rows consistently and speed up selections
2021-10-01 14:24:04 +10:00
RumovZ
e5cf649d6a Remove workaround for Qt completer bug
Reverts  #803.
2021-09-30 17:56:37 +02:00
RumovZ
ee2ecd0700 Add tooltips for some browser columns 2021-09-30 13:15:09 +02:00
RumovZ
326cf0f77f Remove redundant call to len_columns() 2021-09-28 12:11:20 +02:00
RumovZ
72f6f9a47a
Tweak comment
Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
2021-09-28 11:48:35 +02:00
RumovZ
46ffbb936d Speed up to_row_of_unselected_note()
Skip rows between selected rows and return fetched note ids.
2021-09-28 11:47:13 +02:00
RumovZ
a592c5b3a9 Cache selectionModel().selectedRows() 2021-09-28 11:45:22 +02:00
RumovZ
eac8972a28 Calculate len_selection depending on modifiers
If no modifiers are pressed, a single row has probably been clicked and
`selectedRows()` is fast, while a lot of rows might have been deselcted.
2021-09-28 10:22:20 +02:00
RumovZ
287854d014 Prefer selectionModel().reset() over .clear()
The latter triggers `selectionChanged()` unreliably, probably due to the
aggregation of chronologically close events, causing problems in
tracking `_len_selection`. `reset()` never emits signals.
2021-09-28 10:19:33 +02:00
Damien Elmes
96798f018a
Merge pull request #1382 from RumovZ/tags-from-sidebar
Tags from sidebar
2021-09-27 18:41:32 +10:00
RumovZ
f89811870e Calculate number of selected rows manually
`len(self._view.selectionModel().selectedRows())` is slow for large
selections, because Qt queries flags() for every selected cell, so we
calculate the number of selected rows ourselves.
2021-09-27 10:15:53 +02:00
RumovZ
18f0d026b5 Switch to new row before deleting notes
The table now properly deselects deleted rows, but that takes effort and
it's more convenient to have a selected row after deleting.
2021-09-25 17:28:38 +02:00
RumovZ
f54f15cd44 Handle deleted or restored rows
- Cache the result of 'table.len_selection()'
- Update this cache manually when a row was deleted or restored
- Emit 'dataChanged()' after such a change to fix flags not updating
correctly to the shortcut in 'model.flags()'
- Remove/retsore focus if the current element was deleted/restored
2021-09-25 17:16:53 +02:00
RumovZ
3a8c494544 Only check flags of cached rows
Speeds up the selection process (esp. Ctrl+A) by avoiding to fetch rows.

Co-authored-by: BlueGreenMagick <BlueGreenMagick@users.noreply.github.com>
2021-09-25 15:32:22 +02:00
RumovZ
73ec0a2b2e Add callbacks to row fetching routine
Called when a row is detected that has been deleted or restored.
2021-09-25 15:27:19 +02:00
RumovZ
2b5bf23bbd Check 'index.isValid()' in 'table.model' 2021-09-25 15:21:06 +02:00
hikaru-y
fc232eb0f7 Fix memory leak in previewer
Related thread:
https://forums.ankiweb.net/t/high-memory-usage-over-time-on-2-1-44/13544/
2021-09-22 17:21:08 +09:00
RumovZ
75f210a66c Enable adding/removing tags from the sidebar ...
... to selected notes.
2021-09-21 11:48:43 +02:00
Damien Elmes
d091a547a4
Merge pull request #1375 from RumovZ/disable-actions
Disable unusable browser actions on row change
2021-09-21 18:38:30 +10:00
Damien Elmes
1ceb9965ad add hidden option to disable tooltips in browse screen
https://forums.ankiweb.net/t/browser-text-pop-up-when-hovering-over-card-poll/13254
2021-09-21 15:03:37 +10:00
Damien Elmes
9720592519 temporary fix for error on deleting (#1374) 2021-09-20 22:02:44 +10:00
RumovZ
94b261f1ef Simplify sidebar context menu separators
Qt can collapse consecutive menu separators, so no need to check if a
subroutine has actually added any actions to the menu.
2021-09-19 18:33:36 +02:00
RumovZ
40bad0f65d Disable unusable browser actions on row change 2021-09-17 16:16:34 +02:00
Damien Elmes
b877026248 don't check state of current card when repositioning
closes #1365
2021-09-13 14:56:53 +10:00
RumovZ
d044360ff9 Disable 'Rename with Parents' for top-level items 2021-08-30 11:10:14 +02:00
Damien Elmes
528343b417
Merge pull request #1319 from abdnh/sidebar-scroll-center
Use PositionAtCenter for sidebar scrolling
2021-08-02 18:35:38 +10:00
Damien Elmes
f0b8b10314
Merge pull request #1311 from hikaru-y/flag-mark-icons-in-previewer
Show flag and mark icons in previewer
2021-08-02 18:33:36 +10:00
abdo
ad6f5c7404 Use PositionAtCenter for sidebar scrolling 2021-08-02 10:57:54 +03:00
Damien Elmes
68dddfe93b prevent hiding of sidebar
https://forums.ankiweb.net/t/browser-format-issues/11504/10
2021-07-28 11:14:09 +10:00