Merge pull request #45 from txgio/gui-exit-anki

Creating the guiExitAnki endpoint to allow closing Anki programmatically
This commit is contained in:
Alex Yatskov 2017-08-28 19:41:44 -07:00 committed by GitHub
commit 1645d5b210
2 changed files with 26 additions and 0 deletions

View File

@ -850,6 +850,13 @@ class AnkiBridge:
else:
return False
def guiExitAnki(self):
timer = QTimer()
def exitAnki():
timer.stop()
self.window().close()
timer.timeout.connect(exitAnki)
timer.start(1000) # 1s should be enough to allow the response to be sent.
#
# AnkiConnect
@ -1149,6 +1156,10 @@ class AnkiConnect:
def guiDeckReview(self, name):
return self.anki.guiDeckReview(name)
@webApi
def guiExitAnki(self):
return self.anki.guiExitAnki()
#
# Entry

View File

@ -1119,6 +1119,21 @@ Categories:
```
true
```
* **guiExitAnki**
Schedules a request to close Anki after 1s. This operation is asynchronous, so it will return immediately and won't wait until Anki actually exits.
*Sample request*:
```
{
"action": "guiExitAnki"
}
```
*Sample response*:
```
null
```
## License ##