tweaks to lookup

This commit is contained in:
Damien Elmes 2008-12-04 04:11:00 +09:00
parent 5830b45b93
commit 30ef6ac450

View file

@ -5,6 +5,7 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
import urllib, re import urllib, re
import anki import anki
from ankiqt import ui
# Tools - looking up words in the dictionary # Tools - looking up words in the dictionary
########################################################################## ##########################################################################
@ -19,11 +20,12 @@ class Lookup(object):
text = unicode(self.main.mainWin.mainText.selectedText()) text = unicode(self.main.mainWin.mainText.selectedText())
text = text.strip() text = text.strip()
if "\n" in text: if "\n" in text:
self.main.setStatus(_("Can't look up a selection with a newline.")) ui.utils.showInfo(_("Can't look up a selection with a newline."))
return return
text = text.strip() text = text.strip()
if not text: if not text:
self.main.setStatus(_("Empty selection.")) u
ui.utils.showInfo(_("Empty selection."))
return return
function(text) function(text)
@ -42,7 +44,7 @@ class Lookup(object):
else: else:
baseUrl += "E" baseUrl += "E"
url = baseUrl + urllib.quote(text.encode("utf-8")) url = baseUrl + urllib.quote(text.encode("utf-8"))
self.main.setStatus(_("Looking %s up on edict...") % text) ui.utils.showInfo(_("Looking %s up on edict...") % text)
qurl = QUrl() qurl = QUrl()
qurl.setEncodedUrl(url) qurl.setEncodedUrl(url)
QDesktopServices.openUrl(qurl) QDesktopServices.openUrl(qurl)
@ -54,7 +56,7 @@ class Lookup(object):
"http://eow.alc.co.jp/" + "http://eow.alc.co.jp/" +
newText + newText +
"/UTF-8/?ref=sa") "/UTF-8/?ref=sa")
self.main.setStatus(_("Looking %s up on ALC...") % text) ui.utils.showInfo(_("Looking %s up on ALC...") % text)
qurl = QUrl() qurl = QUrl()
qurl.setEncodedUrl(url) qurl.setEncodedUrl(url)
QDesktopServices.openUrl(qurl) QDesktopServices.openUrl(qurl)