def setup_styles(self, force_calibre_style): self.original_font = QFont(QApplication.font()) fi = gprefs['font'] if fi is not None: font = QFont(*(fi[:4])) s = gprefs.get('font_stretch', None) if s is not None: font.setStretch(s) QApplication.setFont(font) depth_ok = True if iswindows: # There are some people that still run 16 bit winxp installs. The # new style does not render well on 16bit machines. try: depth_ok = get_windows_color_depth() >= 32 except: import traceback traceback.print_exc() if force_calibre_style or (depth_ok and gprefs['ui_style'] != 'system'): self.load_calibre_style() else: st = self.style() if st is not None: st = unicode(st.objectName()).lower() if (islinux or isbsd) and st in ('windows', 'motif', 'cde'): from PyQt4.Qt import QStyleFactory styles = set(map(unicode, QStyleFactory.keys())) if os.environ.get('KDE_FULL_SESSION', False): self.load_calibre_style() elif 'Cleanlooks' in styles: self.setStyle('Cleanlooks')
def build_font_obj(self): font_info = self.current_font if font_info is not None: font = QFont(*(font_info[:4])) font.setStretch(font_info[4]) else: font = qt_app.original_font return font
def reload_settings(self, *args): s = self.settings self.scheme = s.colorscheme() fontname, fontsize = s.font_family, s.font_size self.double_strike = s.double_strike font = QFont(fontname) font.setPointSizeF(fontsize) if s.integer_metrics: font.setStyleStrategy(QFont.ForceIntegerMetrics | font.styleStrategy()) if not s.antialias: font.setStyleStrategy(QFont.NoAntialias|font.styleStrategy()) font.setHintingPreference(s.hinting_level) stretch = int(100 * s.font_xstretch) if stretch != 100: font.setStretch(stretch) spacing = int(100 * s.letter_spacing) if spacing != 100: font.setLetterSpacing(QFont.PercentageSpacing, spacing) weight = int(100 * s.weight) if weight != 100: font.setWeight(weight) self._line_spacing_factor = s.line_spacing self.q_font = font self.q_completion_bgcolor = to_q_color(self.scheme.bg) self.q_completion_bgcolor.setAlphaF(CompletionViewOpacity) self.q_bgcolor = to_q_color(self.scheme.bg) self.q_fgcolor = to_q_color(self.scheme.fg) self.tab_stop = s.tab_stop self.q_tab_color = to_q_color(self.scheme.bg.mean(self.scheme.fg)) self.tab_glyph = s.tab_glyph self.word_wrap = False self.reloaded()
def setup_styles(self, force_calibre_style): self.original_font = QFont(QApplication.font()) fi = gprefs["font"] if fi is not None: font = QFont(*(fi[:4])) s = gprefs.get("font_stretch", None) if s is not None: font.setStretch(s) QApplication.setFont(font) depth_ok = True if iswindows: # There are some people that still run 16 bit winxp installs. The # new style does not render well on 16bit machines. try: depth_ok = get_windows_color_depth() >= 32 except: import traceback traceback.print_exc() if not depth_ok: prints("Color depth is less than 32 bits disabling modern look") if force_calibre_style or (depth_ok and gprefs["ui_style"] != "system"): self.load_calibre_style() else: st = self.style() if st is not None: st = unicode(st.objectName()).lower() if (islinux or isbsd) and st in ("windows", "motif", "cde"): from PyQt4.Qt import QStyleFactory styles = set(map(unicode, QStyleFactory.keys())) if os.environ.get("KDE_FULL_SESSION", False): self.load_calibre_style() elif "Cleanlooks" in styles: self.setStyle("Cleanlooks")