Sounds starting to work
This commit is contained in:
@@ -236,8 +236,7 @@ class PersonDialog(QDialog, Ui_Dialog):
|
|||||||
start = datetime.fromisoformat(self.sessionCombo.currentText())
|
start = datetime.fromisoformat(self.sessionCombo.currentText())
|
||||||
msg["Subject"] = f"TT English, Session: {start.date().isoformat()}"
|
msg["Subject"] = f"TT English, Session: {start.date().isoformat()}"
|
||||||
msg["From"] = "Christopher T. Johnson <cjohnson@troglodite.com>"
|
msg["From"] = "Christopher T. Johnson <cjohnson@troglodite.com>"
|
||||||
# msg["To"] = self.emailEdit.text().strip()
|
msg["To"] = self.emailEdit.text().strip()
|
||||||
msg["To"] = "cjohnson@troglodite.com"
|
|
||||||
msg.set_content("There is a html message you should read")
|
msg.set_content("There is a html message you should read")
|
||||||
msg.add_alternative(self.inliner.inline(html), subtype="html")
|
msg.add_alternative(self.inliner.inline(html), subtype="html")
|
||||||
server = smtplib.SMTP(secrets.SMTP_HOST, secrets.SMTP_PORT)
|
server = smtplib.SMTP(secrets.SMTP_HOST, secrets.SMTP_PORT)
|
||||||
@@ -363,12 +362,11 @@ class PersonDialog(QDialog, Ui_Dialog):
|
|||||||
def makeDefinitions(self) -> str:
|
def makeDefinitions(self) -> str:
|
||||||
query = QSqlQuery()
|
query = QSqlQuery()
|
||||||
query.prepare(
|
query.prepare(
|
||||||
"SELECT w.word, w.definition FROM sessions s "
|
"SELECT w.word, w.definition "
|
||||||
"LEFT JOIN session_word sw "
|
"FROM session_word sw "
|
||||||
"ON (s.session_id = s.session_id) "
|
|
||||||
"LEFT JOIN words w "
|
"LEFT JOIN words w "
|
||||||
"ON (sw.word_id = w.word_id) "
|
"ON (sw.word_id = w.word_id) "
|
||||||
"WHERE s.session_id = :session_id "
|
"WHERE sw.session_id = :session_id "
|
||||||
"ORDER BY w.word"
|
"ORDER BY w.word"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
44
lib/read.py
44
lib/read.py
@@ -95,6 +95,7 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
# self.sessionBtn.clicked.connect(self.sessionAction)
|
# self.sessionBtn.clicked.connect(self.sessionAction)
|
||||||
self.sessionBtn.clicked.connect(self.session.timerAction)
|
self.sessionBtn.clicked.connect(self.session.timerAction)
|
||||||
self.paraEdit.verticalScrollBar().valueChanged.connect(self.scrollSlot)
|
self.paraEdit.verticalScrollBar().valueChanged.connect(self.scrollSlot)
|
||||||
|
self.defEdit.selectionChanged.connect(self.recursiveDef)
|
||||||
#
|
#
|
||||||
# Connect signals
|
# Connect signals
|
||||||
#
|
#
|
||||||
@@ -106,9 +107,39 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
self.soundEffect.mediaStatusChanged.connect(self.changedStatus)
|
self.soundEffect.mediaStatusChanged.connect(self.changedStatus)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#
|
||||||
|
# Events
|
||||||
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# slots
|
# slots
|
||||||
#
|
#
|
||||||
|
@pyqtSlot()
|
||||||
|
def recursiveDef(self):
|
||||||
|
cursor = self.defEdit.textCursor()
|
||||||
|
selection = cursor.selectedText().strip()
|
||||||
|
if len(selection) <= 0:
|
||||||
|
return
|
||||||
|
query = QSqlQuery()
|
||||||
|
query.prepare("SELECT * FROM words " "WHERE word = :word")
|
||||||
|
query.bindValue(":word", selection)
|
||||||
|
if not query.exec():
|
||||||
|
query_error()
|
||||||
|
if not query.next():
|
||||||
|
response = requests.get(
|
||||||
|
f"https://api.dictionaryapi.dev/api/v2/entries/en/{selection}"
|
||||||
|
)
|
||||||
|
if response.status_code != 200:
|
||||||
|
return
|
||||||
|
definitions = json.loads(response.content.decode("utf-8"))
|
||||||
|
definition = definitions[0]
|
||||||
|
word_id = None
|
||||||
|
else:
|
||||||
|
definition = query.value("definition")
|
||||||
|
word_id = query.value("word_id")
|
||||||
|
self.setDefEdit(selection, word_id, definition)
|
||||||
|
return
|
||||||
|
|
||||||
@pyqtSlot(QMediaPlayer.MediaStatus)
|
@pyqtSlot(QMediaPlayer.MediaStatus)
|
||||||
def changedStatus(self, status):
|
def changedStatus(self, status):
|
||||||
if status == QMediaPlayer.MediaStatus.LoadedMedia:
|
if status == QMediaPlayer.MediaStatus.LoadedMedia:
|
||||||
@@ -117,9 +148,7 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
if not audioOutput:
|
if not audioOutput:
|
||||||
self.soundEffect.setAudioOutput(self.audioOutput)
|
self.soundEffect.setAudioOutput(self.audioOutput)
|
||||||
audioOutput = self.audioOutput
|
audioOutput = self.audioOutput
|
||||||
print(f"{status} No audioOutput???")
|
|
||||||
audioDevice = audioOutput.device()
|
audioDevice = audioOutput.device()
|
||||||
print(audioDevice.description(), audioDevice.id().data())
|
|
||||||
print(status)
|
print(status)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -127,10 +156,8 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
def changedState(self, status):
|
def changedState(self, status):
|
||||||
audioOutput = self.soundEffect.audioOutput()
|
audioOutput = self.soundEffect.audioOutput()
|
||||||
if not audioOutput:
|
if not audioOutput:
|
||||||
print(f"{status} No AudioOutput")
|
|
||||||
return
|
return
|
||||||
audioDevice = audioOutput.device()
|
audioDevice = audioOutput.device()
|
||||||
print(audioDevice.description(), audioDevice.id().data())
|
|
||||||
print(status)
|
print(status)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -155,7 +182,7 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
cursor = self.paraEdit.textCursor()
|
cursor = self.paraEdit.textCursor()
|
||||||
fmt = cursor.charFormat()
|
fmt = cursor.charFormat()
|
||||||
if not fmt.fontUnderline():
|
if not fmt.fontUnderline():
|
||||||
self.addword()
|
self.addWord()
|
||||||
cursor = self.paraEdit.textCursor()
|
cursor = self.paraEdit.textCursor()
|
||||||
textBlock = self.paraEdit.document().findBlock(cursor.position())
|
textBlock = self.paraEdit.document().findBlock(cursor.position())
|
||||||
blockNum = textBlock.blockNumber()
|
blockNum = textBlock.blockNumber()
|
||||||
@@ -586,6 +613,10 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
return
|
return
|
||||||
word = query.value("word")
|
word = query.value("word")
|
||||||
definition = json.loads(query.value("definition"))
|
definition = json.loads(query.value("definition"))
|
||||||
|
self.setDefEdit(word, query.value("word_id"), definition)
|
||||||
|
return
|
||||||
|
|
||||||
|
def setDefEdit(self, word, word_id, definition):
|
||||||
if "phonetics" in definition:
|
if "phonetics" in definition:
|
||||||
self.phonetics = definition["phonetics"]
|
self.phonetics = definition["phonetics"]
|
||||||
else:
|
else:
|
||||||
@@ -595,7 +626,8 @@ class EditDialog(QDialog, Ui_Dialog):
|
|||||||
cursor.insertHtml(self.defToHtml(word, definition))
|
cursor.insertHtml(self.defToHtml(word, definition))
|
||||||
cursor.setPosition(0)
|
cursor.setPosition(0)
|
||||||
self.defEdit.setTextCursor(cursor)
|
self.defEdit.setTextCursor(cursor)
|
||||||
self.displayedWord.emit(query.value("word_id"))
|
if word_id:
|
||||||
|
self.displayedWord.emit(word_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
def showDefinition(self) -> None:
|
def showDefinition(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user