Skip to content

Commit

Permalink
|Added text selection shortcut for Windows and Mac| Disabled Forvo Au…
Browse files Browse the repository at this point in the history
…to TTS option|
  • Loading branch information
Rascalov committed Mar 21, 2022
1 parent af5136c commit 597bc27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 3 additions & 8 deletions ForvoTts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@
from .bs4Scraper import lookup_word
import os
import glob
from threading import *

# TODO: To anyone even remotely familiar with QT, this probably looks horrendous. Revamp encouraged.

class ForvoTts(QDialog):
finalResult = None # to be a
def __init__(self, mw, targetNote, parent, focusedField):
def __init__(self, mw, targetNote, parent, focusedField, selectedText):
QDialog.__init__(self, parent or mw)
#super(ForvoTts, self).__init__(parent)
selectionText = QApplication.clipboard().text(1)
self.textBox = QLineEdit(self)
self.textBox.setGeometry(QRect(200, 50, 150, 30))
self.textBox.setMinimumWidth(170)
self.textBox.setPlaceholderText("Search...")
self.config = mw.addonManager.getConfig(__name__)
self.focusedField = focusedField
for fieldName in targetNote.keys():
if(selectionText in targetNote[fieldName]):
self.textBox.setText(selectionText)
break

self.textBox.setText(selectedText)
self.targetNote = targetNote
self.setupUi(self)


def setupUi(self, Dialog):
Dialog.setObjectName("TTSDialog")
Expand Down
6 changes: 4 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .ForvoTts import ForvoTts
from aqt import gui_hooks


def openForvoAudioGenerator():
cardCount = mw.col.cardCount()
config = mw.addonManager.getConfig(__name__)
Expand All @@ -12,16 +13,17 @@ def openForvoAudioGenerator():

action = QAction("Add Forvo TTS to deck", mw)
action.triggered.connect(openForvoAudioGenerator)
mw.form.menuTools.addAction(action)
#mw.form.menuTools.addAction(action)

def addForvoTtsOption(editerWindow, qmenu):
qmenu.addAction("Add Forvo Audio", lambda: forvoTts(editerWindow))


def forvoTts(editorWindow):
editor = editorWindow.editor
results = []
note = editor.note
widget = ForvoTts(mw, note, editor.parentWindow, editor.currentField)
widget = ForvoTts(mw, note, editor.parentWindow, editor.currentField, editorWindow.selectedText())
if(widget.exec_()):
result = widget.finalResult
editor.web.setFocus()
Expand Down

0 comments on commit 597bc27

Please sign in to comment.