Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
    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")
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
    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")
Exemplo n.º 7
0
    def __init__(self, getword_daemon, setting_config, api):
        Window.__init__(self)
        self.setting_config = setting_config
        self.setFlags(QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.FramelessWindowHint | \
                QtCore.Qt.WindowStaysOnTopHint)

        self.youdaoTranslate = YoudaoTranslate()
        self.qml_context.setContextProperty("youdaoTranslate",
                                            self.youdaoTranslate)
        self.qml_context.setContextProperty(
            "translateInfo", self.youdaoTranslate.translate_info)
        self.qml_context.setContextProperty("suggestModel", suggestModel)
        self.qml_context.setContextProperty("historyModel", historyModel)
        self.qml_context.setContextProperty("getwordDaemon", getword_daemon)
        self.qml_context.setContextProperty("windowApi", api)
        self._menu = MiniWindowMenu(getword_daemon, api, self)
        self.qml_context.setContextProperty("popupMenu", self._menu)
        self.qml_context.setContextProperty("settingConfig",
                                            self.setting_config)

        self.config_group = "Mini Window"
        default_x = self.setting_config.get(self.config_group, "x")
        default_y = self.setting_config.get(self.config_group, "y")
        if default_x == None or default_y == None:
            # set default position at topright
            desktop = QtWidgets.qApp.desktop()
            geo = desktop.screenGeometry(desktop.primaryScreen())
            default_x = geo.x() + geo.width() - 388
            default_y = geo.y() + 100
        else:
            default_x = int(default_x)
            default_y = int(default_y)
        self.setX(default_x)
        self.setY(default_y)

        self.load_qml("MiniWindow.qml")