class OcrResultWindow(Window): def __init__(self, getword_daemon, setting_config, api): Window.__init__(self) self.getword_daemon = getword_daemon self.setting_config = setting_config self.setFlags(QtCore.Qt.Tool | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) self.youdaoTranslate = YoudaoTranslate() self.translate_info = self.youdaoTranslate.translate_info self.youdaoTranslate.translateFinished.connect( self.handleTranslateFinished) self.qml_context.setContextProperty("translateInfo", self.translate_info) self.qml_context.setContextProperty("getwordDaemon", self.getword_daemon) self.qml_context.setContextProperty("settingConfig", self.setting_config) self.qml_context.setContextProperty("windowApi", api) self.load_qml("OcrResultWindow.qml") @QtCore.pyqtSlot() def handleTranslateFinished(self): if not self.isVisible(): self.show() @QtCore.pyqtSlot(int, int, str) def startTranslate(self, x, y, text): self.setPos(x, y) self.translate(text) @QtCore.pyqtSlot(str) def translate(self, text): text = text.strip() if text: self.youdaoTranslate.get_translate(text) @QtCore.pyqtSlot(int, int) def setPos(self, x, y): self.setX(x) self.setY(y) def isPinned(self): return self.rootObject().isPinned()
class StrokeResultWindow(Window): translateFinished = QtCore.pyqtSignal() resultWindowHide = QtCore.pyqtSignal() def __init__(self, getword_daemon, setting_config, api): Window.__init__(self) self.getword_daemon = getword_daemon self.setting_config = setting_config self.setFlags(QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) #self.setFlags(QtCore.Qt.Popup) self.youdaoTranslate = YoudaoTranslate() self.translate_info = self.youdaoTranslate.translate_info self.youdaoTranslate.translateFinished.connect(self.translateFinished) self.qml_context.setContextProperty("translateInfo", self.translate_info) self.qml_context.setContextProperty("getwordDaemon", self.getword_daemon) self.qml_context.setContextProperty("settingConfig", self.setting_config) self.qml_context.setContextProperty("windowApi", api) self.load_qml("StrokeResultWindow.qml") @QtCore.pyqtSlot(int, int) def updateStrokeIconPosition(self, x, y): self.rootObject().updateStrokeIconPosition(x, y) @QtCore.pyqtSlot(str) def translate(self, text): text = text.strip() if text: self.rootObject().changeQueryWords(text) self.youdaoTranslate.get_translate(text) @QtCore.pyqtSlot() def clear_translate(self): self.youdaoTranslate.clear_translate() def isPinned(self): return self.rootObject().isPinned()
class OcrResultWindow(Window): def __init__(self, getword_daemon, setting_config, api): Window.__init__(self) self.getword_daemon = getword_daemon self.setting_config = setting_config self.setFlags(QtCore.Qt.Tool | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) self.youdaoTranslate = YoudaoTranslate() self.translate_info = self.youdaoTranslate.translate_info self.youdaoTranslate.translateFinished.connect(self.handleTranslateFinished) self.qml_context.setContextProperty("translateInfo", self.translate_info) self.qml_context.setContextProperty("getwordDaemon", self.getword_daemon) self.qml_context.setContextProperty("settingConfig", self.setting_config) self.qml_context.setContextProperty("windowApi", api) self.load_qml("OcrResultWindow.qml") @QtCore.pyqtSlot() def handleTranslateFinished(self): if not self.isVisible(): self.show() @QtCore.pyqtSlot(int, int, str) def startTranslate(self, x, y, text): self.setPos(x, y) self.translate(text) @QtCore.pyqtSlot(str) def translate(self, text): text = text.strip() if text: self.youdaoTranslate.get_translate(text) @QtCore.pyqtSlot(int, int) def setPos(self, x, y): self.setX(x) self.setY(y) def isPinned(self): return self.rootObject().isPinned()
class StrokeResultWindow(Window): translateFinished = QtCore.pyqtSignal() resultWindowHide = QtCore.pyqtSignal() def __init__(self, getword_daemon, setting_config, api): Window.__init__(self) self.getword_daemon = getword_daemon self.setting_config = setting_config self.setFlags(QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) #self.setFlags(QtCore.Qt.Popup) self.youdaoTranslate = YoudaoTranslate() self.translate_info = self.youdaoTranslate.translate_info self.youdaoTranslate.translateFinished.connect(self.translateFinished) self.qml_context.setContextProperty("translateInfo", self.translate_info) self.qml_context.setContextProperty("getwordDaemon", self.getword_daemon) self.qml_context.setContextProperty("settingConfig", self.setting_config) self.qml_context.setContextProperty("windowApi", api) self.load_qml("StrokeResultWindow.qml") @QtCore.pyqtSlot(int, int) def updateStrokeIconPosition(self, x, y): self.rootObject().updateStrokeIconPosition(x, y) @QtCore.pyqtSlot(str) def translate(self, text): text = text.strip() if text: self.rootObject().changeQueryWords(text) self.youdaoTranslate.get_translate(text) @QtCore.pyqtSlot() def clear_translate(self): self.youdaoTranslate.clear_translate() def isPinned(self): return self.rootObject().isPinned()