Ejemplo n.º 1
0
 def do_background(self):
     col = QColorDialog.getColor(Qt.white, self,
             _('Choose background color'), QColorDialog.ShowAlphaChannel)
     if col.isValid():
         fmt = QTextCharFormat()
         fmt.setBackground(QBrush(col))
         with self.editing_cursor() as c:
             c.mergeCharFormat(fmt)
Ejemplo n.º 2
0
 def mousePressEvent(self, event):
     '''
     @param: event MouseEvent
     '''
     if event.modifiers() & Qt.ShiftModifier:
         styleHelper.setBaseColor(
             QColorDialog.getColor(styleHelper.requestedBaseColor(),
                                   self._parent))
Ejemplo n.º 3
0
 def choose_color(self):
     col = QColorDialog.getColor(self.current_color or Qt.black, self, _('Choose color'))
     if col.isValid():
         self.current_color = col
         self.update_tooltip()
         self.ic.fill(col)
         self.setIcon(QIcon(self.ic))
         self.data[self.name] = self.value
         self.changed.emit()
Ejemplo n.º 4
0
 def do_color(self):
     col = QColorDialog.getColor(
         Qt.GlobalColor.black, self, _('Choose foreground color'),
         QColorDialog.ColorDialogOption.ShowAlphaChannel)
     if col.isValid():
         fmt = QTextCharFormat()
         fmt.setForeground(QBrush(col))
         with self.editing_cursor() as c:
             c.mergeCharFormat(fmt)
Ejemplo n.º 5
0
    def _get_color(self):  # pragma: no cover
        """
        The method is made to bypass the program crashes during testing
        in Ubuntu. Tests terminated if QColorDialog used in other_color.

        For use in tests (obj is object of ColorPicker):
          with patch.object(obj, '_get_color', return_value=QColor("blue")):
        """
        return QColorDialog(self).getColor(initial=QColor("black"))
Ejemplo n.º 6
0
    def colorDialog(self,*e):

        # ダイアログを表示する
        getcolor = QColorDialog.getColor()
        
        # ラベルに色名を設定
        self.label.setText(getcolor.name())
        
        # フレームに色を設定
        style_color = "background-color: {0}".format(getcolor.name())
        self.frame.setStyleSheet("QWidget { "+style_color+" }")
 def onColorKingdomClicked (self):
     
     dlg = QColorDialog(self.colorKingdom )
     dlg.setOption(QColorDialog.ShowAlphaChannel,True)
     if dlg.exec_() == QDialog.Accepted:
         self.colorKingdom  = dlg.currentColor()
         self.sender().setStyleSheet("#"+self.sender().objectName()+"{background-color: rgba("+str(self.colorKingdom.red())+","+str(self.colorKingdom.green())+","+str(self.colorKingdom.blue())+","+str(self.colorKingdom.alpha())+");}")
         self.sender().show()                    
     else:
         dlg.close()
Ejemplo n.º 8
0
 def change_cover_grid_color(self):
     col = QColorDialog.getColor(self.cg_bg_widget.bcol,
                           self.gui, _('Choose background color for the Cover grid'))
     if col.isValid():
         col = tuple(col.getRgb())[:3]
         self.set_cg_color(col)
         self.changed_signal.emit()
         if self.cg_bg_widget.btex:
             if question_dialog(
                 self, _('Remove background image?'),
                 _('There is currently a background image set, so the color'
                   ' you have chosen will not be visible. Remove the background image?')):
                 self.set_cg_texture(None)
Ejemplo n.º 9
0
 def change_cover_grid_color(self):
     col = QColorDialog.getColor(self.cg_bg_widget.bcol,
                           self.gui, _('Choose background color for cover grid'))
     if col.isValid():
         col = tuple(col.getRgb())[:3]
         self.set_cg_color(col)
         self.changed_signal.emit()
         if self.cg_bg_widget.btex:
             if question_dialog(
                 self, _('Remove background image?'),
                 _('There is currently a background image set, so the color'
                   ' you have chosen will not be visible. Remove the background image?')):
                 self.set_cg_texture(None)
Ejemplo n.º 10
0
 def change_color(self, which, reset=False):
     if reset:
         setattr(self, "current_%s_color" % which, None)
     else:
         initial = getattr(self, "current_%s_color" % which)
         if initial:
             initial = QColor(initial)
         else:
             initial = Qt.black if which == "text" else Qt.white
         title = _("Choose text color") if which == "text" else _("Choose background color")
         col = QColorDialog.getColor(initial, self, title, QColorDialog.ShowAlphaChannel)
         if col.isValid():
             name = unicode(col.name())
             setattr(self, "current_%s_color" % which, name)
     self.update_sample_colors()
Ejemplo n.º 11
0
 def change_color(self, which, reset=False):
     if reset:
         setattr(self, 'current_%s_color'%which, None)
     else:
         initial = getattr(self, 'current_%s_color'%which)
         if initial:
             initial = QColor(initial)
         else:
             initial = Qt.black if which == 'text' else Qt.white
         title = (_('Choose text color') if which == 'text' else
                 _('Choose background color'))
         col = QColorDialog.getColor(initial, self,
                 title, QColorDialog.ShowAlphaChannel)
         if col.isValid():
             name = unicode(col.name())
             setattr(self, 'current_%s_color'%which, name)
     self.update_sample_colors()
Ejemplo n.º 12
0
 def format_text(self, formatting):
     if self.syntax != 'html':
         return
     if formatting.startswith('justify_'):
         return self.smarts.set_text_alignment(
             self,
             formatting.partition('_')[-1])
     color = 'currentColor'
     if formatting in {'color', 'background-color'}:
         color = QColorDialog.getColor(
             QColor(Qt.GlobalColor.black if formatting ==
                    'color' else Qt.GlobalColor.white), self,
             _('Choose color'),
             QColorDialog.ColorDialogOption.ShowAlphaChannel)
         if not color.isValid():
             return
         r, g, b, a = color.getRgb()
         if a == 255:
             color = 'rgb(%d, %d, %d)' % (r, g, b)
         else:
             color = 'rgba(%d, %d, %d, %.2g)' % (r, g, b, a / 255)
     prefix, suffix = {
         'bold': ('<b>', '</b>'),
         'italic': ('<i>', '</i>'),
         'underline': ('<u>', '</u>'),
         'strikethrough': ('<strike>', '</strike>'),
         'superscript': ('<sup>', '</sup>'),
         'subscript': ('<sub>', '</sub>'),
         'color': ('<span style="color: %s">' % color, '</span>'),
         'background-color':
         ('<span style="background-color: %s">' % color, '</span>'),
     }[formatting]
     left, right = self.get_range_inside_tag()
     c = self.textCursor()
     c.setPosition(left)
     c.setPosition(right, QTextCursor.MoveMode.KeepAnchor)
     prev_text = unicode_type(c.selectedText()).rstrip('\0')
     c.insertText(prefix + prev_text + suffix)
     if prev_text:
         right = c.position()
         c.setPosition(left)
         c.setPosition(right, QTextCursor.MoveMode.KeepAnchor)
     else:
         c.setPosition(c.position() - len(suffix))
     self.setTextCursor(c)
Ejemplo n.º 13
0
 def format_text(self, formatting):
     if self.syntax != 'html':
         return
     if formatting.startswith('justify_'):
         return self.smarts.set_text_alignment(
             self,
             formatting.partition('_')[-1])
     color = 'currentColor'
     if formatting in {'color', 'background-color'}:
         color = QColorDialog.getColor(
             QColor(Qt.black if formatting == 'color' else Qt.white), self,
             _('Choose color'), QColorDialog.ShowAlphaChannel)
         if not color.isValid():
             return
         r, g, b, a = color.getRgb()
         if a == 255:
             color = 'rgb(%d, %d, %d)' % (r, g, b)
         else:
             color = 'rgba(%d, %d, %d, %.2g)' % (r, g, b, a / 255)
     prefix, suffix = {
         'bold': ('<b>', '</b>'),
         'italic': ('<i>', '</i>'),
         'underline': ('<u>', '</u>'),
         'strikethrough': ('<strike>', '</strike>'),
         'superscript': ('<sup>', '</sup>'),
         'subscript': ('<sub>', '</sub>'),
         'color': ('<span style="color: %s">' % color, '</span>'),
         'background-color': ('<span style="background-color: %s">' % color,
                              '</span>'),
     }[formatting]
     left, right = self.get_range_inside_tag()
     c = self.textCursor()
     c.setPosition(left)
     c.setPosition(right, c.KeepAnchor)
     prev_text = unicode(c.selectedText()).rstrip('\0')
     c.insertText(prefix + prev_text + suffix)
     if prev_text:
         right = c.position()
         c.setPosition(left)
         c.setPosition(right, c.KeepAnchor)
     else:
         c.setPosition(c.position() - len(suffix))
     self.setTextCursor(c)
Ejemplo n.º 14
0
 def format_text(self, formatting):
     if self.syntax != "html":
         return
     if formatting.startswith("justify_"):
         return self.smarts.set_text_alignment(self, formatting.partition("_")[-1])
     color = "currentColor"
     if formatting in {"color", "background-color"}:
         color = QColorDialog.getColor(
             QColor(Qt.black if formatting == "color" else Qt.white),
             self,
             _("Choose color"),
             QColorDialog.ShowAlphaChannel,
         )
         if not color.isValid():
             return
         r, g, b, a = color.getRgb()
         if a == 255:
             color = "rgb(%d, %d, %d)" % (r, g, b)
         else:
             color = "rgba(%d, %d, %d, %.2g)" % (r, g, b, a / 255)
     prefix, suffix = {
         "bold": ("<b>", "</b>"),
         "italic": ("<i>", "</i>"),
         "underline": ("<u>", "</u>"),
         "strikethrough": ("<strike>", "</strike>"),
         "superscript": ("<sup>", "</sup>"),
         "subscript": ("<sub>", "</sub>"),
         "color": ('<span style="color: %s">' % color, "</span>"),
         "background-color": ('<span style="background-color: %s">' % color, "</span>"),
     }[formatting]
     left, right = self.get_range_inside_tag()
     c = self.textCursor()
     c.setPosition(left)
     c.setPosition(right, c.KeepAnchor)
     prev_text = unicode(c.selectedText()).rstrip("\0")
     c.insertText(prefix + prev_text + suffix)
     if prev_text:
         right = c.position()
         c.setPosition(left)
         c.setPosition(right, c.KeepAnchor)
     else:
         c.setPosition(c.position() - len(suffix))
     self.setTextCursor(c)
Ejemplo n.º 15
0
 def foreground_color(self):
     col = QColorDialog.getColor(Qt.black, self,
             _('Choose foreground color'), QColorDialog.ShowAlphaChannel)
     if col.isValid():
         self.exec_command('foreColor', unicode(col.name()))
Ejemplo n.º 16
0
 def choose_color(self):
     col = QColorDialog.getColor(QColor(self._color or Qt.white), self,
                                 _('Choose a color'))
     if col.isValid():
         self.color = unicode_type(col.name())
Ejemplo n.º 17
0
 def background_color(self):
     col = QColorDialog.getColor(Qt.white, self,
                                 _('Choose background color'),
                                 QColorDialog.ShowAlphaChannel)
     if col.isValid():
         self.exec_command('hiliteColor', unicode_type(col.name()))
Ejemplo n.º 18
0
 def foreground_color(self):
     col = QColorDialog.getColor(Qt.black, self,
                                 _('Choose foreground color'),
                                 QColorDialog.ShowAlphaChannel)
     if col.isValid():
         self.exec_command('foreColor', unicode_type(col.name()))
Ejemplo n.º 19
0
 def _pick_color(self):
     color = QColorDialog.getColor()
     if color.isValid():
         self._set_color(color)
Ejemplo n.º 20
0
 def choose_color(self):
     c = QColorDialog.getColor(self._color, self, _('Choose color'))
     if c.isValid():
         self._color = c
         self.update_display()
Ejemplo n.º 21
0
 def showColors(self):
     colorDialog = QColorDialog()
     color = colorDialog.getColor()
     if color:
         self.fontColorChanged(color)
Ejemplo n.º 22
0
 def choose_color(self):
     col = QColorDialog.getColor(QColor(self._color or Qt.white), self, _('Choose a color'))
     if col.isValid():
         self.color = unicode(col.name())
Ejemplo n.º 23
0
 def choose_color(self):
     c = QColorDialog.getColor(self._color, self, _('Choose color'))
     if c.isValid():
         self._color = c
         self.update_display()
Ejemplo n.º 24
0
 def fget(self):
     return [col.getRgb() for col in
             (QColorDialog.customColor(i) for i in xrange(QColorDialog.customCount()))]
Ejemplo n.º 25
0
 def background_color(self):
     col = QColorDialog.getColor(Qt.white, self,
             _('Choose background color'), QColorDialog.ShowAlphaChannel)
     if col.isValid():
         self.exec_command('hiliteColor', unicode(col.name()))
Ejemplo n.º 26
0
 def fset(self, colors):
     num = min(len(colors), QColorDialog.customCount())
     for i in xrange(num):
         QColorDialog.setCustomColor(i, QColor(*colors[i]))