示例#1
0
    def browseBackgroundColor(self):
        """
        :rtype: None
        """
        color = self.backgroundColor()
        d = QtWidgets.QColorDialog(self)
        d.setCurrentColor(color)
        colors = [(0, 0, 0), (20, 20, 30), (0, 30, 60), (0, 60, 60),
                  (0, 60, 30), (60, 0, 10), (60, 0, 40), (40, 15, 5)]
        index = -1
        for colorR, colorG, colorB in colors:
            for i in range(0, 6):
                index += 1
                try:
                    standardColor = QtGui.QColor(colorR, colorG, colorB)
                    d.setStandardColor(index, standardColor)
                except:
                    standardColor = QtGui.QColor(colorR, colorG, colorB).rgba()
                    d.setStandardColor(index, standardColor)

                colorR += 20
                colorB += 20
                colorG += 20

        d.currentColorChanged.connect(self.setBackgroundColor)
        d.open(self, QtCore.SLOT('blankSlot()'))
        if d.exec_():
            self.setBackgroundColor(d.selectedColor())
        else:
            self.setBackgroundColor(color)
    def browseColor(self):
        """
        Show the color dialog.

        :rtype: None
        """
        color = self.currentColor()

        d = QtWidgets.QColorDialog(self)
        d.setCurrentColor(color)

        standardColors = self.browserColors()

        if standardColors:
            index = -1
            for standardColor in standardColors:
                index += 1

                try:
                    # Support for new qt5 signature
                    standardColor = QtGui.QColor(standardColor)
                    d.setStandardColor(index, standardColor)
                except:
                    # Support for new qt4 signature
                    standardColor = QtGui.QColor(standardColor).rgba()
                    d.setStandardColor(index, standardColor)

        d.currentColorChanged.connect(self._colorChanged)

        if d.exec_():
            self._colorChanged(d.selectedColor())
        else:
            self._colorChanged(color)
示例#3
0
 def browseFolderColor(self):
     """
     :rtype: None
     """
     dialog = QtWidgets.QColorDialog(self.parent())
     dialog.currentColorChanged.connect(self.setFolderColor)
     dialog.open(self, QtCore.SLOT('blankSlot()'))
     if dialog.exec_():
         self.setFolderColor(dialog.selectedColor())
示例#4
0
    def browseFolderColor(self):
        """
        :rtype: None
        """
        dialog = QtWidgets.QColorDialog(self.parent())
        dialog.currentColorChanged.connect(self.setFolderColor)

        # PySide2 doesn't support d.open(), so we need to pass a blank slot.
        dialog.open(self, QtCore.SLOT("blankSlot()"))

        if dialog.exec_():
            self.setFolderColor(dialog.selectedColor())
示例#5
0
 def browseBackgroundColor(self, parent = None):
     """
     :type parent: QtWidgets.QWidget
     :rtype: None
     """
     color = self.backgroundColor()
     dialog = QtWidgets.QColorDialog(parent)
     dialog.setCurrentColor(color)
     dialog.connect(dialog, QtCore.SIGNAL('setBackgroundColor(const QColor&)'), self.setBackgroundColor)
     dialog.open()
     if dialog.exec_():
         self.setBackgroundColor(dialog.selectedColor())
     else:
         self.setBackgroundColor(color)
    def browseColor(self):
        """Show the color dialog for changing the current color."""
        color = self.color()

        d = QtWidgets.QColorDialog(self)
        d.setCurrentColor(color)
        d.currentColorChanged.connect(self._colorChanged)

        # PySide2 doesn't support d.open(), so we need to pass a blank slot.
        d.open(self, QtCore.SLOT("blankSlot()"))

        if d.exec_():
            self._colorChanged(d.selectedColor())
        else:
            self._colorChanged(color)
示例#7
0
    def browseAccentColor(self, parent=None):
        """
        Show the color dialog to browser for a accent color.

        :type parent: QtWidgets.QWidget
        :rtype: None
        """
        color = self.accentColor()
        dialog = QtWidgets.QColorDialog(parent)
        dialog.setCurrentColor(color)
        dialog.connect(dialog, QtCore.SIGNAL("setAccentColor(const QColor&)"),
                       self.setAccentColor)
        dialog.open()
        if dialog.exec_():
            self.setAccentColor(dialog.selectedColor())
        else:
            self.setAccentColor(color)
示例#8
0
    def browseColor(self):
        """
        :rtype: None
        """
        color = self.color()
        d = QtWidgets.QColorDialog(self)
        d.setCurrentColor(color)
        colors = [(230, 60, 60),
                  (250, 80, 130), (255, 90, 40), (240, 100, 170),
                  (255, 125, 100), (240, 200, 150), (250, 200, 0),
                  (225, 200, 40), (80, 200, 140), (80, 225, 120),
                  (50, 180, 240), (100, 200, 245), (130, 110, 240),
                  (180, 160, 255), (180, 110, 240), (210, 110, 255)]
        index = -1
        for colorR, colorG, colorB in colors:
            for i in range(0, 3):
                index += 1
                if colorR < 0:
                    colorR = 0
                if colorG < 0:
                    colorG = 0
                if colorB < 0:
                    colorB = 0
                try:
                    standardColor = QtGui.QColor(colorR, colorG, colorB)
                    d.setStandardColor(index, standardColor)
                except:
                    standardColor = QtGui.QColor(colorR, colorG, colorB).rgba()
                    d.setStandardColor(index, standardColor)

                colorR -= 20
                colorB -= 20
                colorG -= 20

        d.currentColorChanged.connect(self.setColor)
        d.open(self, QtCore.SLOT('blankSlot()'))
        if d.exec_():
            self.setColor(d.selectedColor())
        else:
            self.setColor(color)
    def createColorDialog(
            self,
            parent,
            standardColors=None,
            currentColor=None,
    ):
        """
        Create a new instance of the color dialog.

        :type parent: QtWidgets.QWidget
        :type standardColors: list[int]
        :rtype: QtWidgets.QColorDialog
        """
        dialog = QtWidgets.QColorDialog(parent)

        if standardColors:
            index = -1
            for colorR, colorG, colorB in standardColors:
                index += 1

                color = QtGui.QColor(colorR, colorG, colorB).rgba()

                try:
                    # Support for new qt5 signature
                    color = QtGui.QColor(color)
                    dialog.setStandardColor(index, color)
                except:
                    # Support for new qt4 signature
                    color = QtGui.QColor(color).rgba()
                    dialog.setStandardColor(index, color)

        # PySide2 doesn't support d.open(), so we need to pass a blank slot.
        dialog.open(self, QtCore.SLOT("blankSlot()"))

        if currentColor:
            dialog.setCurrentColor(currentColor)

        return dialog
示例#10
0
    def browseColor(self):
        """
        Show the color dialog.

        :rtype: None
        """
        color = self.currentColor()

        d = QtWidgets.QColorDialog(self)
        d.setCurrentColor(color)

        standardColors = self.browserColors()

        if standardColors:
            index = -1
            for standardColor in standardColors:
                index += 1

                try:
                    # Support for new qt5 signature
                    standardColor = QtGui.QColor(standardColor)
                    d.setStandardColor(index, standardColor)
                except:
                    # Support for new qt4 signature
                    standardColor = QtGui.QColor(standardColor).rgba()
                    d.setStandardColor(index, standardColor)

        d.currentColorChanged.connect(self._colorChanged)

        # PySide2 doesn't support d.open(), so we need to pass a blank slot.
        d.open(self, QtCore.SLOT("blankSlot()"))

        if d.exec_():
            self._colorChanged(d.selectedColor())
        else:
            self._colorChanged(color)