Commit Graph

1669 Commits

Author SHA1 Message Date
Damien Elmes
737a8d934e persistent add-on configuration
- add-ons can ship default config in a config.json file
- users can edit the config in the add-ons dialog, easily syntax-check
the json, and restore it to the defaults
- an optional config.md contains instructions to the user in markdown
format
- config will be preserved when add-on is updated, instead of being
overwritten as is the case when users are required to edit the source
files

A simple example: in config.json:

{"myvar": 5}

In your add-on's code:

from aqt import mw
config = mw.addonManager.getConfig(__name__)
print("var is", config['myvar'])

Add-ons that manage options in their own GUI can have that GUI
displayed when the config button is clicked:

mw.addonManager.setConfigAction(__name__, myOptionsFunc)
2017-08-28 20:51:43 +10:00
Damien Elmes
b0a62838b5 profile tweaks
- handle unpickling of anki 2.0 prefs
- copy the prefs on first load, as python2 is not capable of reading the
protocol 3 pickles we write for proper bytes support
- when there's an error unpickling, write a clean copy of the
preferences instead of forgetting all profiles and starting from scratch
2017-08-28 18:35:24 +10:00
Damien Elmes
a96ddfc3fd allow templates and add-ons to hook into reviewer updated/shown
eg

from anki.hooks import addHook

def prepare(q):
    return q + """
<script>
onUpdateHook.push(function () {
    window.scrollTo(0, 2000);
})
</script>"""

addHook('prepareQuestion', prepare)
2017-08-28 14:54:22 +10:00
Damien Elmes
76b4343c5e fix browse link 2017-08-26 22:40:11 +10:00
Damien Elmes
92fe869653 fix error on add-on download
suspect this was the cause of the mystery enclosing scope errors as well
2017-08-26 19:55:39 +10:00
Damien Elmes
02a3e14c13 setupEditorShortcuts is a hook, not a filter
add-ons can modify cuts in place
2017-08-26 18:47:45 +10:00
Damien Elmes
ca37b15aa7 bump version 2017-08-26 15:25:10 +10:00
Damien Elmes
7288a9b063 new add-on handling
- separate dialog for managing add-ons
- only add-ons compatible with Anki 2.1 will be shown on AnkiWeb
- can delete or toggle disabled on multiple add-ons at once
- check for updates button
- button to view add-on's AnkiWeb page

The new handling drops support for single file .py add-ons, and requires
add-ons to store all files in a single folder. This ensures all files
are cleaned up properly when updating or deleting an add-on, and
prevents file conflicts between separate add-ons. See the updated
add-on docs for more:

https://apps.ankiweb.net/docs/addons21.html#add-on-folders
https://apps.ankiweb.net/docs/addons21.html#sharing-add-ons

README.addons has been moved to the above page
2017-08-26 15:14:20 +10:00
Damien Elmes
f824db2143 drop 3.5 from travis 2017-08-25 16:43:01 +10:00
Damien Elmes
595ac321d0 Merge branch 'master' of github.com:dae/anki 2017-08-25 16:39:50 +10:00
Damien Elmes
2c9f286026 update python ver dep 2017-08-25 16:39:21 +10:00
Damien Elmes
4f9afcea94 Merge pull request #202 from glutanimate/patch-1
Update required python version to 3.6+
2017-08-25 16:37:12 +10:00
Aristotelis
b176af79e9 Update required python version to 3.6+ 2017-08-25 08:24:38 +02:00
Damien Elmes
7b1747d650 don't throw an error when closing with tooltip or debug window open 2017-08-25 12:14:59 +10:00
Damien Elmes
3b9ac82a32 Merge pull request #201 from glutanimate/editor-addbutton-convenience-function
Convenience function to assign function a button, bridge cmd & shortcut
2017-08-24 18:28:00 +10:00
Damien Elmes
5b0d740948 Merge branch 'master' into editor-addbutton-convenience-function 2017-08-24 18:26:51 +10:00
Damien Elmes
ec27ca52b2 Merge pull request #200 from glutanimate/editor-button-labels
Reintroduce button labels for the Editor
2017-08-24 18:20:55 +10:00
Damien Elmes
5d05264f86 Merge pull request #199 from glutanimate/pass-editor-instance
Pass on Editor instance when running "setupEditorShortcuts" filter
2017-08-24 18:19:28 +10:00
Damien Elmes
77bbc14c59 remember export folder location 2017-08-24 14:38:05 +10:00
Glutanimate
e0038f8003 No need to assign QShortcut to variable 2017-08-24 00:17:28 +02:00
Glutanimate
2d0e74ee5f Convenience function to assign function a button, bridge cmd & shortcut
This is meant to more closely replicate Anki 2.0.x`s _addButton method
than the current one does. Its primary purpose is to reduce the
boilerplate code needed for add-on authors to implement a new button
alongside its hotkey.
2017-08-23 23:55:24 +02:00
Glutanimate
d7bf865524 Reintroduce button labels for the Editor
Anki 2.0.x provided add-on authors with the ability to define
labels that could be used instead of icons. This commit reintroduces
that ability and makes the use of an icon optional.
2017-08-23 23:48:08 +02:00
Glutanimate
16221cc47a Pass on Editor instance when running "setupEditorShortcuts" filter 2017-08-23 23:37:11 +02:00
Damien Elmes
08e0174f2e remove dupeOnSchemaChange
no longer required now that anki 1.x importing dropped
2017-08-21 13:50:11 +10:00
Damien Elmes
ff2e7b9e81 typo in stats 2017-08-21 11:29:54 +10:00
Damien Elmes
db5d23d9dc catch exceptions when setting HTML
thanks to Alicia for the original solution:
dee4c98e9b
2017-08-17 20:02:28 +10:00
Damien Elmes
13b331fb0a fix translations and shortcuts on editor buttons 2017-08-17 13:51:54 +10:00
Damien Elmes
a7580c3762 revert undo shortcut 2017-08-17 13:46:31 +10:00
Damien Elmes
3ad9261c8c catch corrupt media db, fix it in 'check media' 2017-08-17 13:33:54 +10:00
Damien Elmes
e8cc960da3 bump version 2017-08-16 21:53:21 +10:00
Damien Elmes
53fb3b0e8c only macs seem to require the shift+tab fix 2017-08-16 21:51:57 +10:00
Damien Elmes
375c071a26 catch attempts to write outside the media folder
big thanks to David Bailey for discovering this
2017-08-16 21:08:46 +10:00
Damien Elmes
194c02ed16 make sure we swallow the exception when closing
otherwise the main window sticks around with no collection
2017-08-16 21:06:50 +10:00
Damien Elmes
4467b7c991 restore marking support
maybe multiple mark types would make sense in the future, but for now
let's stick to what will work in the older clients
2017-08-16 20:30:29 +10:00
Damien Elmes
43d2fc2307 readme tweak 2017-08-16 20:02:09 +10:00
Damien Elmes
a66c5f555f revamp profile manager
- use a main window instead of a dialog, so the menu items of the main
window don't appear while the profile window is active on OS X
- the profile manager now has a button to automatic restoring from
backup, which will prevent old backups from being clobbered
- drop support for profile passwords
- do the right thing when user quits from the menu in profile manager
mode
2017-08-16 19:45:39 +10:00
Damien Elmes
059db539a7 avoid setting modality in progress dialog
when modal, the program hangs on OS X when moving back and forth
between the main window and the profile manager, and I haven't been able
to find a better workaround

.update() ignores user input when processing events, so this will
hopefully not break things
2017-08-16 17:43:56 +10:00
Damien Elmes
489d16ed14 refactor profile and collection loading/unloading
- unloadCollection() now waits for all collection windows to
indicate they've closed, and calls a callback when it's done
- autosync runs when the collection is unloaded, and is no longer
responsible for reloading it
- make sure backup thread runs until completion
- ensure we return to profile manager when collection can't be loaded
- don't run the profile manager with exec_(), or opening+closing a
broken profile ends up nesting runloops
- warn if a window wasn't cleaned up as part of collection unloading
2017-08-16 17:39:37 +10:00
Damien Elmes
b3a569ed57 progress dialog tweaks
- don't use mw as parent if it's not visible
- wider
2017-08-16 13:20:29 +10:00
Damien Elmes
8ab5a3a176 use callback when closing windows
remove the old forceClose hack in favour of a callback when closing, so
all windows have a chance to save properly before the collection is
unloaded

also:

- fix a warning shown when opening about screen
- require a call to editor.cleanup() when closing a window, to make sure
 any pending js callbacks don't try to fire on a deleted object
- make sure we gc webview when closing editcurrent
- main.py still needs refactoring to make use of the change
2017-08-16 12:48:15 +10:00
Damien Elmes
ca9d80c014 py3 always has a db progress handler 2017-08-16 11:50:00 +10:00
Damien Elmes
b28ca8c0d1 make saveNow() consistently fire callback after returning to event loop
avoid gotchas with callback firing in the middle of a close event, etc
2017-08-16 11:49:33 +10:00
Damien Elmes
d330d2f77f fix unit tests 2017-08-15 21:31:58 +10:00
Damien Elmes
d0389e138e Merge pull request #197 from techdavid/fix-bottom-drag-default
Fix decks being moved to the default deck when dragged to the bottom
2017-08-15 21:21:52 +10:00
Damien Elmes
c4b439eaf2 new import shortcut that doesn't conflict with italics 2017-08-15 21:18:47 +10:00
Damien Elmes
265bef2b68 likewise for manage note types 2017-08-15 18:49:41 +10:00
Damien Elmes
29dc4f298a add 'clear unused tags' back to menu
users who only use the sidebar may miss it
2017-08-15 18:48:22 +10:00
Damien Elmes
bef6e5bcf5 treat name resolution failure as internet offline 2017-08-15 18:46:07 +10:00
Damien Elmes
5f614a5a45 ctrl+shift for undo shortcut 2017-08-15 18:44:11 +10:00
Damien Elmes
b558712976 filter menu tweaks
- make the chunking and menu code more generic
- decks and note types now chunk menus too
- chunked menu now shows start and end prefix
2017-08-15 18:41:36 +10:00