Commit Graph

1272 Commits

Author SHA1 Message Date
Wilco Greven
9b10e3f43e Set applicationName and desktopFileName before instantiating the application.
When these are set after instantiating the application Anki will load both
$XDG CONFIG HOME/.config/Ankirc and $XDG CONFIG HOME/.config/ankirc.
2019-07-20 13:10:59 +02:00
Wilco Greven
ffab5d31d4 Set the desktop file name.
Otherwise, on Wayland, Anki will look for python3.desktop This fixes the window icon.
2019-07-18 23:14:34 +02:00
Damien Elmes
4f819d06ec display a more helpful message when base folder not readable in startup 2019-07-17 17:23:22 +10:00
Damien Elmes
95387af2cd cleanup recording on cancel 2019-07-14 11:19:29 +10:00
Damien Elmes
7a9508ea75 force default button in record dialog
https://anki.tenderapp.com/discussions/ankidesktop/34985-make-save-the-default-option-when-recording-audio
2019-07-12 17:37:25 +10:00
Damien Elmes
7b93e9855e quieten local port message for now
the race condition that is causing this still needs to be investigated
2019-06-27 10:01:23 +10:00
Damien Elmes
c7201b0c3a prefix non-breaking spaces
https://anki.tenderapp.com/discussions/ankidesktop/34512-first-space-is-omitted-when-pasting
2019-06-10 09:41:29 +10:00
Damien Elmes
1a6de042df fix __renderPage() being called twice 2019-06-01 16:35:19 +10:00
Lovac42
a803f4afee added runHooks for reverted cards and state. 2019-05-17 20:17:36 -04:00
Damien Elmes
1c47eb73d0 fix preview failing to appear when 'show both sides' enabled 2019-05-17 15:16:13 +10:00
Damien Elmes
1f36a7112f don't error out when non-latin characters written to js console
(some?) macOS users have an ascii encoding, so we need to escape
the non-ascii portions prior to writing
2019-05-17 08:43:25 +10:00
Damien Elmes
0008e6cb3f
Merge pull request #306 from lovac42/master
doubleclick addman list
2019-05-15 15:58:43 +10:00
Damien Elmes
86d9b57877 prevent deck chooser from becoming default
Qt's behaviour seems to have changed in move to 5.12
2019-05-15 14:50:55 +10:00
lovac42
f41e791c5a
doubleclick addman list
doubleclick on addon manager list opens conf editor.
2019-05-13 17:27:27 -04:00
Damien Elmes
9ce1f051cc catch add-on deletion failure due to locked files in add-on folder
https://anki.tenderapp.com/discussions/add-ons/32676-2112
2019-04-29 18:43:10 +10:00
Damien Elmes
8a63b4712c on serverAbort, return early
- fixes error attempting to access self.client.hostNum
- prevents media sync from running
2019-04-29 18:27:00 +10:00
Damien Elmes
3716feb1c4 fix 'open backup' opening to an empty deck list
Starting the import in a timer could cause the collection to be unloaded
while the deck list was being displayed, leading to an inconsistent
state.

The timer was originally required to avoid importing on startup,
but profile load is already delayed until after startup these days,
so the workaround should no longer be necessary.
2019-04-29 16:59:29 +10:00
Damien Elmes
c3dc02cd7f don't require callback for regular deck refresh
Ensures that decks refresh properly even if the webview has previously
failed to load due to a bug (such as the render routine being called
while the collection is closed)
2019-04-29 16:46:13 +10:00
Damien Elmes
6594f62f5d fix stuck webview issue
A race condition could cause domDone to get stuck on false, causing
any further bridge messages and setHtml() calls to be ignored. Fix
the issue by clearing pending actions and resetting domDone when
setting HTML.
2019-04-29 16:41:47 +10:00
Damien Elmes
9fb5a3257c daemonize helper threads so that sys.exit() during startup works
with daemonize set to False, the app hangs waiting on the helper threads
2019-04-29 14:36:44 +10:00
Damien Elmes
955f21e594
Merge pull request #304 from ErezVolk/jsonschema
Use jsonschema for add-on manifests
2019-04-29 12:34:47 +10:00
Damien Elmes
b4019473ab fix formatting being lost in inter-field pasting on macOS
ownsClipboard() always returns false on macOS

regression introduced in PR 274
2019-04-29 12:30:52 +10:00
Damien Elmes
b2cfba367e fix bug caused by user creating profile with trailing space
Caught exception:
  File "aqt\main.py", line 237, in onOpenBackup
  File "aqt\profiles.py", line 264, in backupFolder
  File "aqt\profiles.py", line 274, in _ensureExists
  File "os.py", line 220, in makedirs
<class 'FileNotFoundError'>: [WinError 3] The system cannot find the path specified: 'C:\\Users\\xxx\\AppData\\Roaming\\Anki2\\xxx \\backups'
2019-04-25 09:37:58 +10:00
Erez Volk
2f75d1758d Use jsonschema for add-on manifests 2019-04-24 23:42:49 +03:00
Damien Elmes
ed0fae3c0c catch another full disk error 2019-04-23 10:19:05 +10:00
Damien Elmes
eef86bf37e don't try set filter if webview already deleted
https://anki.tenderapp.com/discussions/add-ons/32496-add-on-error
2019-04-21 19:12:04 +10:00
Damien Elmes
9cc99cdced possible fix for " super-class ... Preferences was never called"
Can't reproduce the issue, but it seems the user was able to open the
preferences screen when no collection was loaded. If an error was
caught in loadCollection() the main window was not being hidden, so
perhaps a timing issue was preventing the profiles screen from taking
modal focus.

Removed the check in the prefs init - it is hopefully no longer
necessary, and returning before QDialog.__init__() was called was
causing the problem.

Caught exception:
  File "aqt/webview.py", line 27, in cmd
  File "aqt/webview.py", line 85, in _onCmd
  File "aqt/webview.py", line 360, in _onBridgeCmd
  File "aqt/toolbar.py", line 56, in _linkHandler
  File "aqt/toolbar.py", line 80, in _syncLinkHandler
  File "aqt/main.py", line 669, in onSync
  File "aqt/main.py", line 365, in unloadCollection
  File "aqt/main.py", line 611, in closeAllWindows
  File "aqt/__init__.py", line 110, in closeAll
<class 'RuntimeError'>: super-class __init__() of type Preferences was never called
2019-04-21 19:02:03 +10:00
Damien Elmes
623926e8f9 fix some timers failing to fire 2019-04-21 18:56:30 +10:00
Damien Elmes
8c58e7a76a support conflicts when downloading from AnkiWeb
users can now upload .ankiaddon files as well - package/name remains
defined by the add-on listing as before
2019-04-16 17:44:00 +10:00
Damien Elmes
112fc8e7c1 don't confirm conflict disabling
we don't want to be showing dialog boxes while a progress window
is active
2019-04-16 17:43:02 +10:00
Damien Elmes
b3d48c6de6 need rich text in install error, as err msgs have html 2019-04-16 17:39:08 +10:00
Damien Elmes
580d699161 use dialog instead of tooltip if there's more than one log line 2019-04-16 17:38:38 +10:00
Damien Elmes
3592365762
Merge pull request #300 from glutanimate/dynamic-addon-config-button
Disable add-on config button when no config present
2019-04-16 17:36:46 +10:00
Damien Elmes
f80d250b47 Revert "Workaround for AltGr '@' issue."
This reverts commit 1e433a7cdd and
91178d3d58

Due to regressions this will be moved into an optional add-on, at
least for now.
2019-04-16 13:39:40 +10:00
Damien Elmes
015bb71cca fix race condition in webview load on Windows
- don't require collection for initial blank content
- defer profile load until initial blank content loaded
- use plain text for blank content to prevent initial flash of white
2019-04-16 13:24:38 +10:00
Glutanimate
199d9dcb44 Disable add-on config button when no config present
https://anki.tenderapp.com/discussions/ankidesktop/33602-disable-the-config-button-when-an-add-on-is-highlighted-that-does-not-have-any-config
2019-04-15 14:53:18 +02:00
Damien Elmes
d24d485f06 preview code shouldn't assume self.card is valid 2019-04-15 12:20:12 +10:00
Damien Elmes
380d59f775 fix race condition in webview startup on windows
use _setHtml so that _domDone is set to false
2019-04-10 17:31:55 +10:00
Damien Elmes
91178d3d58 extend altgr fix to editor fields, and add warning about helper
extends https://github.com/dae/anki/pull/298
2019-04-10 16:16:29 +10:00
Damien Elmes
4a167304a6
Merge pull request #298 from dlon/altgr-fix
"@" suspends cards with text input for some keyboard layouts
2019-04-10 15:33:02 +10:00
Damien Elmes
7120607dfe avoid highlighting/tabbing to top bar 2019-04-10 15:16:22 +10:00
Damien Elmes
111727240b standard blue focus highlight on windows 2019-04-10 15:16:06 +10:00
Damien Elmes
df4aad50e1 avoid popups for some non-serious warnings 2019-04-10 12:44:01 +10:00
David Lönnhager
1e433a7cdd Workaround for AltGr '@' issue. 2019-04-09 14:55:00 +02:00
Damien Elmes
478ee66d0e fix issue preventing profile rename/delete
qtwebengineprocess.exe inherits the current working directory, so if
it is started after the profile is loaded, it prevents the profile
media folder from being renamed/deleted

also, load profile on first run at the same point we normally load
the profile
2019-04-09 18:48:50 +10:00
Damien Elmes
dac5ea2a7a ensure card info is closed properly 2019-04-09 16:21:43 +10:00
Glutanimate
4de09400c5 Fix timestamp comparison failing when update API returns null
Addresses a rare instance of update checks failing when locally
installed packages point to a shared ID that has yet to be updated
to 2.1. In those instances Anki's update API returns null, which
causes a ValueError downstream when comparing the timestamps
against each other.
2019-04-08 17:51:15 +02:00
Damien Elmes
cc335a15e4 make sure card counts are updated when undoing reviews 2019-04-08 15:47:49 +10:00
Damien Elmes
e7c3de1d9d friendly message for full disk 2019-04-08 15:32:58 +10:00
Damien Elmes
838545b1d6 fix preview not updating when note edited 2019-04-08 15:18:40 +10:00
Damien Elmes
e4eaebe2fb fix note not displaying when preview toggled off & on 2019-04-08 15:18:27 +10:00
Damien Elmes
8ed069d4a6 fix memory leak in card layout screen 2019-03-26 11:31:40 +09:00
Damien Elmes
44952ff727 revert undo shortcut change in browser
when ctrl+z pressed in focused field and no undo history left, qt
triggers the menu item instead, causing data loss

I tried capturing the shortcut in JS and manually executing the undo,
and that seems to work on macOS, but not on Windows.

fixes
https://anki.tenderapp.com/discussions/ankidesktop/33064-how-to-undo-reverted-to-state-deleting-my-cards
2019-03-11 13:43:25 +10:00
Damien Elmes
8de0e7e54c handle blur/key event before note id set
can't reproduce the issue here, but presumably this change will
work around
https://anki.tenderapp.com/discussions/ankidesktop/33038-bug-after-updatehtml-notes-wont-display
2019-03-10 08:24:44 +10:00
Damien Elmes
22d6feed87 Merge branch 'master' of github.com:dae/anki 2019-03-07 18:34:35 +10:00
Damien Elmes
79660e41bb keep global i18n handlers working
the previous change broke the translations of copy&pasted anki code in
add-ons

should fix
https://anki.tenderapp.com/discussions/ankidesktop/32922-chinese-characters-in-the-main-window-when-setting-language-to-japanese#comment_47043676
2019-03-07 18:34:22 +10:00
Glutanimate
324370497e Set QTWEBENGINE_DICTIONARIES_PATH
This introduces the possibility for add-ons to supply spell checking
support in web views.
2019-03-06 18:59:38 +01:00
Damien Elmes
0543df7dfa allow translators to override Windows font
to work around Qt's awful fallback handling on Windows 10

https://anki.tenderapp.com/discussions/ankidesktop/32922-chinese-characters-in-the-main-window-when-setting-language-to-japanese
2019-03-06 15:28:49 +10:00
Damien Elmes
09651be9e7 check a profile exists every time
if something went wrong between pm.meta() and .ensureProfile() in the
past, it would lead to an inability to start Anki due to the a lack of
any profiles

https://anki.tenderapp.com/discussions/ankidesktop/32972-linux-upgrade-problems-20-219
2019-03-06 15:27:13 +10:00
Damien Elmes
73761b598f tweak coding statement to make xgettext happy 2019-03-05 09:59:21 +10:00
Damien Elmes
59b9c361ac allow decreasing daily limits in custom study 2019-03-05 09:06:17 +10:00
Damien Elmes
b168ce6eed add option to strip html in export 2019-03-05 08:57:53 +10:00
Damien Elmes
d0985a4e7c preview state depends on card id, not note id
fixes
https://anki.tenderapp.com/discussions/ankidesktop/32952-commit-c07f2d07474b52c065539fe9e56cbc6047856ad8-causes-preview-to-not-work-with-multiples-cards-of-same-note-cloze-deletions
2019-03-05 07:50:54 +10:00
Damien Elmes
f9f5d9d3ab deprecated global _/ngettext was returning None
the plurals may still be wrong in the ngettext case, but at least
it should not lead to premature tracebacks
2019-03-05 07:46:27 +10:00
Damien Elmes
7d65594944
Merge pull request #288 from glutanimate/mediasrv-addon-support
Extend mediasrv to also serve media files in addons directory
2019-03-04 18:03:48 +10:00
Damien Elmes
ebdd8dae4b tidy up unused imports 2019-03-04 17:25:19 +10:00
Damien Elmes
6e077ab414 use raw strings for regexs 2019-03-04 17:03:43 +10:00
Damien Elmes
4037a034aa fix inconsistent indentation 2019-03-04 16:54:22 +10:00
Damien Elmes
5185e817fc move from deprecated optparse to argparse 2019-03-04 16:45:29 +10:00
Damien Elmes
f6b2135129 fix some warnings 2019-03-04 16:01:10 +10:00
Damien Elmes
7755eb408c fix incorrect qt constructor call 2019-03-04 15:59:53 +10:00
Damien Elmes
e91901911f WindowsError may not be defined 2019-03-04 12:29:55 +10:00
Damien Elmes
919738a9d7 print warning when add-ons access _ without importing it 2019-03-04 12:08:48 +10:00
Damien Elmes
da2ddcc6e2 explicitly import _ and ngettext 2019-03-04 11:58:34 +10:00
Damien Elmes
3721cc4604 silence some spurious errors and remove some unused code 2019-03-04 11:22:40 +10:00
Glutanimate
58d0955392 Refactor: re.match --> re.fullmatch 2019-03-03 17:04:01 +01:00
Glutanimate
5e90758f39 Allow add-on authors to set a whitelist of webview-accessible files
Extends the AddonManager API with two new methods, setWebExports and
getWebExports. setWebExports expects an add-on module name and a
valid RegEx pattern to match subpaths in the add-on folder against.

Any matching subpaths will be accessible in Anki's web views by
referencing them with /_addons/{addon_id}/{subpath}.

For instance, to allow access to .css and .png files in your add-on's
user_files directory you would call:

> mw.addonManager.setWebExports(__name__, r"user_files/.+(\.png|\.css)")

You could then reference these files in web views as such:

> <img src="/_addons/{addon_id}/user_files/test.png">

Please note that this bypasses the default security policies used
in Anki webviews. You should take care to construct your RegEx
patterns specific enough so that they do not match any sensitive
files of our add-on.
2019-03-02 18:57:51 +01:00
Damien Elmes
a389b8b4a0 move versionWithBuild into anki module 2019-02-28 08:37:42 +10:00
Damien Elmes
d6915ff6e8 avoid traceback when network offline in add-on check 2019-02-27 14:18:16 +10:00
Damien Elmes
2e70c56248 fix regression in showInfo() et al 2019-02-27 14:16:35 +10:00
Damien Elmes
66cbc87580 ensure progress window cleared if error on add-on import 2019-02-27 14:08:20 +10:00
Damien Elmes
444abfff94 avoid nbsp for single spaces when pasting text
https://anki.tenderapp.com/discussions/ankidesktop/32823-all-spaces-are-being-replaced-with-nbsp-when-pasting-219-linux
2019-02-27 13:54:50 +10:00
Glutanimate
1fb6123f5a Extend mediasrv to also serve media files in addons directory
RequestsHandler now rewrites "/_addons" references to addons folder.
2019-02-26 13:08:15 +01:00
Damien Elmes
fed15f5b90 include note id in state
to make sure we refresh when multiple notes have same mod time
2019-02-26 11:21:25 +10:00
Damien Elmes
c07f2d0747 avoid refreshing preview when nothing has changed
fixes visible redraw when:
- opening preview screen while cursor in field (as editTimer
fires even if note has not changed)
- moving between cards (as loadNote and rowChanged hooks are both
fired)
2019-02-26 11:18:32 +10:00
Damien Elmes
4116ab65b0 improve add-on downloading error readability 2019-02-26 09:36:20 +10:00
Damien Elmes
139e04c7c3 be explicit about text format when showing add-on errors
fixes br codes showing in error messages
2019-02-26 09:36:02 +10:00
Damien Elmes
188d822d09
Merge pull request #287 from glutanimate/fix-subpixel-antialiasing
Fix subpixel font anti-aliasing
2019-02-26 08:01:35 +10:00
Glutanimate
ac53a0852e Set webview bg to system default window color instead of Qt.transparent
Qt.transparent prevents subpixel anti-aliasing from working, resulting
in slightly blurry fonts on non-retina displays.
(The window background color is not determined correctly on macOS, so
we hardcode it.)

Credits for discovering this issue go to the unknown author of
https://ankiweb.net/shared/info/94394764
2019-02-25 11:44:27 +01:00
Glutanimate
4fd5a9c176 Add a button to copy debug information to About dialog
Supplies information on platform, app, toolkit, and installed add-ons.
Should come in useful to troubleshoot issues that do not produce an
error message, especially for add-on developers.
2019-02-24 14:55:55 +01:00
Glutanimate
c45ea26cd6 Move annotatedName to AddonManager to allow outside access 2019-02-24 14:51:19 +01:00
Glutanimate
569f42c0f5 Move supportText() to utils in order to allow use outside of errors 2019-02-24 14:50:39 +01:00
Damien Elmes
86b3657969 clear selection when deleting add-on(s)
fixes error when deleting last, and wrong selection
otherwise
2019-02-24 15:24:31 +10:00
Glutanimate
195ca93cfe Preserve selected add-ons 2019-02-23 10:10:05 +01:00
Glutanimate
15a83df126 Colour disabled add-ons gray 2019-02-23 10:04:45 +01:00
Glutanimate
8725583c97 Add tooltip feedback for restoring defaults
Changes might not always be apparent, so a tooltip might help.
2019-02-23 09:39:49 +01:00
Glutanimate
1080ae10f9 Store addonconf geom and splitter. Tweak font sizes and margins. 2019-02-23 09:39:49 +01:00
Aristotelis
ff7b06fbda
Merge branch 'master' into install-local-addons 2019-02-23 09:27:17 +01:00
Glutanimate
512be4fc2c Implement add-on conflict handling via manifests "conflicts" value
Only enabled for locally installed packages for now
2019-02-22 21:14:42 +01:00
Glutanimate
8fceccf4b7 Refactor: Add manifest schema, unify install paths, use context manager
Sets the foundation for more elaborate additions to the manifest.

Manifest files are still only being read for local imports, but with
this commit that could be easily changed in the future.
2019-02-22 17:04:07 +01:00