Esempio n. 1
0
 def setDefaultEngine(self, key):
   """
   @param  key  unicode
   """
   d = self.__d
   if d.defaultEngineKey != key:
     d.defaultEngineKey = key
     settings.global_().setTtsEngine(key)
Esempio n. 2
0
 def setLocation(self, path):
     if path != self.location():
         settings.global_().setFastaitLocation(path)
         if path:
             from sakurakit import skfileio
             dllpaths = skfileio.listdirs(os.path.join(path, "GTS"))
             if dllpaths:
                 skpaths.append_paths(dllpaths)
Esempio n. 3
0
  def __init__(self, parent=None):
    super(SystemStatus, self).__init__(parent)
    d = self.__d = _SystemStatus(self)

    netman.manager().onlineChanged.connect(self.onlineChanged)
    gameman.manager().processChanged.connect(d.onProcessChanged)
    dataman.manager().loginChanged.connect(d.onLoginChanged)
    settings.global_().userLanguageChanged.connect(self.userLanguageChanged)
    settings.global_().userIdChanged.connect(self.userIdChanged)
Esempio n. 4
0
 def location(self):
     """@reimp"""
     ret = settings.global_().dreyeLocation()
     if self.verifyLocation(ret):
         return ret
     from dreye import dreyemt
     ret = dreyemt.location()
     if self.verifyLocation(ret):
         return ret
     return settings.global_().dreyeLocation()
Esempio n. 5
0
    def location(self):
        """@reimp"""
        ret = settings.global_().ezTransLocation()
        if self.verifyLocation(ret):
            return ret

        from eztrans import eztrans
        ret = eztrans.location()
        if self.verifyLocation(ret):
            return ret
        return settings.global_().ezTransLocation()
Esempio n. 6
0
    def location(self):
        """@reimp"""
        ret = settings.global_().transcatLocation()
        if self.verifyLocation(ret):
            return ret

        from transcat import transcat
        ret = transcat.location()
        if self.verifyLocation(ret):
            return ret
        return settings.global_().transcatLocation()
Esempio n. 7
0
    def location(self):
        """@reimp"""
        ret = settings.global_().jbeijingLocation()
        if self.verifyLocation(ret):
            return ret

        from jbeijing import jbeijing
        ret = jbeijing.location()
        if self.verifyLocation(ret):
            return ret
        return settings.global_().jbeijingLocation()
Esempio n. 8
0
    def location(self):
        """@reimp"""
        ret = settings.global_().lecLocation()
        if self.verifyLocation(ret):
            return ret

        from lec import powertrans
        ret = powertrans.location()
        if self.verifyLocation(ret):
            return ret

        return settings.global_().lecLocation()
Esempio n. 9
0
    def location(self):
        """@reimp"""
        ret = settings.global_().atlasLocation()
        if self.verifyLocation(ret):
            return ret

        from atlas import atlas
        ret = atlas.location()
        if self.verifyLocation(ret):
            return ret

        return settings.global_().atlasLocation()
Esempio n. 10
0
 def zunkoEngine(self):
   if not self._zunkoEngine:
     if self._zunkoMutex.tryLock():
       eng = self._zunkoEngine = _ttsman.ZunkoEngine(
           mutex = self._zunkoMutex,
           volume=self.getVolume(_ttsman.ZunkoEngine.key))
       settings.global_().zunkoLocationChanged.connect(eng.setPath)
       #growl.msg(' '.join((
       #  my.tr("Load TTS"),
       #  eng.name,
       #)))
       self._zunkoMutex.unlock()
     else:
       dwarn("ignored due to thread contention")
   return self._zunkoEngine
Esempio n. 11
0
    def showTranslation(self, text, language, provider, align, timestamp):
        """
    @param  text  unicode
    @param  language  str
    @param  provider  str
    @param  align  list or None
    @param  timestamp  long
    """
        if not settings.global_().isGrimoireTranslationVisible():
            return

        d = self.__d

        if d.timestamp > timestamp:
            dprint("translation comes too late, ignored")
            return
        if not align:
            align = None  # enforce None
        else:
            align = SkValueObject(value=align)
            d.retainObject(align)
        #text = text.replace('\n', '<br/>')
        d.append(
            partial(GrimoireBean.instance.showTranslation.emit, text, language,
                    provider, align, timestamp))
Esempio n. 12
0
 def showSubtitle(self, s):
     """
 @param  s  dataman.SubtitleObject
 """
     if settings.global_().isGrimoireSubtitleVisible():
         self.__d.append(partial(GrimoireBean.instance.showSubtitle.emit,
                                 s))
Esempio n. 13
0
def wallpaper_url():
    """
  @return  unicode not None
  """
    import settings
    return settings.global_().springBoardWallpaperUrl() or image_url(
        'wallpaper').toString()
Esempio n. 14
0
def confirmUpdateTerms():
    """
  @return  {reset=bool} or None
  """
    if not netman.manager().isOnline():
        growl.warn(my.tr("Cannot perform update when offline"))
        return
    #_speak(u"今すぐ辞書を更新しますか?")
    t = settings.global_().termsTime() or config.VERSION_TIMESTAMP
    sel = QMessageBox.question(
        _parent(), my.tr("Update user-contributed dictionary"), "\n\n".join((
            "\n".
            join((my.tr(
                "Dictionary terms for machine translation are updated on: {0}."
            ),
                  my.
                  tr("VNR will check for automatically updates. Do you want to update now?"
                     ))),
            my.tr("""
VNR will do incremental update by default.
But if you press Reset, VNR will redownload the entire data, which is slow."""
                  ),
        )).format(i18n.timestamp2datetime(t)), Yes | No | Reset, No)
    if sel == Yes:
        return {'reset': False}
    elif sel == Reset:
        return {'reset': True}
Esempio n. 15
0
 def getVolume(self, key):
   """
   @param  key  str
   @return  int
   """
   try: return int(settings.global_().ttsVolumes().get(key) or 100)
   except (ValueError, TypeError): return 100
Esempio n. 16
0
def manager():
    ret = GrabManager()
    import settings
    ss = settings.global_()
    ret.setLocation(ss.grabLocation())
    ss.grabLocationChanged.connect(ret.setLocation)
    return ret
Esempio n. 17
0
 def getSpeed(self, key):
   """
   @param  key  str
   @return  int
   """
   try: return int(settings.global_().ttsSpeeds().get(key) or 0)
   except (ValueError, TypeError): return 0
Esempio n. 18
0
 def getGender(self, key):
   """
   @param  key  str
   @return  str
   """
   try: return settings.global_().ttsGenders().get(key) or 'f'
   except (ValueError, TypeError): return 'f'
Esempio n. 19
0
    def renderHanzi(self, text, html=False):
        """
    @param  text  unicode
    @param* html  bool
    @return  [unicode] or None
    """
        ss = settings.global_()
        radicalEnabled = ss.isKanjiRadicalEnabled()
        hanjaEnabled = ss.isKanjiHanjaEnabled()
        kanjidicEnabled = ss.kanjiDicLanguages()
        if not any((radicalEnabled, hanjaEnabled, kanjidicEnabled)):
            return

        m = hanzidict.manager()
        ret = []
        for ch in text:
            if iskanji(ch):
                rad = m.lookupRadicalString(ch) if radicalEnabled else None
                hanja = hanjaconv.lookup_hanja_char(
                    ch) if hanjaEnabled else None
                trans = m.translateKanji(ch) if kanjidicEnabled else None
                info = filter(bool, (hanja, trans))
                if info:
                    ch = u"%s{%s}" % (ch, ','.join(info))
                text = u"【%s】" % ch
                if rad:
                    text = "%s[%s]" % (text, rad[1:-1])
                if html:
                    text = _dictman.render_kanji(text)
                ret.append(text)
        return ret
Esempio n. 20
0
 def toLanguageEdit(self):
     ret = QtWidgets.QLabel()
     ret.setToolTip(my.tr("User language"))
     ss = settings.global_()
     ret.setText(i18n.language_name2(ss.userLanguage()))
     ss.userLanguageChanged.connect(
         lambda lang: ret.setText(i18n.language_name2(lang)))
     return ret
Esempio n. 21
0
def kojien():
    """
  @return  EBook
  """
    ret = KojienDic()
    import settings
    ret.setLocation(settings.global_().kojienLocation())
    return ret
Esempio n. 22
0
def daijisen():
    """
  @return  EBook
  """
    ret = DaijisenDic()
    import settings
    ret.setLocation(settings.global_().daijisenLocation())
    return ret
Esempio n. 23
0
 def googleEngine(self):
     if not self._googleEngine:
         ss = settings.global_()
         self._googleEngine = _ttsman.GoogleEngine()
         #online=self._online,
         #language='ja', # force Japanese language at this point
         #ss.googleTtsLanguageChanged.connect(self._googleEngine.setLanguage)
     return self._googleEngine
Esempio n. 24
0
 def showComment(self, c):
     """
 @param  c  dataman.Comment
 """
     if (settings.global_().isGrimoireSubtitleVisible()
             and c.d.type == 'subtitle' and not c.d.disabled
             and not c.d.deleted):
         self.__d.append(partial(GrimoireBean.instance.showComment.emit, c))
Esempio n. 25
0
 def refresh(self):
     import config, i18n, settings
     t = config.VERSION_TIMESTAMP
     line1 = tr_("Version") + " " + i18n.timestamp2datetime(t)
     t = settings.global_().updateTime() or config.VERSION_TIMESTAMP
     line2 = tr_("Update") + " " + i18n.timestamp2datetime(t)
     msg = '\n'.join((line1, line2))
     self.versionLabel.setText(msg)
Esempio n. 26
0
  def __init__(self, abortSignal):
    self.abortSignal = abortSignal # signal

    self.online = False
    self.language = 'en' # str, user language

    self.convertsAlphabet = False
    self.yueEnabled = False # translate zh to yue

    self.allTranslators = [] # all created translators
    self.marked = False
    self.rubyEnabled = False

    self.romajiEnabled = \
    self.infoseekEnabled = \
    self.exciteEnabled = \
    self.niftyEnabled = \
    self.systranEnabled = \
    self.babylonEnabled = \
    self.bingEnabled = \
    self.googleEnabled = \
    self.naverEnabled = \
    self.vtransEnabled = \
    self.baiduEnabled = \
    self.youdaoEnabled = \
    self.lecOnlineEnabled = \
    self.transruEnabled = \
    self.hanVietEnabled = \
    self.jbeijingEnabled = \
    self.fastaitEnabled = \
    self.dreyeEnabled = \
    self.ezTransEnabled = \
    self.transcatEnabled = \
    self.atlasEnabled = \
    self.lecEnabled = \
    False # bool

    self.ehndEnabled = True

    self.romajiType = 'romaji'

    self.alignEnabled = {} # {str key:bool t}
    self.scriptEnabled = {} # {str key:bool t}

    self.retrans = {} # {str key:_trman.Retranslator}

    # {str key:{'yes':bool,'key':str,'lang':str}}
    self.retransSettings = settings.global_().retranslatorSettings() or {}
    # Example:
    #self.retransSettings = {
    #  'jbeijing': {'yes':True, 'key': 'hanviet', 'lang':'zhs'},
    #}

    from PySide.QtNetwork import QNetworkAccessManager
    nam = QNetworkAccessManager() # parent is not assigned
    from qtrequests import qtrequests
    self.session = qtrequests.Session(nam, abortSignal=self.abortSignal, requestTimeout=config.APP_ONLINE_TRANSLATION_TIMEOUT)
Esempio n. 27
0
  def __init__(self, parent=None):
    super(ShioriBean, self).__init__(parent)
    self.__d = _ShioriBean()
    ShioriBean.instance = self

    ss = settings.global_()
    self.__d.enabled = ss.isJapaneseDictionaryEnabled()
    ss.japaneseDictionaryEnabledChanged.connect(self.setEnabled)
    dprint("pass")
Esempio n. 28
0
 def _iterStarDict(self):
     """
 @yield  StarDict, str category
 """
     ss = settings.global_()
     if ss.isStardictHanjaEnabled():
         yield dicts.stardict('hanja'), 'hanja'
     if ss.isStardictJaViEnabled():
         yield dicts.stardict('ja-vi'), 'ovdp'
Esempio n. 29
0
    def _iterEB(self):
        """
    @yield  EB
    """
        ss = settings.global_()
        if ss.isZhongriEnabled():
            eb = ebdict.zhongri()
            if eb.exists():
                yield eb
            else:
                growl.warn("<br/>".join(
                    (my.tr("Cannot load {0}").format(u"Zhongri (日中統合辞典)"),
                     my.tr("Please double check its location in Preferences.")
                     )))

        if ss.isWadokuEnabled():
            eb = ebdict.wadoku()
            if eb.exists():
                yield eb
            else:
                growl.warn("<br/>".join(
                    (my.tr("Cannot load {0}").format(u"Wadoku (和独辞書)"),
                     my.tr("Please double check its location in Preferences.")
                     )))

        for lang in config.JMDICT_LANGS:
            if ss.isJMDictEnabled(lang):
                eb = ebdict.jmdict(lang)
                if eb.exists():
                    yield eb
                else:
                    growl.warn("<br/>".join(
                        (my.tr("Cannot load {0}").format("JMDict (%s)" % lang),
                         my.
                         tr("Please double check its location in Preferences.")
                         )))

        if ss.isDaijirinEnabled():
            eb = ebdict.daijirin()
            if eb.exists():
                yield eb
            else:
                growl.warn("<br/>".join(
                    (my.tr("Cannot load {0}").format(u"DAIJIRIN (大辞林)"),
                     my.tr("Please double check its location in Preferences.")
                     )))

        if ss.isKojienEnabled():
            eb = ebdict.kojien()
            if eb.exists():
                yield eb
            else:
                growl.warn("<br/>".join(
                    (my.tr("Cannot load {0}").format(u"KOJIEN6 (広辞苑)"),
                     my.tr("Please double check its location in Preferences.")
                     )))
Esempio n. 30
0
    def deviceEdit(self):
        ret = QtWidgets.QComboBox()
        ret.setToolTip(my.tr("Audio device to record"))
        ret.setEditable(False)
        ret.addItems([it['name'] for it in audioinfo.inputdevices()])
        #ret.setMaxVisibleItems(ret.count())

        import settings
        ret.setCurrentIndex(settings.global_().audioDeviceIndex())
        return ret