Commit Graph

10085 Commits

Author SHA1 Message Date
Damien Elmes
5cdfa7a60a Update translations 2023-01-18 23:21:06 +10:00
Damien Elmes
19bbcb4cc0 Use backend for extracting cloze text to type
Closes #2311
2023-01-18 23:05:28 +10:00
Damien Elmes
03814fa1c4 Add some extra info to the 'modified without updating' message
For #2315
2023-01-18 22:38:28 +10:00
Damien Elmes
b8a8342a9a Fix sync indicator not being visible in deck list screen
Closes #2327
2023-01-18 22:32:39 +10:00
Aristotelis
476e3af759
Bump Linux theme refresh timer back up to 5 minutes (#2331)
On Linux distributions that do not yet support org.freedesktop.appearance.color-scheme (most distros released prior to 2022), querying DBus for the missing property produces verbose journal entries over Anki's entire runtime.
2023-01-18 22:24:59 +10:00
Damien Elmes
943dddf28f
Update Rust deps (#2332)
* Temporarily disable hakari

* Upgrade compatible deps except Chrono

* Update semver-incompatible crates

* Re-enable hakari

* Update licenses & cargo-deny

* Fix new clippy lints

* Update to latest Rust
2023-01-18 22:24:29 +10:00
Damien Elmes
ded805b504
Switch Rust import style (#2330)
* Prepare to switch Rust import style

* Run nightly format

Closes #2320

* Clean up a few imports

* Enable comment wrapping

* Wrap comments
2023-01-18 21:39:55 +10:00
Damien Elmes
9d84f357b6 Probable fix for flaky test 2023-01-18 21:32:08 +10:00
Matthias Metelka
f169ee0933
Revamp Preferences, implement Minimalist Mode and Qt widget gallery to test GUI changes (#2289)
* Create widget gallery dialog

* Add WidgetGallery to debug dialog

* Use enum for its intended purpose

* Rename "reduced-motion" to "reduce-motion"

* Add another border-radius value

and make former large radius a bit smaller.

* Revamp preferences, add minimalist mode

Also:
- create additional and missing widget styles and tweak existing ones
- use single profile entry to set widget styles and reduce choices to Anki and Native

* Indent QTabBar style definitions

* Add missing styles for QPushButton states

* Fix QTableView background

* Remove unused layout from Preferences

* Fix QTabView focused tab style

* Highlight QCheckBox and QRadioButton when focused

* Fix toolbar styles

* Reorder preferences

* Add setting to hide bottom toolbar

* Move toolbar settings above minimalist modes

* Remove unused lines

* Implement proper full-screen mode

* Sort imports

* Tweak deck overview appearance in minimalist mode

* Undo TitledContainer changes

since nobody asked for that

* Remove dynamic toolbar background from minimalist mode

* Tweak buttons in minimalist mode

* Fix some issues

* Reduce theme check interval to 5s on Linux

* Increase hide timer interval to 2s

* Collapse toolbars with slight delay when moving to review state

This should ensure the bottom toolbar collapses too.

* Allow users to make hiding exclusive to full screen

* Rename full screen option

* Fix hide mode dropdown ignoring checkbox state on startup

* Fix typing issue

* Refine background image handling

Giving the toolbar body the main webview height ensures background-size: cover behaves exactly the same.

To prevent an override of other background properties, users are advised to only set background-images via the background-image property, not the background shorthand.

* Fix top toolbar getting huge when switching modes

The issue was caused by the min-height hack to align the background images. A call to web.adjustHeightToFit would set the toolbar to the same height as the main webview, as the function makes use of document.offsetHeight.

* Prevent scrollbar from appearing on bottom toolbar resize

* Cleanup

* Put review tab before editing; fix some tab orders

* Rename 'network' to 'syncing'

* Fix bottom toolbar disappearing on UI > 100

* Improve Preferences layout by adding vertical spacers to the bottom

also make the hiding of video_driver and its label more obvious in preferences.py.

* Fix bottom toolbar animating on startup

Also fix bottom toolbar not appearing when unchecking hide mode in reviewer.

* Hide/Show menubar in fullscreen mode along with toolbar

* Attempt to fix broken native theme on macOS

* Format

* Improve native theme on other systems by not forcing palette

with the caveat that theme switching can get weird.

* Fix theme switching in native style

* Remove redundant condition

* Add back check for Qt5 to prevent theme issues

* Add check for macOS before setting fusion theme

* Do not force scrollbar styles on macOS

* Remove all of that crazy theme logic

* Use canvas instead of button-bg for ColorRole.Button

* Make sure Anki style is always based on Fusion

otherwise we can't guarantee the same look on all systems.

* Explicitly apply default style when Anki style is not selected

This should fix the style not switching back after it was selected.

* Remove reduncant default_palette

* Revert 8af4c1cc2

On Mac with native theme, both Qt5 and Qt6 look correct already. On
the Anki theme, without this change, we get the fusion-style scrollbars
instead of the rounded ones.

* Rename AnkiStyles enum to WidgetStyle

* Fix theme switching shades on same theme

* Format

* Remove unused placeholderText

that caused an error when opening the widget gallery on Qt5.

* Check for full screen windowState using bitwise operator

to prevent error in Qt5.

Credit: https://stackoverflow.com/a/65425151

* Hide style option on Windows

also exclude native option from dropdown just in case.

* Format

* Minor naming tweak
2023-01-18 21:24:16 +10:00
Damien Elmes
c923553a53 Replace newlines with linebreaks when importing without HTML
https://forums.ankiweb.net/t/line-breaks-are-removed-when-importing-csv-on-linux/26451
2023-01-18 21:00:33 +10:00
Damien Elmes
0be9ee8dcc Fix ctrl+enter not working when importing screen first opened
Thanks to blueputty01 for investigating!

Closes #2326
2023-01-18 15:41:47 +10:00
Damien Elmes
cf45cbf429
Rework syncing code, and replace local sync server (#2329)
This PR replaces the existing Python-driven sync server with a new one in Rust.
The new server supports both collection and media syncing, and is compatible
with both the new protocol mentioned below, and older clients. A setting has
been added to the preferences screen to point Anki to a local server, and a
similar setting is likely to come to AnkiMobile soon.

Documentation is available here: <https://docs.ankiweb.net/sync-server.html>

In addition to the new server and refactoring, this PR also makes changes to the
sync protocol. The existing sync protocol places payloads and metadata inside a
multipart POST body, which causes a few headaches:

- Legacy clients build the request in a non-deterministic order, meaning the
entire request needs to be scanned to extract the metadata.
- Reqwest's multipart API directly writes the multipart body, without exposing
the resulting stream to us, making it harder to track the progress of the
transfer. We've been relying on a patched version of reqwest for timeouts,
which is a pain to keep up to date.

To address these issues, the metadata is now sent in a HTTP header, with the
data payload sent directly in the body. Instead of the slower gzip, we now
use zstd. The old timeout handling code has been replaced with a new implementation
that wraps the request and response body streams to track progress, allowing us
to drop the git dependencies for reqwest, hyper-timeout and tokio-io-timeout.

The main other change to the protocol is that one-way syncs no longer need to
downgrade the collection to schema 11 prior to sending.
2023-01-18 12:43:46 +10:00
RumovZ
1be30573e1
Replace dissimilar crate with difflib (#2322)
This also inserts the expected text if it's missing at the very
beginning of the provided text.
2023-01-16 09:49:34 +10:00
Hikaru Y
604e0f46e1
Fix and refactor image size constraints (#2318)
* Remove 'ResizableImage.svelte'

Rather than having a svelte file that just sets global styles, it's
better to set those in a (s)css file.

* Fix and refactor image size constraints

- Fixes https://forums.ankiweb.net/t/2-1-56-image-size-problem-in-editor/26207
- Use :host-context() to switch image styles instead of toggling CSS
variables.

* Fix toolbar buttons for image overlay sometimes being cut off
2023-01-13 23:18:25 +10:00
Damien Elmes
8131ea1908 Fix quotes breaking field descriptions, and prevent content injection
https://forums.ankiweb.net/t/some-field-descriptions-are-not-showing/26295
2023-01-13 16:37:49 +10:00
Matthias Metelka
df456e959d
Make QCheckBox more visible (#2314) 2023-01-12 09:16:38 +10:00
Damien Elmes
10fd465edb Increase delay for mutter
It's a nasty hack, and would be nice if we could easily limit it to
users who are using Mutter.
2023-01-11 19:59:34 +10:00
dependabot[bot]
b5cca03d09
Bump bzip2 from 0.4.3 to 0.4.4 (#2310)
Bumps [bzip2](https://github.com/alexcrichton/bzip2-rs) from 0.4.3 to 0.4.4.
- [Release notes](https://github.com/alexcrichton/bzip2-rs/releases)
- [Commits](https://github.com/alexcrichton/bzip2-rs/commits/0.4.4)

---
updated-dependencies:
- dependency-name: bzip2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-11 12:58:35 +10:00
Matthias Metelka
ba822d9ee9
Simplify padding definition and center text (#2308) 2023-01-11 12:58:02 +10:00
Damien Elmes
5db95c97e3 Fix incorrect added total/average
https://forums.ankiweb.net/t/anki-2-1-56-release-candidate/26001/18
2023-01-10 09:45:54 +10:00
Hikaru Y
25def4f741
Fix spaces not handled properly when entering text around MathJax (#2307)
Regressed in #2288
https://forums.ankiweb.net/t/2-1-56-qt6-pressing-space-after-mathjax-inserts-nbsp-with-escaped/26147
2023-01-10 08:51:09 +10:00
RumovZ
6df7be90c5
Fix negated introduced:x search (#2306)
1. Add outer brackets.
2. Coalesce aggregate, because `null and true` is `null` in SQL land,
so cards that were not introduced, but manually rescheduled in the
period of interest, would not show up in a negated search.
2023-01-10 08:49:35 +10:00
Aristotelis
91d563278f
Fix toolbar add-on breakages and introduce toolbar tray layout & API (#2301)
* Layout toolbar using CSS grid, introducing left and right trays

The trays provide a space for add-ons to introduce their own widgets to the toolbar without interfering with each other.

* Align tray items to the top

* Move absolutely positioned add-on items to right toolbar tray

Workaround that fixes breakages in add-ons like AMBOSS, Study Timer, and potentially others that currently still inject absolutely positioned elements into the toolbar using `top_toolbar_did_init_links`.

* Account for add-ons that add manual padding (e.g. Study Timer)

* Add docstrings and slightly refactor

* Tweak item alignment

* Introduce hooks for extending left and right toolbar trays

* Assign CSS classes to all tray items

* Add disclaimer on transitional nature of new hooks
2023-01-10 08:48:50 +10:00
Damien Elmes
cef672a6a1 Update Windows/Linux to Qt 6.4.2
Closes #2275
2023-01-09 16:22:47 +10:00
Matthias Metelka
9f8667fb47
Auto-hide toolbar in Reviewer (#2262)
* Give webviews a slide-in animation

if reduced motion isn't set.

* Auto-hide toolbar in review mode

moving the mouse above the main webview expands the toolbar. When the mouse leaves the toolbar, it will collapse after a delay of 2s.

* Save some space on bottom toolbars

* Use props for all hard-coded transition durations

and decrease most commonly used duration (200ms) to 150ms.

* Move auto-hide logic into ToolbarWebView

and handle auto-hide specific events in the respective webview subclasses.

* Fix typing issues

* Fix flickering issue

* Add auto_hide_toolbar opt-in to preferences

* Rename hide_toolbar to collapse_toolbar

to better describe the dock-like behaviour.

* Rename setting to minimize_distractions

* Reduce calls to pm in eventFilter

* Run formatter

* Revert setting title to something more specific

* Increase default animation time to 180ms

* Inset toolbar in review mode

when auto-hide is not enabled.

* Use card background on toolbar and add glass effect

* Use flatten/elevate over inset/outset

* Use flatten/elevate over inset/outset

* Update toolbar.py

* Fix toolbar background delay

* Tweak styles

* Use "collapse" instead of "auto-hide"

* Fix background misalignment in collapse mode

* Do not collapse toolbar when pointer is outside MainWebView

* Reduce hide_timer interval to 1000ms

* Use CSS to hide toolbar instead of setting webview height

* Add guard to prevent backdrop-filter: blur on Qt 5.14

* Apply transition to body instead of toolbar

to not complicate things for #2301.

* Fix Qt 5.14 and apply guard globally

* Fix background image scaling difference

* Tweak preference wording (dae)
2023-01-09 14:39:31 +10:00
Damien Elmes
afca2f52ce Update translations 2023-01-09 11:09:02 +10:00
Damien Elmes
3b0fd7b3eb Bump version 2023-01-09 11:08:53 +10:00
Damien Elmes
07fd88ddea Allow timestamps to be a day ahead
https://github.com/ankitects/anki/issues/1895#issuecomment-1374574230
2023-01-09 10:04:48 +10:00
dependabot[bot]
4e92c29815
Bump tokio from 1.23.0 to 1.23.1 (#2303)
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.23.0 to 1.23.1.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.23.0...tokio-1.23.1)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-07 10:01:56 +10:00
Damien Elmes
7f71277514 Whitelist dependabot 2023-01-07 09:53:29 +10:00
Damien Elmes
309c467403 Work around button margins being too thin on Windows 2023-01-05 17:15:10 +10:00
Damien Elmes
f9aa232d9b Fix cloze buttons not working in MathJax editor
Regressed in #2144
2023-01-05 15:58:32 +10:00
Damien Elmes
037610715d Fix incorrect count in 'added' tooltip 2023-01-05 10:21:26 +10:00
Damien Elmes
8206f39bdc Fix sparse today stats
Not safe to assume revlog is ordered by query
2023-01-05 10:14:37 +10:00
Damien Elmes
bc6975973e Display a more helpful error when the locale is wrong 2023-01-04 19:01:55 +10:00
Damien Elmes
f2bb0395bf Fix unreadable text when searching in sidebar
We used to have a separate SUSPENDED_BG, but it got removed in the UI
refactor.

https://www.reddit.com/r/Anki/comments/1029gbw/is_anyone_else_with_2155_experience_way_to_bright/
2023-01-04 18:16:19 +10:00
Damien Elmes
0eddb25287
Integrate AnkiDroid's backend patches into the repo (#2290)
* Relax chrono specification for AnkiDroid

https://github.com/ankidroid/Anki-Android-Backend/pull/251

* Add AnkiDroid service and AnkiDroid customizations

Most of the work here was done by David in the Backend repo; integrating
it into this repo for ease of future maintenance.

Based on 5d9f262f4c
with some tweaks:

- Protobuf imports have been fixed to match the recent refactor
- FatalError has been renamed to AnkidroidPanicError
- Tweaks to the desktop code to deal with the extra arg to open_collection,
and exclude AnkiDroid service methods from our Python code.

* Refactor AnkiDroid's DB code to avoid uses of unsafe
2023-01-03 13:11:23 +10:00
Damien Elmes
922574444f Update json5 due to CWE
Doesn't affect us, but satisfies Dependabot
https://cwe.mitre.org/data/definitions/1321.html
2023-01-03 13:03:25 +10:00
Damien Elmes
65a79c743f Update translations 2023-01-03 12:59:50 +10:00
Damien Elmes
30bf5f8b39 Fix 'git submodule' after git security update 2023-01-03 12:59:50 +10:00
kelciour
e9428449ff
Fix two mpv issues on Windows (#2294)
* Fix mpv with two Windows accounts at the same time

Closes #2203

* Add a workaround for audio cut off early on Windows

Closes #1730
2023-01-03 11:59:39 +10:00
Aristotelis
2270ff425a
Add dev tools for live-reloading Anki's web views (#2151)
* Add dev tools for live-reloading the web stack while running Anki

* Handle CDP connection errors more graciously

* Include sass in web stack watchers

* Refactor monitored folder and event definition

* Switch to more specific build target

Thanks to @hikaru-y

* Add PyChromeDevTools to dev requirements

* Update rebuild-web for ninja

* Satisfy mypy

* Remove ts-watch

Superseded by web-watch (the version here was also still based around bazel)

* Simplify calls to other build tools

Given that `./ninja qt/aqt` has to be run from the project root anyways, it doesn't make sense to use calls relative to `rebuild-web` in an ill-guided effort to lower dependencies on hard-coded paths.

* Remove remaining script-relative tool path
2023-01-03 11:55:58 +10:00
Damien Elmes
3357389309 Fix some regressions with the graphs when printing
- page-break avoidance needs to be moved to the wrapping TitledContainer
- grid has to be disabled, as it prevents page breaks from working, and
shows too many columns (https://forums.ankiweb.net/t/stats-save-as-pdf-problems-2-1-55/25773)
- content underflowed the top header
2022-12-30 17:37:38 +10:00
Damien Elmes
ba68764fcb Another attempt at fixing missing cacert.pem
A few reports like https://forums.ankiweb.net/t/error-report-check-database-did-not-work/25796
indicate that the previous solution has not helped, and has just made things
worse. My guess is that AppNap on macOS is preventing the timer from even
running before the file gets cleaned up.
2022-12-30 15:30:53 +10:00
Damien Elmes
766e28d64d Clean up build artifacts between runs 2022-12-30 15:22:11 +10:00
Hikaru Y
be6d1dfb66
Work around issue with entering text around MathJax via IME (#2288)
* Add 'placement' property

* Extract logic for moving text node into instance method

... so that it can be used elsewhere.

* Add writable store to indicate whether composition session is active

* Work around issue with entering text around MathJax via IME

* Make get() called only once while composition session is active
2022-12-30 13:32:41 +10:00
Ren Tatsumoto
7d22053730
Mention how to fix build crash in the readme. (#2286)
* update linux.md

mention how to fix libcrypt.so.1-related build crash

* Mention Fedora as well (dae)
2022-12-30 13:10:37 +10:00
Damien Elmes
4c5a2461d0 Handle broken utimes() on Android
Closes https://github.com/ankidroid/Anki-Android/issues/12827
Closes https://github.com/ankidroid/Anki-Android/issues/12974
2022-12-28 16:33:06 +10:00
Damien Elmes
272d53079f Pad buttons instead of using min-width
Qt seems to be treating min-width more like width, and truncates text.
The issue is not limited to macOS with force_custom_styles: with a
sufficiently large amount of text on a button, it truncates on other
platforms too.

https://forums.ankiweb.net/t/2-1-55-issue-with-auto-browser-and-upload-download-dialog/25636

There are a few other uses of min-width in the styling - it may be worth
checking whether they suffer from the same issue as well.
2022-12-28 12:04:44 +10:00
Damien Elmes
b415c7a9a5 Formatting tweak
Triggered by './ninja format', though curiously it did not get picked
up in a check.
2022-12-28 11:53:21 +10:00