def _setup_formats(self): interface_colors.load_from_config() self.formats = {} for level, feat in log.levels_features.items(): text_fmt = QtGui.QTextCharFormat() text_fmt.setFontFamily(FONT_FAMILY_MONOSPACE) text_fmt.setForeground(interface_colors.get_qcolor(feat.color_key)) self.formats[level] = text_fmt
def _setup_formats(self): interface_colors.load_from_config() self.formats = {} font = QtGui.QFont() font.setFamily("Monospace") for level, feat in log.levels_features.items(): text_fmt = QtGui.QTextCharFormat() text_fmt.setFont(font) text_fmt.setForeground(interface_colors.get_qcolor(feat.color_key)) self.formats[level] = text_fmt
def test_interface_colors(self): with self.assertRaises(UnknownColorException): interface_colors.get_color('testcolor') self.assertEqual(interface_colors.get_color('entity_error'), _DEFAULT_COLORS['entity_error'].value) interface_colors.load_from_config() self.assertEqual(interface_colors.get_color('entity_error'), '#abcdef') self.assertEqual(interface_colors.get_colors()['entity_error'], '#abcdef') interface_colors.set_color('entity_error', '#000000') interface_colors.save_to_config() self.assertEqual(config.setting['interface_colors']['entity_error'], '#000000') self.assertNotIn('unknowncolor', config.setting['interface_colors']) self.assertEqual( interface_colors.get_color_description('entity_error'), _DEFAULT_COLORS['entity_error'].description) self.assertEqual(interface_colors.get_qcolor('entity_error'), QColor('#000000'))
def test_interface_colors(self): for key in ('interface_colors', 'interface_colors_dark'): interface_colors = InterfaceColors( dark_theme=key == 'interface_colors_dark') with self.assertRaises(UnknownColorException): interface_colors.get_color('testcolor') default_colors = interface_colors.default_colors self.assertEqual(interface_colors.get_color('entity_error'), default_colors['entity_error'].value) interface_colors.load_from_config() self.assertEqual(interface_colors.get_color('entity_error'), '#abcdef') self.assertEqual(interface_colors.get_colors()['entity_error'], '#abcdef') interface_colors.set_color('entity_error', '#000000') self.assertTrue(interface_colors.save_to_config()) self.assertEqual(config.setting[key]['entity_error'], '#000000') self.assertNotIn('unknowncolor', config.setting[key]) self.assertEqual( interface_colors.get_color_description('entity_error'), default_colors['entity_error'].description) self.assertEqual(interface_colors.get_qcolor('entity_error'), QColor('#000000'))
def load(self): interface_colors.load_from_config() self.update_color_selectors()