From a35313922d347794c5111fc7dd7b874c4c0f836b Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Mon, 28 Aug 2017 23:24:08 -0300 Subject: [PATCH 1/2] Creating the guiExitAnki endpoint to allow closing Anki programmatically. --- AnkiConnect.py | 11 +++++++++++ README.md | 15 +++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/AnkiConnect.py b/AnkiConnect.py index ace378d..7659bde 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -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 diff --git a/README.md b/README.md index b5c0f8e..4a009f7 100644 --- a/README.md +++ b/README.md @@ -1119,6 +1119,21 @@ Categories: ``` true ``` +* **guiExitAnki** + + Schedules a request to close Anki after 1s. This operation is asynchronous, so it will return immediately. + + *Sample request*: + ``` + { + "action": "guiExitAnki" + } + ``` + + *Sample response*: + ``` + null + ``` ## License ## From 0adc2e784452bcc39df2a0c201f82f411459fe59 Mon Sep 17 00:00:00 2001 From: tomasgodoi Date: Mon, 28 Aug 2017 23:27:28 -0300 Subject: [PATCH 2/2] Updating readme. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a009f7..1571167 100644 --- a/README.md +++ b/README.md @@ -1121,7 +1121,7 @@ Categories: ``` * **guiExitAnki** - Schedules a request to close Anki after 1s. This operation is asynchronous, so it will return immediately. + 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*: ```