1
This commit is contained in:
Alex Yatskov 2016-05-01 20:43:09 -07:00
parent 47905e7808
commit 09b007d5f0
4 changed files with 25 additions and 31 deletions

View File

@ -38,7 +38,7 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.vocabDefs = []
def __init__(self, parent, preferences, language, filename=None, anki=None, remoteApi=None, closed=None):
def __init__(self, parent, preferences, language, filename=None, anki=None, closed=None):
QtGui.QMainWindow.__init__(self, parent)
self.setupUi(self)
@ -48,7 +48,6 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
self.facts = []
self.anki = anki
self.remoteApi = remoteApi
self.closed = closed
self.language = language
self.preferences = preferences
@ -104,9 +103,6 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
if self.preferences['windowSize'] is not None:
self.resize(QtCore.QSize(*self.preferences['windowSize']))
if self.remoteApi is not None:
self.remoteApi.enable(self.preferences['enableRemoteApi'])
self.comboTags.addItems(self.preferences['tags'])
self.applyPreferencesContent()
@ -493,11 +489,12 @@ class MainWindowReader(QtGui.QMainWindow, gen.reader_ui.Ui_MainWindowReader):
samplePosStart = self.state.scanPosition
samplePosEnd = self.state.scanPosition + self.preferences['scanLength']
cursor = self.textContent.textCursor()
content = unicode(self.textContent.toPlainText())
contentSample = content[samplePosStart:samplePosEnd]
contentSampleFlat = contentSample.replace(u'\n', unicode())
cursor = self.textContent.textCursor()
if len(contentSampleFlat) == 0 or not japanese.util.isJapanese(contentSampleFlat[0]):
cursor.clearSelection()
self.textContent.setTextCursor(cursor)

View File

@ -38,10 +38,10 @@ class RemoteApi:
'getVersion': self.apiGetVersion,
}
self.enable(self.preferences['enableRemoteApi'])
def advance(self):
enabled = self.preferences['enableRemoteApi']
def enable(self, enabled=True):
if self.server is None and enabled:
self.server = AjaxServer(self.handler)
self.server.listen()
@ -49,8 +49,6 @@ class RemoteApi:
self.server.close()
self.server = None
def advance(self):
if self.server is not None:
self.server.advance()

View File

@ -65,7 +65,6 @@ class YomichanPlugin(Yomichan):
self.language,
None,
self.anki,
self.remoteApi,
self.onWindowClose
)
self.window.show()