Commit graph

33 commits

Author SHA1 Message Date
Abdo
8764e39062 Fix field focus lost when pressing alt in the editor (#3378) 2024-08-29 17:32:24 +07:00
David Culley
59fb88588d Update type annotations to use | operator (#3323)
* refactor: update to `|` operator

* refactor: add missing type hint

* refactor: enable `|` operator for older versions

* refactor: remove obsolete import
2024-07-26 18:15:39 +07:00
David Culley
5be8f423f2 Update type annotation syntax (#3283)
* chore: add myself to CONTRIBUTORS file

* refactor: use newer type hints for Union/Optional

* refactor: fix deprecated type annotations

use collections.abc rather than typing

* refactor: use lower letter type annotations

* style: reformat with black

* refactor: remove unused imports

* refactor: add missing imports for type hints

* fixup! refactor: use newer type hints for Union/Optional

* fix: add missing imports for type annotations

* fixup! refactor: use newer type hints for Union/Optional

* fixup! style: reformat with black

* refactor: fix remaining imports re: type hints
2024-07-21 14:00:52 +07:00
Damien Elmes
e81c49032f Apply same ctrl+numpad enter fix that the add screen has
Likely regression in the switch to a main window
2023-10-26 11:57:37 +10:00
Abdo
c3150b2b35 Turn edit window into a QMainWindow (#2732)
* Turn edit window into a QMainWindow

* Ensure dialog is garbage collected (dae)
2023-10-14 10:29:57 +10:00
Mani
2f204f8e8b image occlusion button in note editor (#2485)
* setup mask editor in note editor
- add image on mask button click (only one time)
- show hide add button for io on notetype change
- hide field in io notetype
- icon for toggle
and replace image

* add update io notes

* Tidy up i/o notetype check and fix error

- Make it a method on editor
- Use .get(), because the setting doesn't exist on older notetypes
- Pass the bool value into the ts code, instead of the enum

* reset io page after adding

* remove adjust function & add target for mask editor

* handle browse mode & merged sidetoolbar and toptoolbar to toolbar

* fix: shape, button click in browse, dropdown menu

* add arrow to add button

* store for handling visiblity of maskeditor
- remove update  button in edit mode, implement autoupdate

* update var name

* simplify store
2023-07-27 22:45:49 +10:00
Damien Elmes
7ef1dd781e PEP8 editorMode 2022-01-12 15:01:43 +10:00
Henrik Giesel
f5ecf063a3 Split/Merge editor.py for its three use cases (#1581)
* Forbid inserting object and iframe tags via PlainTextInput

* Add optional browserMode parameter to Editor

* Create new ts modules for three editor instances

- note-creator for AddCards
- browser-editor for the editor in the Browser
- reviewer-editor for the EditCurrent

* Revert "Forbid inserting object and iframe tags via PlainTextInput"

This reverts commit ab90ae8194494d883a1863126496e2d8f332509e.

* Refactor browserMode to editorMode

* Move new editor variants inside /ts/editor directory

* Fix typo
2022-01-12 14:51:43 +10:00
Damien Elmes
631c345ef0 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
Damien Elmes
aaba9a777a fix note changes triggering a queue rebuild 2021-06-08 12:09:35 +10:00
Damien Elmes
c3b0fb35b7 more perform_op() tweaks
- pass the handler directly
- reviewer special-cases for flags and notes are now applied at
call site
- drop the kind attribute on OpChanges which is not needed
2021-04-06 10:14:11 +10:00
Damien Elmes
3ab53c77c7 add booleans for various screens to OpChanges
The backend knows exactly which op has executed, and it saves us having
to re-implement this logic on each client.

Fixes the browser table refreshing when toggling decks.
2021-04-05 14:28:56 +10:00
Damien Elmes
12c1a570ac allow ops to pass metadata into perform_op()
Instances can pass handled_by=self to more easily ignore events they
initiate.

Fixes ugly refresh when expanding/collapsing decks, but we're still
refreshing the card/notes area unnecessarily in that case.
2021-04-05 13:43:09 +10:00
Damien Elmes
1df14f7c9c update no-arg tr references in qt/ 2021-03-26 13:48:26 +10:00
Damien Elmes
3ba9932779 decorator for saveNow(), mkII
Mostly @RumovZ's work from https://github.com/ankitects/anki/pull/1066,
with a workaround for the issue encountered on
18a8d458bb

Fix is to use pyqtSlot() to specify the slot signature, as described
on https://stackoverflow.com/questions/44371451/python-pyqt-qt-qmenu-qaction-syntax

Also renamed saveNow() for PEP8, but have not updated all the existing
calls to use the decorator yet - might be easiest to do at the same time
as perform_op() calls are added.
2021-03-19 19:45:21 +10:00
Damien Elmes
1c0bc67fd9 prevent editor from refreshing itself after a save
- add after_hooks arg to perform_op()
- when refreshing browse screen, just redraws cells, and handle
editor update in Browser instead of the model
2021-03-19 19:45:21 +10:00
Damien Elmes
b1350727fc commit immediately when there's no active checkpoint
Reviews and operations on the backend that support undoing can now be
committed immediately, so they will not be lost in the event of a crash.

This required tweaks to a few places:

- don't set collection mtime on save() unless changes were made in
Python, as otherwise we end up accidentally clearing the backend undo
queue
- autosave() is now run on every reset()
- garbage collection now runs in a timer, instead of relying on
autosave() to be run periodically
2021-03-10 11:47:53 +10:00
Damien Elmes
bf7528d90a minor code cleanups with pyupgrade
- pyupgrade --py38-plus --keep-runtime-typing --keep-percent-format
- third-party mpv and winpaths excluded
2021-02-11 09:43:40 +10:00
Damien Elmes
6c60a27c8b add remaining types and disable missing types on (almost) all aqt 2021-02-03 00:00:29 +10:00
Damien Elmes
748aeb9df1 add a bunch of return types 2021-02-01 23:53:23 +10:00
Damien Elmes
83892eac51 add types to various other files
Mainly automated with MonkeyType
2021-02-01 22:08:56 +10:00
Damien Elmes
8075d46011 convert setWindowFlags call into helper, and fix invalid variables
"type: ignore" was masking the invalid references to self in places
like showText()
2021-01-07 14:24:49 +10:00
BlueGreenMagick
9a29d1b97a remove context help button 2021-01-06 22:15:48 +09:00
Damien Elmes
7e655614b2 fix remaining _() references; remove unused imports 2020-11-18 12:43:46 +10:00
Damien Elmes
066b1498ae merge bulk of qt/ - designer files still to do 2020-11-17 17:42:43 +10:00
Henrik Giesel
747c8532c2 Create ResetReason enum 2020-08-16 18:56:32 +02:00
Henrik Giesel
7bb4df13d9 Reorder + make all parameters optional 2020-08-16 18:56:32 +02:00
Henrik Giesel
0b9d7b2cb8 Satisfy formatter 2020-08-16 18:56:32 +02:00
Henrik Giesel
ea6eb2ba3b Add new use of requireReset 2020-08-16 18:56:32 +02:00
Damien Elmes
20db4ab2f3 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
8bad40152d remove _hook/_filter suffix 2020-01-15 16:53:24 +10:00
Damien Elmes
32edb4522d migrate addHook/remHook calls 2020-01-15 13:49:26 +10:00
Damien Elmes
2a00e0a6b0 tweaking the folder names again
hopefully that's the last of it
2020-01-03 07:48:38 +10:00
Renamed from anki-qt/aqt/editcurrent.py (Browse further)