コード例 #1
0
 def on_rtfFontButton_clicked(self):
     """
     Private method used to select the font for the RTF export.
     """
     font, ok = KQFontDialog.getFont(self.rtfFont)
     if ok:
         self.rtfFontSample.setFont(font)
         self.rtfFont = font
コード例 #2
0
 def __changeFont(self, doAll, familyOnly, sizeOnly):
     """
     Private slot to change the highlighter font.
     
     @param doAll flag indicating to change the font for all styles (boolean)
     @param familyOnly flag indicating to set the font family only (boolean)
     @param sizeOnly flag indicating to set the font size only (boolean
     """
     def setFont(font, style, familyOnly, sizeOnly):
         """
         Local function to set the font.
         
         @param font font to be set (QFont)
         @param style style to set the font for (integer)
         @param familyOnly flag indicating to set the font family only (boolean)
         @param sizeOnly flag indicating to set the font size only (boolean
         """
         if familyOnly or sizeOnly:
             newFont = QFont(self.lexer.font(style))
             if familyOnly:
                 newFont.setFamily(font.family())
             if sizeOnly:
                 newFont.setPointSize(font.pointSize())
             self.lexer.setFont(newFont, style)
         else:
             self.lexer.setFont(font, style)
     
     def setSampleFont(font, familyOnly, sizeOnly):
         """
         Local function to set the font of the sample text.
         
         @param font font to be set (QFont)
         @param familyOnly flag indicating to set the font family only (boolean)
         @param sizeOnly flag indicating to set the font size only (boolean
         """
         if familyOnly or sizeOnly:
             newFont = QFont(self.lexer.font(self.style))
             if familyOnly:
                 newFont.setFamily(font.family())
             if sizeOnly:
                 newFont.setPointSize(font.pointSize())
             self.sampleText.setFont(newFont)
         else:
             self.sampleText.setFont(font)
     
     font, ok = KQFontDialog.getFont(self.lexer.font(self.style))
     if ok:
         setSampleFont(font, familyOnly, sizeOnly)
         if doAll:
             for style in list(self.lexer.ind2style.values()):
                 setFont(font, style, familyOnly, sizeOnly)
         elif len(self.styleElementList.selectedItems()) > 1:
             for selItem in self.styleElementList.selectedItems():
                 style = self.lexer.ind2style[self.styleElementList.row(selItem)]
                 setFont(font, style, familyOnly, sizeOnly)
         else:
             setFont(font, self.style, familyOnly, sizeOnly)
コード例 #3
0
 def selectFont(self, fontSample, fontVar, showFontInfo = False):
     """
     Public method used by the font selection buttons.
     
     @param fontSample reference to the font sample widget (QLineEdit)
     @param fontVar reference to the variable containing the font (QFont)
     @param showFontInfo flag indicating to show some font info
         as the sample (boolean)
     @return selected font (QFont)
     """
     font, ok = KQFontDialog.getFont(fontVar)
     if ok:
         fontSample.setFont(font)
         if showFontInfo:
             fontSample.setText(
                 QString("%1 %2").arg(font.family()).arg(font.pointSize()))
     else:
         font = fontVar
     return font