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

View File

@ -38,10 +38,10 @@ class RemoteApi:
'getVersion': self.apiGetVersion, '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: if self.server is None and enabled:
self.server = AjaxServer(self.handler) self.server = AjaxServer(self.handler)
self.server.listen() self.server.listen()
@ -49,8 +49,6 @@ class RemoteApi:
self.server.close() self.server.close()
self.server = None self.server = None
def advance(self):
if self.server is not None: if self.server is not None:
self.server.advance() self.server.advance()

View File

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