More progress on all entites in MW data load
This commit is contained in:
23
lib/read.py
23
lib/read.py
@@ -1,12 +1,9 @@
|
||||
import json
|
||||
from typing import Any, Dict, List, Optional, cast
|
||||
from typing import Dict, List, Optional, cast
|
||||
|
||||
import requests
|
||||
from PyQt6.QtCore import QPoint, QResource, Qt, QTimer, pyqtSignal, pyqtSlot
|
||||
from PyQt6.QtGui import (
|
||||
QBrush,
|
||||
QColor,
|
||||
QCursor,
|
||||
QKeyEvent,
|
||||
QPainter,
|
||||
QPainterPath,
|
||||
@@ -15,7 +12,7 @@ from PyQt6.QtGui import (
|
||||
QTextCursor,
|
||||
)
|
||||
from PyQt6.QtSql import QSqlQuery
|
||||
from PyQt6.QtWidgets import QDialog, QTextEdit, QWidget
|
||||
from PyQt6.QtWidgets import QDialog, QWidget
|
||||
|
||||
from lib import query_error
|
||||
from lib.preferences import Preferences
|
||||
@@ -89,6 +86,7 @@ class ReadDialog(QDialog, Ui_ReadDialog):
|
||||
self.playSound.connect(self.sound.playSound)
|
||||
self.playAlert.connect(self.sound.alert)
|
||||
self.definition.pronounce.connect(self.sound.playSound)
|
||||
self.definition.newWord.connect(self.newWord)
|
||||
return
|
||||
|
||||
#
|
||||
@@ -98,6 +96,15 @@ class ReadDialog(QDialog, Ui_ReadDialog):
|
||||
#
|
||||
# slots
|
||||
#
|
||||
@pyqtSlot(str)
|
||||
def newWord(self, word: str) -> None:
|
||||
w = Word(word)
|
||||
if not w.isValid():
|
||||
self.playAlert.emit()
|
||||
return
|
||||
self.definition.setWord(w)
|
||||
return
|
||||
|
||||
@pyqtSlot()
|
||||
def timerAction(self) -> None:
|
||||
if self.session.isActive(): # We are stopping
|
||||
@@ -127,6 +134,9 @@ class ReadDialog(QDialog, Ui_ReadDialog):
|
||||
cursor.select(QTextCursor.SelectionType.WordUnderCursor)
|
||||
text = cursor.selectedText().strip()
|
||||
word = Word(text)
|
||||
if not word.isValid():
|
||||
self.playAlert.emit()
|
||||
return
|
||||
word.playPRS()
|
||||
return
|
||||
|
||||
@@ -221,6 +231,9 @@ class ReadDialog(QDialog, Ui_ReadDialog):
|
||||
cursor.select(cursor.SelectionType.WordUnderCursor)
|
||||
text = cursor.selectedText().strip()
|
||||
word = Word(text)
|
||||
if not word.isValid():
|
||||
self.playAlert.emit()
|
||||
return
|
||||
self.definition.setWord(word)
|
||||
self.showDefinition()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user