From 3e8478e6ff5682b070360c30b8c71032d63ae0ac Mon Sep 17 00:00:00 2001 From: "Christopher T. Johnson" Date: Tue, 21 Nov 2023 19:28:51 -0500 Subject: [PATCH] Move all slots to a single location. --- lib/read.py | 97 +++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/lib/read.py b/lib/read.py index a0e1594..9b2b4c0 100644 --- a/lib/read.py +++ b/lib/read.py @@ -73,22 +73,9 @@ class EditDialog(QDialog, Ui_Dialog): self.paraEdit.verticalScrollBar().valueChanged.connect(self.scrollSlot) return - def defToHtml(self, word: str, definition) -> str: - html = f'

{word}

' + "\n" - try: - html += f"

{definition['phonetic']}

" + "\n" - except Exception: - pass - html += '\n

\n" - return html - + # + # slots + # @pyqtSlot() def printAction(self) -> None: html = "\n\n\n" @@ -189,6 +176,53 @@ class EditDialog(QDialog, Ui_Dialog): self.update() return + @pyqtSlot() + def nextAction(self) -> None: + if self.stackedWidget.currentIndex() == 1: + print("Next Definition") + self.nextDefinition() + elif self.paragraphs: + self.nextParagraph() + else: + self.nextSection() + return + + @pyqtSlot() + def prevAction(self) -> None: + if self.stackedWidget.currentIndex() == 1: + print("Previous Definition") + self.prevDefinition() + elif self.paragraphs: + self.prevParagraph() + else: + self.prevSection() + return + + @pyqtSlot() + def defineAction(self) -> None: + print("defineAction") + if self.paragraphs: + self.showDefinition() + else: + self.addWord() + return + + def defToHtml(self, word: str, definition) -> str: + html = f'

{word}

' + "\n" + try: + html += f"

{definition['phonetic']}

" + "\n" + except Exception: + pass + html += '\n

\n" + return html + def load_book(self, person_id: int) -> None: query = QSqlQuery() query.prepare( @@ -329,28 +363,6 @@ class EditDialog(QDialog, Ui_Dialog): painter.fillPath(path, brush) return - @pyqtSlot() - def nextAction(self) -> None: - if self.stackedWidget.currentIndex() == 1: - print("Next Definition") - self.nextDefinition() - elif self.paragraphs: - self.nextParagraph() - else: - self.nextSection() - return - - @pyqtSlot() - def prevAction(self) -> None: - if self.stackedWidget.currentIndex() == 1: - print("Previous Definition") - self.prevDefinition() - elif self.paragraphs: - self.prevParagraph() - else: - self.prevSection() - return - def nextParagraph(self) -> None: self.block += 1 if self.block >= self.paraEdit.document().blockCount(): @@ -367,15 +379,6 @@ class EditDialog(QDialog, Ui_Dialog): self.savePosition() return - @pyqtSlot() - def defineAction(self) -> None: - print("defineAction") - if self.paragraphs: - self.showDefinition() - else: - self.addWord() - return - def addWord(self) -> None: # # Find the word