Commit Graph

9795 Commits

Author SHA1 Message Date
Damien Elmes
41b329aa05 Fix alternate table row color on macOS
https://forums.ankiweb.net/t/anki-2-1-55-beta-3/24295/102
2022-12-03 22:21:22 +10:00
Damien Elmes
fa4fc3e15a Probable workaround for mpv failing after a few days on macOS
Also fix the certifi bumper: it was supposed to repeat
2022-12-03 22:11:39 +10:00
Damien Elmes
1a444f30e9 Fix formatting inside selection not being removed
Regression introduced in #2017 while fixing another bug.

Closes #2072
2022-12-03 21:41:54 +10:00
Damien Elmes
509e0a9811 Try to address crashes on shutdown
I was able to reproduce the crashes fairly reliably by opening the
prefs screen on startup and shutting down the app after 600ms; after
this change the crashes no longer seem to occur.
2022-12-03 19:33:51 +10:00
Damien Elmes
df38bc627c Stop removing build file
Since we reconfigure automatically, this should no longer be necessary.
2022-12-03 19:32:07 +10:00
RumovZ
90a3bbfdb8
Cap calculated hard delay secs at again delay + 1d (#2229) 2022-12-03 18:54:40 +10:00
Damien Elmes
f623ab5317 Automatically regenerate build.ninja and re-run when build fails quickly 2022-12-01 19:40:49 +10:00
Matthias Metelka
9c45a2f7d0
Refactor Select component | Fix CSV import issue (#2227)
* Refactor Select component and implement/update it in various screens

* Remove redundant select CSS

* Tweak DeckOptionsPage

* Fix CSV import layout

* Fix save button margin in change notetype screen

* Fix sticky header positioning

* Remove unused imports

* Make StickyHeader sticky instead of fixed
2022-12-01 19:24:26 +10:00
Matthias Metelka
9ecc0ffdc6
Use third grid column in graphs layout on wide screens (#2226)
* Use third grid column on graphs page when width > 1400px

* Define column width more precisely

* Center graphs inside containers

* Fix graphs always showing 2+ columns (dae)
2022-12-01 16:33:52 +10:00
Matthias Metelka
49455b4b14
Tweak scrollbar colors for better visibility in dark theme (#2225) 2022-12-01 16:15:17 +10:00
Matthias Metelka
a48c96559d
Fix glitchy animation of floating elements (#2224)
* Set max-height of 400px to scrollable Popover

* Pass computed placement to user components

to set different animation directions when the placement changes.

* Move elevation effect from WithFloating/WithOverlay to Popover

* Apply same changes as in WithFloating to WithOverlay

* Adjust FloatingArrow CSS to Popover

* Run eslint and formatter
2022-12-01 15:45:52 +10:00
Matthias Metelka
1ab4ee38c6
Refactor SpinBox component (#2223)
this fixes the increment button not showing.
2022-12-01 15:34:54 +10:00
Damien Elmes
5dc79e22cd Avoid setting RTL on first run
I'm not sure why, but this seems to address the first issue mentioned on
https://forums.ankiweb.net/t/anki-2-1-55-beta-5/24870/58
2022-11-30 19:19:22 +10:00
Damien Elmes
670bf1ef9a Fix cargo-deny exclusion 2022-11-30 13:52:49 +10:00
Damien Elmes
526707473a Enable cargo-deny in CI
We have quite a few duplicate crate deps at the moment, so those warnings
are currently disabled.
2022-11-30 13:20:50 +10:00
Damien Elmes
e3167c4e3c Update incompatible crates 2022-11-30 12:38:10 +10:00
Damien Elmes
b4f4df0030 Pin chrono; update compatible Rust crates
Also pin reqwest in our other crates
2022-11-30 12:38:10 +10:00
Damien Elmes
b7e04381a0 Add cargo-deny config
Not currently enabled in CI; will probably want to exclude the duplicates
from the warnings.
2022-11-30 12:38:10 +10:00
Damien Elmes
0ac7969e2a Use workspace package info in more crates; mark private for cargo-deny 2022-11-30 12:19:56 +10:00
Damien Elmes
50992972d8 Remove unused cargo config in qt/bundle 2022-11-30 11:37:20 +10:00
Matthias Metelka
43ce4cacc6
Give containers brighter color than canvas (#2220)
* Give deck browser table an elevated container look

* Tweak colors of elevated containers (e.g. in deck options)

* Prepare editor fields for custom backgrounds

* Tweak field margin and add explanatory comment
2022-11-29 17:54:42 +10:00
Damien Elmes
65b8b8c69b Fix typechecking error on Windows 2022-11-29 13:28:57 +10:00
Damien Elmes
a70f8d4dd5 Fix TTS handling on Windows
Also update to winsdk, which unblocks Python updates on Windows
2022-11-29 13:04:51 +10:00
Damien Elmes
ca1166990c Update translations 2022-11-28 20:58:14 +10:00
BlueGreenMagick
dd2549564a
use BUTTON_BG for button background (#2217) 2022-11-28 20:53:07 +10:00
Matthias Metelka
4dc91c6ebf
Use less specific html selector to not override user CSS (#2218) 2022-11-28 20:52:19 +10:00
Damien Elmes
3b8a7ab132 Fix clippy warning 2022-11-28 14:42:03 +10:00
Damien Elmes
29adf9eee0 Fix submodule sync when nested in another repo on Windows 2022-11-28 14:37:50 +10:00
Damien Elmes
b2049209ff Re-enable formatting for .ts files
There are some style differences compared to prettier, and not all are
necessarily an improvement, but it's much faster now.
2022-11-28 09:33:04 +10:00
Damien Elmes
ea5153e7a4 Re-enable formatting for .svelte files 2022-11-28 09:17:39 +10:00
Damien Elmes
e497a56f54 Re-enable formatting for .toml files 2022-11-28 09:16:28 +10:00
Damien Elmes
7972708029 Remove rslib cargo config
Was added during initial Bazel experimentation back in 2020
2022-11-27 17:50:36 +10:00
Damien Elmes
c45c1a354c Add missing qt dep to mypy/pylint 2022-11-27 16:45:58 +10:00
Damien Elmes
1e573de63a Update Linux docs 2022-11-27 16:45:54 +10:00
Damien Elmes
1aae621549 Update dockerfile
- Bazel no longer required
- Python no longer required
- Add back the import check step that got lost at one point
2022-11-27 16:45:50 +10:00
Damien Elmes
5e0a761b87
Move away from Bazel (#2202)
(for upgrading users, please see the notes at the bottom)

Bazel brought a lot of nice things to the table, such as rebuilds based on
content changes instead of modification times, caching of build products,
detection of incorrect build rules via a sandbox, and so on. Rewriting the build
in Bazel was also an opportunity to improve on the Makefile-based build we had
prior, which was pretty poor: most dependencies were external or not pinned, and
the build graph was poorly defined and mostly serialized. It was not uncommon
for fresh checkouts to fail due to floating dependencies, or for things to break
when trying to switch to an older commit.

For day-to-day development, I think Bazel served us reasonably well - we could
generally switch between branches while being confident that builds would be
correct and reasonably fast, and not require full rebuilds (except on Windows,
where the lack of a sandbox and the TS rules would cause build breakages when TS
files were renamed/removed).

Bazel achieves that reliability by defining rules for each programming language
that define how source files should be turned into outputs. For the rules to
work with Bazel's sandboxing approach, they often have to reimplement or
partially bypass the standard tools that each programming language provides. The
Rust rules call Rust's compiler directly for example, instead of using Cargo,
and the Python rules extract each PyPi package into a separate folder that gets
added to sys.path.

These separate language rules allow proper declaration of inputs and outputs,
and offer some advantages such as caching of build products and fine-grained
dependency installation. But they also bring some downsides:

- The rules don't always support use-cases/platforms that the standard language
tools do, meaning they need to be patched to be used. I've had to contribute a
number of patches to the Rust, Python and JS rules to unblock various issues.
- The dependencies we use with each language sometimes make assumptions that do
not hold in Bazel, meaning they either need to be pinned or patched, or the
language rules need to be adjusted to accommodate them.

I was hopeful that after the initial setup work, things would be relatively
smooth-sailing. Unfortunately, that has not proved to be the case. Things
frequently broke when dependencies or the language rules were updated, and I
began to get frustrated at the amount of Anki development time I was instead
spending on build system upkeep. It's now about 2 years since switching to
Bazel, and I think it's time to cut losses, and switch to something else that's
a better fit.

The new build system is based on a small build tool called Ninja, and some
custom Rust code in build/. This means that to build Anki, Bazel is no longer
required, but Ninja and Rust need to be installed on your system. Python and
Node toolchains are automatically downloaded like in Bazel.

This new build system should result in faster builds in some cases:

- Because we're using cargo to build now, Rust builds are able to take advantage
of pipelining and incremental debug builds, which we didn't have with Bazel.
It's also easier to override the default linker on Linux/macOS, which can
further improve speeds.
- External Rust crates are now built with opt=1, which improves performance
of debug builds.
- Esbuild is now used to transpile TypeScript, instead of invoking the TypeScript
compiler. This results in faster builds, by deferring typechecking to test/check
time, and by allowing more work to happen in parallel.

As an example of the differences, when testing with the mold linker on Linux,
adding a new message to tags.proto (which triggers a recompile of the bulk of
the Rust and TypeScript code) results in a compile that goes from about 22s on
Bazel to about 7s in the new system. With the standard linker, it's about 9s.

Some other changes of note:

- Our Rust workspace now uses cargo-hakari to ensure all packages agree on
available features, preventing unnecessary rebuilds.
- pylib/anki is now a PEP420 implicit namespace, avoiding the need to merge
source files and generated files into a single folder for running. By telling
VSCode about the extra search path, code completion now works with generated
files without needing to symlink them into the source folder.
- qt/aqt can't use PEP420 as it's difficult to get rid of aqt/__init__.py.
Instead, the generated files are now placed in a separate _aqt package that's
added to the path.
- ts/lib is now exposed as @tslib, so the source code and generated code can be
provided under the same namespace without a merging step.
- MyPy and PyLint are now invoked once for the entire codebase.
- dprint will be used to format TypeScript/json files in the future instead of
the slower prettier (currently turned off to avoid causing conflicts). It can
automatically defer to prettier when formatting Svelte files.
- svelte-check is now used for typechecking our Svelte code, which revealed a
few typing issues that went undetected with the old system.
- The Jest unit tests now work on Windows as well.

If you're upgrading from Bazel, updated usage instructions are in docs/development.md and docs/build.md. A summary of the changes:

- please remove node_modules and .bazel
- install rustup (https://rustup.rs/)
- install rsync if not already installed  (on windows, use pacman - see docs/windows.md)
- install Ninja (unzip from https://github.com/ninja-build/ninja/releases/tag/v1.11.1 and
  place on your path, or from your distro/homebrew if it's 1.10+)
- update .vscode/settings.json from .vscode.dist
2022-11-27 15:24:20 +10:00
Matthias Metelka
88362ba1f7
Make dropdown text smaller than page text by default (#2216) 2022-11-27 10:47:31 +10:00
Matthias Metelka
6c6a10c142
Fix some issues with the Tag Editor (#2215)
* Prevent global focus border on tag-input

* Fix margin issues with tag editor

* Remove redundant autocomplete call

that caused the addition of an empty tag when tag suggestions were selected with the Enter key.

* Prevent input text from overlapping with newly added tags

... at least when they're selected from the autocomplete list via mouse. If they're selected via keyboard, there's still an overlapping issue.

* Fix error on updateSuggestions

* Hide empty tag

* Make double-click to collapse/expand translatable
2022-11-27 10:45:33 +10:00
Hikaru Y
8f2f62c466
Fix shortcuts for tag actions not working (#2214) 2022-11-27 10:29:58 +10:00
Matthias Metelka
b40aae7522
Set overscroll-behavior to none for html elements (#2212) 2022-11-24 20:37:31 +10:00
Matthias Metelka
0d541563a0
Add platform-specific classes to body of ts pages (#2211) 2022-11-24 20:37:01 +10:00
Stefan Kangas
5551a37f03
Fix typos (#2210) 2022-11-24 20:18:57 +10:00
Damien Elmes
fa9ab5ee3f Update translations 2022-11-23 18:52:09 +10:00
Damien Elmes
b7e3d9fbfc Probable fix for "unknown error"
(cherry picked from commit b56835511865cb0e76be012e6aeff721d68fb203)
2022-11-23 18:51:56 +10:00
Yoshi
80598f12ed
Pass addon name to config edit hook (#2205)
* Pass addon name to config edit hook

* Deprecate old hook instead of replacing it
2022-11-23 18:00:28 +10:00
Matthias Metelka
365c5e1fb2
UI size tweaks (#2184)
* Reduce font size of answer button indicators

* Increase padding of browser rows with ResizeToContents on vertical header

* Remove 0.8 scale factor for dropdown item font-size

* Remove font-size prop entirely from DropdownItem

* Revert "Remove font-size prop entirely from DropdownItem"

This reverts commit bb0a158f96183cca74e198867070c2f99af04dc4.

* Remove hard-coded Python font sizes

* Move font size and scrollbar into _root-vars.scss

* Revert editor size variable to 1.6

* Fix icon alignment

* Fix checkbox alignment for dropdown items

* Remove unused classes from Tag.svelte

* Revert "Increase padding of browser rows with ResizeToContents on vertical header"

This reverts commit 77bfc854ba140dd99aae98efcdd4af7052615fa6.

* Remove option to set font size of browser entries

* Add setting for browser row padding to preferences

* Revert "Add setting for browser row padding to preferences"

This reverts commit 75c59da65a1028e2caa3c48b247f99825c1b0b6c.

* Revert "Remove option to set font size of browser entries"

This reverts commit a543783d8ea079f39b7ae445152573c96be29841.
2022-11-23 16:50:15 +10:00
Matthias Metelka
fdfdd67c3a
Revert to pseudo-element approach for field description (#2209)
* Revert to pseudo-element approach for field description

to ensure it changes on update.

* Simplify CSS
2022-11-23 16:37:12 +10:00
Matthias Metelka
7768262086
Remove unneeded spacers (#2208) 2022-11-23 16:35:23 +10:00
Matthias Metelka
e9430fde3b
Give OptionsButton its own ButtonGroup and move it to more prominent position (#2207)
and give it some padding
2022-11-23 16:18:29 +10:00
Matthias Metelka
fba46e9815
Fix Floating Ui error causing freezes on image resize (#2206)
* Replace autoPlacement with flip

* Remove logic made redundant by use of flip()

* Edit preferred placement on components using WithFloating

* Rename placement to preferredPlacement

* Set "bottom" as default placement and remove redundant declarations
2022-11-23 16:16:09 +10:00