Move all slots to a single location.
This commit is contained in:
97
lib/read.py
97
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'<h1 class="def-word">{word}</h1>' + "\n"
|
||||
try:
|
||||
html += f"<p class=\"phonetic\">{definition['phonetic']}</p>" + "\n"
|
||||
except Exception:
|
||||
pass
|
||||
html += '<ul class="outer">' + "\n"
|
||||
for meaning in definition["meanings"]:
|
||||
html += f"<li>{meaning['partOfSpeech']}"
|
||||
html += '<ul class="inner">'
|
||||
for a_def in meaning["definitions"]:
|
||||
html += f"<li>{a_def['definition']}</li>\n"
|
||||
html += "</ul>\n"
|
||||
html += "</ul>\n<p/>\n"
|
||||
return html
|
||||
|
||||
#
|
||||
# slots
|
||||
#
|
||||
@pyqtSlot()
|
||||
def printAction(self) -> None:
|
||||
html = "<!DOCTYPE html>\n<html>\n<head>\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'<h1 class="def-word">{word}</h1>' + "\n"
|
||||
try:
|
||||
html += f"<p class=\"phonetic\">{definition['phonetic']}</p>" + "\n"
|
||||
except Exception:
|
||||
pass
|
||||
html += '<ul class="outer">' + "\n"
|
||||
for meaning in definition["meanings"]:
|
||||
html += f"<li>{meaning['partOfSpeech']}"
|
||||
html += '<ul class="inner">'
|
||||
for a_def in meaning["definitions"]:
|
||||
html += f"<li>{a_def['definition']}</li>\n"
|
||||
html += "</ul>\n"
|
||||
html += "</ul>\n<p/>\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
|
||||
|
||||
Reference in New Issue
Block a user