Ejemplo n.º 1
0
 def _show_errors(self, errors):
     if errors:
         color = interface_colors.get_color("log_error")
         text = '<br />'.join(
             map(
                 lambda s: '<font color="%s">%s</font>' %
                 (color, text_as_html(s)), errors))
         self.ui.error.setText(text + '<hr />')
Ejemplo n.º 2
0
 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'))
Ejemplo n.º 3
0
 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'))
Ejemplo n.º 4
0
    def __init__(self, parent):
        super().__init__(parent)
        self.setWindowFlags(QtCore.Qt.Window)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.parent = parent
        self.parent.scripting_documentation_shown = True
        self.setWindowFlags(QtCore.Qt.Window)
        self.ui = Ui_ScriptingDocumentationDialog()
        self.ui.setupUi(self)
        args = {
            "picard-doc-scripting-url": PICARD_URLS['doc_scripting'],
        }
        text = _('<a href="%(picard-doc-scripting-url)s">Open Scripting'
                 ' Documentation in your browser</a>') % args
        self.ui.scripting_doc_link.setText(text)

        def process_html(html, function):
            if not html:
                html = ''
            template = '<dt>%s%s</dt><dd>%s</dd>'
            if function.module is not None and function.module != 'picard.script':
                module = ' [' + function.module + ']'
            else:
                module = ''
            try:
                firstline, remaining = html.split("\n", 1)
                return template % (firstline, module, remaining)
            except ValueError:
                return template % ("$%s()" % function.name, module, html)

        funcdoc = script_function_documentation_all(
            fmt='html',
            postprocessor=process_html,
        )

        color_fg = interface_colors.get_color('script_function_fg')
        html = DOCUMENTATION_HTML_TEMPLATE % {
            'html': "<dl>%s</dl>" % funcdoc,
            'script_function_fg': color_fg,
        }
        self.ui.textBrowser.setHtml(html)
        self.ui.buttonBox.rejected.connect(self.close)