def findSizes(self,font):
        fontLogger.debug("font.key()=%s" % font.key())
        fontDatabase = QFontDatabase()

        self.sizeCombo.blockSignals(True)
        self.sizeCombo.clear()

        self.sizeComboFs.blockSignals(True)
        self.sizeComboFs.clear()

        styleStr = fontDatabase.styleString(font)
        if fontDatabase.isSmoothlyScalable(font.family(),styleStr):
            for size in QFontDatabase.standardSizes():
                self.sizeCombo.addItem(str(size))
                self.sizeComboFs.addItem(str(size))
        else:
            for size in fontDatabase.smoothSizes(font.family(),styleStr):
                self.sizeCombo.addItem(str(size))
                self.sizeComboFs.addItem(str(size))

        self.sizeCombo.blockSignals(False)
        self.sizeComboFs.blockSignals(False)

        currentSize = unicode(QSettings().value("worksheet/fontsize",
                                                QtReduceDefaults.FONTSIZE))
        sizeIndex = self.sizeCombo.findText(currentSize)
        self.sizeCombo.setCurrentIndex(sizeIndex)

        currentSize = unicode(QSettings().value("worksheet/fontsizefs",
                                                QtReduceDefaults.FONTSIZEFS))
        sizeIndex = self.sizeCombo.findText(currentSize)
        self.sizeComboFs.setCurrentIndex(sizeIndex)
예제 #2
0
    def setUpClass(cls):
        super(TestClockClient,cls).setUpClass()

        mainlog.setLevel(logging.WARNING) # logging.WARNING)
        cls.mem_logger = MemLogger()

        app = QApplication.instance()
        if app is None:
            app = QApplication(sys.argv)

        font_database = QFontDatabase()

        cls.app = app
        cls.window = MainWindow("TEST_CLOCK",cls.mem_logger,dao, font_database, call_mode=JsonCallWrapper.DIRECT_MODE) # IN_PROCESS_MODE
        cls.window.show()
예제 #3
0
    def __init__(self, parent=None, style='default', paths=[]):
        from PySide.QtGui import QFontDatabase

        self._ui = parent  # parent UI
        self._style = style  # style to parse
        self._font_db = QFontDatabase()  # font database
        self._fonts = dict()  # dictionary of valid font types (ui, mono)

        self._config_paths = ()  # paths for cfg mods
        self._config_files = dict()  # cfg files

        self._qss_paths = ()  # qss file paths
        self._qss_files = dict()  # qss files
        self._initialized = False

        # debugging data
        self._data = dict()

        if not self._initialized:
            self.run(paths=paths)
예제 #4
0
 def findSizes(self, font):
     fontDatabase = QFontDatabase()
     currentSize = self.sizeComboBox.currentText()
     with Lib.BlockSignals(self.sizeComboBox):
         self.sizeComboBox.clear()
         if fontDatabase.isSmoothlyScalable(font.family(),
                                            fontDatabase.styleString(font)):
             for size in QFontDatabase.standardSizes():
                 self.sizeComboBox.addItem(str(size))
         else:
             for size in fontDatabase.smoothSizes(
                     font.family(), fontDatabase.styleString(font)):
                 self.sizeComboBox.addItem(str(size))
         self.sizeComboBox.setEditable(False)
     sizeIndex = self.sizeComboBox.findText(currentSize)
     if sizeIndex == -1:
         self.sizeComboBox.setCurrentIndex(
             max(0,
                 self.sizeComboBox.count() / 3))
     else:
         self.sizeComboBox.setCurrentIndex(sizeIndex)
예제 #5
0
 def __nextGoodFontSize(self, font, size, step):
     info = QFontInfo(font)
     family = info.family()
     fontDatabase = QFontDatabase()
     styleStr = fontDatabase.styleString(font)
     fontLogger.debug("family=%s, style=%s" % (family, styleStr))
     if fontDatabase.isSmoothlyScalable(family, styleStr):
         sizes = QFontDatabase.standardSizes()
     else:
         sizes = fontDatabase.smoothSizes(family, styleStr)
     fontLogger.debug("looking for %s in %s step %d" % (size, sizes, step))
     nSize = size
     while nSize not in sizes and sizes[0] <= nSize and nSize <= sizes[-1]:
         nSize += step
     if nSize < sizes[0]:
         fontLogger.debug("out of range - returning %s" % sizes[0])
         return sizes[0]
     if sizes[-1] < nSize:
         fontLogger.debug("out of range - returning %s" % sizes[-1])
         return sizes[-1]
     fontLogger.debug("found %s" % nSize)
     return nSize
    def __init__(self,parent=None):
        super(QtReduceFontComboBox,self).__init__()
        fdb = QFontDatabase()
        l = []
        self.fontDict = {}
        for fam in fdb.families(QFontDatabase.Latin):
            for sty in fdb.styles(fam):
                if not fam in l and fdb.isFixedPitch(fam,sty) \
                and not fdb.bold(fam,sty) and not fdb.italic(fam,sty) \
                and self.__osxHack(fam):
                    fontLogger.debug("family=%s, style=%s, isFixedPitch=%s" %
                                     (fam, sty, fdb.isFixedPitch(fam,sty)))
                    sizes = fdb.smoothSizes(fam,sty)
                    if sizes:
                        font = fdb.font(fam,sty,sizes[0])
                        if not font.exactMatch():
                            fontLogger.debug("no exactMatch for  %s %s %s" %
                                             (fam,sty,sizes[0]))

                        l += [fam]
                        self.fontDict.update({str(fam):font})
        l.sort
        self.addItems(l)
        self.currentIndexChanged.connect(self.currentIndexChangedHandler)