class dlgPreferences(frmPreferences):
    """
    Proxy class for the generated frmPreferences.
    """
    def __init__(self, parent):
        frmPreferences.__init__(self, parent=parent, modal=TRUE)

        self.cmbUserProxy = ComboProxy(self.cmbUser,
                                       kuraapp.app.getObjects("lng_user"),
                                       guiConf.usernr, True)
        self.cmbLanguageProxy = ComboProxy(self.cmbLanguage,
                                           kuraapp.app.getObjects("lng_language"),
                                           guiConf.languagenr, True)
        self.cmbProjectProxy = ComboProxy(self.cmbProject,
                                          kuraapp.app.getObjects("lng_project"),
                                          guiConf.projectnr, True)
        
        self.chkUseDefaultForSearch.setChecked(guiConf.useDefaultForSearch)
        self.chkShowValueHint.setChecked(guiConf.ShowValueHint)
        
        self.lblFont.setText(guiConf.textfontfamily)
        self.lblFont.setFont(QFont(guiConf.textfontfamily, guiConf.textfontsize))
        
        self.lblWidgetFont.setText(guiConf.widgetfontfamily)
        self.lblWidgetFont.setFont(QFont(guiConf.widgetfontfamily,
                                         guiConf.widgetfontsize))

        self.rdgDocbookExport.setButton(guiConf.interlinearstyle)
        
        self.connect(self.bnFont, SIGNAL("clicked()"), self.slotGetFont)
        self.connect(self.bnWidgetFont, SIGNAL("clicked()"), self.slotGetWidgetFont)
    
    def savePreferences(self):    
        try:
            guiConf.usernr = self.cmbUserProxy.currentKey()
        except: pass
        try:
            guiConf.languagenr = self.cmbLanguageProxy.currentKey()
        except: pass
        try:
            guiConf.projectnr=self.cmbProjectProxy.currentKey()
        except: pass
        guiConf.useDefaultForSearch = self.chkUseDefaultForSearch.isChecked()
        guiConf.ShowValueHint = self.chkShowValueHint.isChecked()
        guiConf.interlinearstyle = self.rdgDocbookExport.id(self.rdgDocbookExport.selected())
        kuraapp.app.settings(usernr = guiConf.usernr,
                             languagenr = guiConf.languagenr,
                             projectnr = guiConf.projectnr)
        
     
     
    def slotGetFont(self):
        font, OK = QFontDialog.getFont(guiConf.textfont, self)
        if OK:
            self.lblFont.setText(font.family())
            self.lblFont.setFont(font)
            guiConf.textfontfamily = font.family()
            guiConf.textfontsize = font.pointSize()
            guiConf.textfont = font
     
    def slotGetWidgetFont(self):
        font, OK = QFontDialog.getFont(guiConf.widgetfont, self)
        if OK:
            self.lblWidgetFont.setText(font.family())
            self.lblWidgetFont.setFont(font)
            guiConf.widgetfontfamily = font.family()
            guiConf.widgetfontsize = font.pointSize()
            guiConf.widgetfont = font
            QApplication.setFont(font, TRUE)
Exemple #2
0
class dlgLexChooser(frmLexChooser):

  def __init__(self, parent, parentRecord):
  
    frmLexChooser.__init__(self, parent=parent
                               , name="dlgLexChooser"
                               , modal=TRUE)
    
    self.txtForm.setFont(guiConf.widgetfont)
    self.txtPhoneticForm.setFont(guiConf.widgetfont)
    self.txtGlosse.setFont(guiConf.widgetfont)
    self.cmbLanguage.setFont(guiConf.widgetfont)
    self.lsvSource.setFont(guiConf.widgetfont)
    
    self.parentRecord=parentRecord
    
    self.cmbLanguageProxy=ComboProxy(self.cmbLanguage,
                                     kuraapp.app.getObjects("lng_language"),
                                     currentKey=parentRecord.languagenr)
    self.lsvSourceProxy=ListViewProxy(listView=self.lsvSource,
                                      tableName="lng_lex",
                                      headers=["form", "glosse", "language"])
    self.connect(self.buttonCancel, SIGNAL("clicked()"), self.reject)
    self.connect(self.lsvSourceProxy,
                 PYSIGNAL("sigItemSelected"),
                 self.slotItemChosen)
    self.connect(self.bnFilter, SIGNAL("clicked()"), self.refreshSource)
    self.connect(self.buttonOk, SIGNAL("clicked()"), self.accept)
    self.connect(self.buttonCancel, SIGNAL("clicked()"), self.reject)
    self.connect(self.buttonHelp, SIGNAL("clicked()"), self.slotHelp)
    
  def slotHelp(self):
    QMessageBox.about(self, "Picking a lexeme to go with a morpheme",
"""
A lot of morphemes have a direct representation in the lexicon. You won't
find a plural suffix in the lexicon, but the name of an object will have
an entry. This dialog is used to pick the lexical entry that's the same
as the morpheme you're editing. (Of course, one day, Kura will be able to
do the groundwork for you, leaving you to dither over the more specific items.)

You might also want to pick a lexical item from another language, for instance,
in the case of loanwords.
"""    )
    
  
  def refreshSource(self):
    rows = kuraapp.app.getObjects("lng_lex",
                                  form = nullifyEmptyQString(self.txtForm.text()),
                                  phonetic_form = nullifyEmptyQString(self.txtPhoneticForm.text()),
                                  glosse = nullifyEmptyQString(self.txtGlosse.text()),
                                  languagenr = self.cmbLanguageProxy.currentKey())
    #
    # Get record from child languages
    #
    if self.chkChildrenIncluded.isChecked()==TRUE:
      languageRec=kuraapp.app.createObject("lng_language",
                                           languagenr=self.cmbLanguageProxy.currentKey())
      childLanguages=languageRec.getChildLanguages()
      for language in childLanguages:
        rows = rows + kuraapp.app.getObjects("lng_lex",
                                             form = nullifyEmptyQString(self.txtForm.text()),
                                             phonetic_form =
                                             nullifyEmptyQString(self.txtPhoneticForm.text()),
                                             glosse = nullifyEmptyQString(self.txtGlosse.text()),
                                             languagenr = language.languagenr)
    self.lsvSourceProxy.refreshRows(rows, [])

  def slotItemChosen(self, item, record):
    self.accept()

  def accept(self):
    try:
      self.masterRecord=self.lsvSourceProxy.currentRecord()
      frmLexChooser.accept(self)
    except:
      frmLexChooser.reject(self)