Commit graph

2647 commits

Author SHA1 Message Date
Damien Elmes
51bb18209f clarify QueryOp docstring
Maybe there's a better name we could use than QueryOp - suggestions
welcome.
2021-12-04 08:55:11 +10:00
Damien Elmes
cfbbfdcadc use QueryOp for unused media deletion
Closes #1517
2021-12-04 08:55:11 +10:00
Damien Elmes
d89fbf7f28 QueryOp() was attempting to open progress window on background thread 2021-12-04 08:55:11 +10:00
Matthias Metelka
a4995333ac Fix bug(s) caused by deleting a notetype currently selected in AddCards (#1514)
* Remove unneeded old.note_type() call

Fixes TypeError thrown after deleting a notetype that's currently selected in the editor.

* Handle IndexError on notetype change

Occurs in the Add window when changing the notetype via NotetypeChooser from
- the notetype that's auto-selected after deleting the currently selected notetype
- to a notetype with fewer fields than the auto-selected one

* Add return to exception handler

to properly ignore the command.
2021-12-04 07:55:22 +10:00
Damien Elmes
e5333ceb85 update PyOxidizer 2021-12-03 21:00:15 +10:00
Abdo
726642f782 Adjust arrows direction for RTL layouts in previewer (#1513) 2021-11-29 12:41:08 +10:00
Hikaru Y
a3c36a530b Fix memory leak in AnkiWebView (#1510) 2021-11-29 12:31:37 +10:00
RumovZ
7c2e0ab2d4 Remove redundant camelcase aliases (#1509) 2021-11-26 12:29:48 +10:00
Damien Elmes
cbf14b16c4 move aqt/platform.py code into theme.py
We have other platform-specific code scattered through the codebase,
and better it lives in a location where it is used.
2021-11-25 19:10:57 +10:00
Damien Elmes
2898a46e54 convert invariant assertions to if statements
The packaged builds of 2.1.50 use python -OO, which means our assertion
statements won't be run. This is not an issue for unit tests (as we
don't run them from a packaged build), or for type assertions (which are
added for mypy's benefit), but we do need to ensure that invariant checks
are still run.
2021-11-25 17:47:50 +10:00
Damien Elmes
5d721e8893 fix check for user exporting into data folder on Windows
https://forums.ankiweb.net/t/unable-to-export-colpkg-file/10527
2021-11-25 09:30:17 +10:00
Damien Elmes
0e4c02eac1 update platform checks (eg isWin -> is_win) + devMode 2021-11-25 09:06:16 +10:00
Damien Elmes
270eaa4478 avoid duplicate work in overview screen 2021-11-25 09:01:02 +10:00
Damien Elmes
b1575f9a63 minor docstring fix 2021-11-25 08:57:33 +10:00
Damien Elmes
0d46cb7fd9 add minimal theme detection on Linux
Closes #1116
2021-11-25 08:45:14 +10:00
RumovZ
54d39d1b3b Live theme changes (#1497)
* Allow theme change at runtime and add hook

* Save or restore default palette on theme change

* Update aqt widget styles on theme change

* styling fixes

- drop _light_palette, as default_palette serves the same purpose
- save default platform theme, and restore it when switching away
from nightmode
- update macOS light/dark mode on theme switch
- fix unreadable menus on Windows

* update night-mode classes on theme change

This is the easy part - CSS styling that uses standard_css or our
css variables should update automatically. The main remaining issue
is JS code that sets colors based on the theme at the time it's run -
eg the graph code, and the editor.

* switch night mode value on toggle

* expose current theme via a store; switch graphs to use it

https://github.com/ankitects/anki/issues/1471#issuecomment-972402492

* start using currentTheme in editor/components

This fixes basic editing - there are still components that need updating.

* add simple xcodeproj for code completion

* add helper to get currently-active system theme on macOS

* fix setCurrentTheme not being immediately available

* live update tag color

* style().name() doesn't work on Qt5

* automatic theme switching on Windows/Mac

* currentTheme -> pageTheme

* Replace `nightModeKey` with `pageTheme`

Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2021-11-25 07:17:41 +10:00
Damien Elmes
db4a15eea6 change previous card info shortcut
https://forums.ankiweb.net/t/option-i-shortcut-conflicts-with-language-input/15206
2021-11-24 15:44:25 +10:00
Damien Elmes
a705b72c46 retire the v1 scheduler 2021-11-24 14:12:56 +10:00
Matthias Metelka
e2a30666e4 Change Notetype UI Rework (#1499)
* Enable access to old notetype name

* Set minimum height for ChangeNotetypeDialog

* Add bootstrap icons to change-notetype

* Move alert up and make it collapsible

* Tweak some CSS

- Add variables --sticky-bg and --sticky-border to StickyContainer
- Tweak base.css

* Add translatable string "(Nothing)"

* Rework ChangeNotetype screen

* Initially load option at newIndex and remaining options on focus

Optimization for big notetypes:
Should increase efficiency from O(n²) to O(n). Test on notetype with 500 templates shows significant improvement in load time (~10s down to ~1s).

* Try to satisfy rust test

* Change arrow direction depending on reading direction

+ add 0.5em top padding to main

* Create Alert.svelte

* Introduce CSS variable --pane-bg

* Revert "Initially load option at newIndex and remaining options on focus"

This reverts commit f42beee45c.

* Final cleanup

* Refine padding/gutter
2021-11-24 12:09:55 +10:00
Damien Elmes
a47ae935bf minor wording tweaks and a docstring 2021-11-23 12:18:50 +10:00
evandrocoan
6dfd9665b2 Fix issue 1362 and add a default favicon.ico (#1369) 2021-11-23 12:18:32 +10:00
Damien Elmes
8acc482848 drop beta tag from v3 scheduler
Will exit beta when 2.1.50 is released as stable
2021-11-23 11:10:04 +10:00
Arthur Milchior
a93fad57d9 Remove all_names in notetypechooser (#1501)
The only purpose is to stop having warning in my console because all_names is deprecated
2021-11-23 10:27:57 +10:00
Damien Elmes
bf11b3419d SELinux fixes
https://forums.ankiweb.net/t/anki-installer-for-linux-install-sh-should-change-file-owners-and-selinux-labels-while-installation/15143
2021-11-22 11:06:21 +10:00
Damien Elmes
1ac84d9454 update to edition 2021 2021-11-18 20:51:10 +10:00
RumovZ
c1c9b6c065 Fix close button for add cards dialog (#1496) 2021-11-18 07:22:23 +10:00
Abdo
100cf54f40 Add hotkey to save add-on config (#1492) 2021-11-17 07:18:48 +10:00
Abdo
ef5b577189 Fix duplicate conflicting add-on names being shown (#1489) 2021-11-14 11:36:32 +10:00
RumovZ
87b851bde2 Add fullscreen shortcut (#1488) 2021-11-14 11:35:43 +10:00
RumovZ
120909f1d9 Make add cards dialog a main window (#1486)
Closes #980.
2021-11-14 11:33:59 +10:00
Damien Elmes
10e902150e when a post handler fails, log the traceback to the console
https://forums.ankiweb.net/t/cant-change-note-type/14809
2021-11-12 11:54:13 +10:00
Damien Elmes
3d9e52a635 fix profile with older keys being reported as corrupt
Older Anki versions like 2.1.35 used sip 5.2, which appears to
(presumably incorrectly) serialize QByteArrays as Unicode:

    0: (    MARK
    1: d        DICT       (MARK at 0)
    2: p    PUT        0
    5: V    UNICODE    'mainWindowGeom'
   21: p    PUT        1
   24: c    GLOBAL     'sip _unpickle_type'
   44: p    PUT        2
   47: (    MARK
   48: V        UNICODE    'PyQt5.QtCore'
   62: p        PUT        3
   65: V        UNICODE    'QByteArray'
   77: p        PUT        4
   80: (        MARK
   81: c            GLOBAL     '_codecs encode'
   97: p            PUT        5
  100: (            MARK
  101: V                UNICODE    "[...]"
  354: p                PUT        6
  357: V                UNICODE    'latin1'
  365: p                PUT        7
  368: t                TUPLE      (MARK at 100)

Our unpickle_type() was incorrectly ignoring any non-PyQt class when
unpickling, so it was choking on the reference to _codecs.
2021-11-06 09:44:00 +10:00
Matthias Metelka
1592fd0295 Editor Field Descriptions (#1476)
* Add description input to fields dialog

QLineEdit seems like the best option, as it saves space and motivates users to keep their descriptions concise.

* Add setDescriptions to note initialization script

Went for the extra function instead of including it in setFields to prevent potential add-on breakages.

* Add tooltip next to field name if description is set

* Refactor code according to suggestions

Set default tooltip placement to right instead of bottom

Use .get() for fld["description"]

Fix tab order in fields dialog

Swap out abbreviation "desc" for full length name to keep consistency

* Update Protobuf and Rust for description

Add description to notetypes.proto and schema11

Co-authored-by: RumovZ <RumovZ@users.noreply.github.com>

* Fix tooltips not updating with description

Remove redundant variable tooltipOptions

Update previousTooltip within reactive function

* Move LabelDescription out of LabelName

Co-authored-by: Henrik Giesel <hgiesel@users.noreply.github.com>

* Decrease icon size and fix alignment

Co-Authored-By: Henrik Giesel <hengiesel@gmail.com>

* the new key needs to be cleared from fields, not the notetype itself

Co-authored-by: RumovZ <RumovZ@users.noreply.github.com>
Co-authored-by: Henrik Giesel <hengiesel@gmail.com>
Co-authored-by: Damien Elmes <gpg@ankiweb.net>
2021-11-06 09:42:48 +10:00
Henrik Giesel
b97dc23b96 Several editor fixes (#1478)
* Declare toolbar api via modifiable property

* Fix addon buttons

* Assign editing areas in a synchronous way

* Restore the Tab shortcut that moves the caret to end

- moveCaretToEnd is called twice now: The moveCaretToEnd calls in
  *TextInput causes the caret to be moved to the end when switching back
  from the window and back.
- To fix this, I will need the code for saving and restoring locations
  from #1377

* Restore selections in the PlainTextInput

* Improve type safety of destroyable

- clearable-array was renamed to destroyable
2021-11-05 11:29:02 +10:00
Abdo
854fd71c26 Fix invalid path in cargo-env.bat (#1477)
* Fix invalid path in cargo-env.bat

* Assume cargo-env.bat is run from repo root; fix package script (dae)

* mention cargo-raze doesn't work on Windows (dae)
2021-11-05 11:08:23 +10:00
Henrik Giesel
d74c38abe5 Several CSS fixes - Editor Cleanup (#1470)
* Refactor editor css, fix editor button highlight

- Avoid using webview.css
- Move more buttons css into button_mixins

* Fix DropdownItem appearance

* Fix the visuals of tags

* Make dropdown font slightly smaller

* Give SelectOption a background color

* Move some css from deck-options-base to CardStateCustomizer

* Avoid using core.scss for CardStats

* Avoid using sass/core in congrats package

* Inline core.scss into webview.scss

* Include fusion-vars for base.scss

* need to keep core.scss around for now (dae)
2021-10-31 08:29:22 +10:00
Damien Elmes
8ef362e7ed fix scripts/mypy*
Broken in switch to rules_python
2021-10-30 09:14:43 +10:00
Damien Elmes
455e0ce63b fix sort order toggling
We're getting an enum instead of an int in Qt6

normal/reversed have been renamed to ascending/descending; no add-ons
appear to be using the old versions.
2021-10-30 09:14:43 +10:00
Damien Elmes
670690fd64 fix broken startup on macOS due to incorrect mpv path 2021-10-30 09:14:43 +10:00
Damien Elmes
ce12b00c8e fix missing protobuf C extension on darwin-arm 2021-10-30 09:14:43 +10:00
RumovZ
e49b81bf88 Disable renaming of no-flag item (#1467) 2021-10-30 09:08:51 +10:00
Damien Elmes
0facadcf91 ignore requested graphics driver on Qt6 for now 2021-10-29 19:34:05 +10:00
Damien Elmes
a3c7628931 avoid printing compat warning on Qt5 2021-10-29 19:29:12 +10:00
Damien Elmes
c0a812cf9a tweaks for Linux package 2021-10-29 19:26:35 +10:00
Damien Elmes
56e432cf16 tweaks for Windows package
- move audio tools into subfolder
- add buildmanifest.py
2021-10-29 18:11:28 +10:00
Damien Elmes
951339a6fa show warning instead of crashing when recording on darwin-arm64 2021-10-29 14:43:59 +10:00
Damien Elmes
6774f81895 rename some of the files in aqt/qt/ 2021-10-29 13:54:24 +10:00
Damien Elmes
5f929cc959 add a flag to disable PyQt5 compat 2021-10-29 10:08:07 +10:00
Damien Elmes
62ec17adc6 fix missing icons in browse screen
Introduced in 4a0fa32d3c
2021-10-29 10:08:07 +10:00
Damien Elmes
4a0fa32d3c print a deprecation warning for old-style enums
https://github.com/ankitects/anki/pull/1440#issuecomment-948622876
2021-10-28 20:21:52 +10:00