Пример #1
0
    def theme(self):
        """
        :rtype: dict
        """
        if self._theme is None:
            c1 = self.accentColor()
            b1 = self.backgroundColor()

            textWhite = studioqt.Color(255, 255, 255, 255)
            backgroundWhite = studioqt.Color(255, 255, 255, 20)

            self._theme = {
                "PACKAGE_DIRNAME": studiolibrary.DIRNAME,
                "RESOURCE_DIRNAME": studiolibrary.RESOURCE_DIRNAME,
                "ACCENT_COLOR": c1.toString(),
                "ACCENT_COLOR_R": str(c1.red()),
                "ACCENT_COLOR_G": str(c1.green()),
                "ACCENT_COLOR_B": str(c1.blue()),
                "BACKGROUND_COLOR": b1.toString(),
                "BACKGROUND_COLOR_R": str(b1.red()),
                "BACKGROUND_COLOR_G": str(b1.green()),
                "BACKGROUND_COLOR_B": str(b1.blue()),
                "RECORD_TEXT_COLOR": textWhite.toString(),
                "RECORD_TEXT_SELECTED_COLOR": textWhite.toString(),
                "RECORD_BACKGROUND_COLOR": backgroundWhite.toString(),
                "RECORD_BACKGROUND_SELECTED_COLOR": c1.toString(),
            }

        return self._theme
Пример #2
0
    def options(self):
        """
        Return the variables used to customise the style sheet.

        :rtype: dict
        """
        accentColor = self.accentColor()
        backgroundColor = self.backgroundColor()

        textWhite = studioqt.Color(255, 255, 255, 200)
        backgroundWhite = studioqt.Color(255, 255, 255, 20)

        options = {
            "RESOURCE_DIRNAME": studioqt.RESOURCE_DIRNAME,
            "ACCENT_COLOR": accentColor.toString(),
            "ACCENT_COLOR_R": str(accentColor.red()),
            "ACCENT_COLOR_G": str(accentColor.green()),
            "ACCENT_COLOR_B": str(accentColor.blue()),
            "BACKGROUND_COLOR": backgroundColor.toString(),
            "BACKGROUND_COLOR_R": str(backgroundColor.red()),
            "BACKGROUND_COLOR_G": str(backgroundColor.green()),
            "BACKGROUND_COLOR_B": str(backgroundColor.blue()),

            # Item theme colors will be depricated soon.
            "ITEM_TEXT_COLOR": textWhite.toString(),
            "ITEM_TEXT_SELECTED_COLOR": textWhite.toString(),
            "ITEM_BACKGROUND_COLOR": backgroundWhite.toString(),
            "ITEM_BACKGROUND_SELECTED_COLOR": accentColor.toString(),
        }

        return options
Пример #3
0
    def forgroundColor(self):
        """
        Return the foreground color for the theme.

        :rtype: studioqt.Color 
        """
        if self.isDark():
            return studioqt.Color(250, 250, 250, 225)
        else:
            return studioqt.Color(0, 40, 80, 180)
Пример #4
0
    def itemBackgroundColor(self):
        """
        Return the item background color.

        :rtype: studioqt.Color 
        """
        if self.isDark():
            return studioqt.Color(255, 255, 255, 20)
        else:
            return studioqt.Color(255, 255, 255, 120)
Пример #5
0
    def setIcon(self, column, icon, color=None):
        """
        Set the icon to be displayed in the given column.

        :type column: int or str
        :type icon: QtGui.QIcon
        :type color: QtGui.QColor or None
        :rtype: None
        """
        # Safe guard for when the class is being used without the gui.
        isAppRunning = bool(QtWidgets.QApplication.instance())
        if not isAppRunning:
            return

        if isinstance(icon, basestring):
            if not os.path.exists(icon):
                color = color or studioqt.Color(255, 255, 255, 20)
                icon = studiolibrary.resource().icon("image", color=color)
            else:
                icon = QtGui.QIcon(icon)

        if isinstance(column, basestring):
            self._icon[column] = icon
        else:
            self._pixmap[column] = None
            QtWidgets.QTreeWidgetItem.setIcon(self, column, icon)

        self.updateIcon()
Пример #6
0
    def accentForgroundColor(self):
        """
        Return the foreground color for the accent color.

        :rtype: studioqt.Color 
        """
        return studioqt.Color(255, 255, 255, 255)
Пример #7
0
 def setBackgroundColor(self, color):
     """
     :type color: studioqt.Color
     """
     c = studioqt.Color(color.red(), color.green(), color.blue(),
                        color.alpha())
     self.settings().set("backgroundColor", c.toString())
Пример #8
0
    def itemBackgroundHoverColor(self):
        """
        Return the item background color when the mouse hovers over the item.

        :rtype: studioqt.Color 
        """
        return studioqt.Color(255, 255, 255, 60)
Пример #9
0
    def setColors(self, colors):
        """
        Set the colors for the color bar.

        :type colors: list[str] or list[studioqt.Color]
        """
        self.deleteButtons()

        self.layout().addStretch()

        for color in colors:

            if not isinstance(color, str):
                color = studioqt.Color(color)
                color = color.toString()

            callback = partial(self._colorChanged, color)
            css = "background-color: " + color

            button = self.COLOR_BUTTON_CLASS(self)
            button.setObjectName('colorButton')
            button.setStyleSheet(css)
            button.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                 QtWidgets.QSizePolicy.Preferred)
            button.clicked.connect(callback)
            self.layout().addWidget(button)

        button = QtWidgets.QPushButton("...", self)
        button.setObjectName('browseColorButton')
        button.setSizePolicy(QtWidgets.QSizePolicy.Preferred,
                             QtWidgets.QSizePolicy.Preferred)

        button.clicked.connect(self.browseColor)
        self.layout().addWidget(button)
        self.layout().addStretch()
Пример #10
0
 def _colorChanged(self, color):
     """
     Triggered when the color changes from the color browser.
     
     :type color: QtGui.QColor
     """
     colorString = studioqt.Color(color).toString()
     self.setValue(colorString)
     self.emitValueChanged()
Пример #11
0
    def setColors(self, colors):
        """
        Set the colors for the color bar.

        :type colors: list[str] or list[studioqt.Color]
        """
        self.deleteButtons()

        first = True
        last = False

        for i, color in enumerate(colors):

            if i == len(colors)-1:
                last = True

            if not isinstance(color, str):
                color = studioqt.Color(color)
                color = color.toString()

            callback = partial(self._colorChanged, color)

            button = self.COLOR_BUTTON_CLASS(self)

            button.setObjectName('colorButton')
            button.setColor(color)

            button.setSizePolicy(
                QtWidgets.QSizePolicy.Expanding,
                QtWidgets.QSizePolicy.Preferred
            )

            button.setProperty("first", first)
            button.setProperty("last", last)

            button.clicked.connect(callback)

            self.layout().addWidget(button)

            self._buttons.append(button)

            first = False

        self._menuButton = QtWidgets.QPushButton("...", self)
        self._menuButton.setObjectName('menuButton')
        self._menuButton.setSizePolicy(
            QtWidgets.QSizePolicy.Expanding,
            QtWidgets.QSizePolicy.Preferred
        )

        self._menuButton.clicked.connect(self.browseColor)
        self.layout().addWidget(self._menuButton)
        self.refresh()
Пример #12
0
 def options(self):
     """
     Return the variables used to customise the style sheet.
     
     :rtype: dict
     """
     accentColor = self.accentColor()
     backgroundColor = self.backgroundColor()
     textWhite = studioqt.Color(255, 255, 255, 255)
     backgroundWhite = studioqt.Color(255, 255, 255, 20)
     options = {'RESOURCE_DIRNAME': studioqt.RESOURCE_DIRNAME,
      'ACCENT_COLOR': accentColor.toString(),
      'ACCENT_COLOR_R': str(accentColor.red()),
      'ACCENT_COLOR_G': str(accentColor.green()),
      'ACCENT_COLOR_B': str(accentColor.blue()),
      'BACKGROUND_COLOR': backgroundColor.toString(),
      'BACKGROUND_COLOR_R': str(backgroundColor.red()),
      'BACKGROUND_COLOR_G': str(backgroundColor.green()),
      'BACKGROUND_COLOR_B': str(backgroundColor.blue()),
      'ITEM_TEXT_COLOR': textWhite.toString(),
      'ITEM_TEXT_SELECTED_COLOR': textWhite.toString(),
      'ITEM_BACKGROUND_COLOR': backgroundWhite.toString(),
      'ITEM_BACKGROUND_SELECTED_COLOR': accentColor.toString()}
     return options
Пример #13
0
 def setIcon(self, column, icon, color=None):
     """
     Set the icon to be displayed in the given column.
     
     :type column: int or str
     :type icon: QtGui.QIcon
     :rtype: None
     """
     if isinstance(icon, basestring):
         if not os.path.exists(icon):
             color = color or studioqt.Color(255, 255, 255, 20)
             icon = studioqt.resource().icon('image', color=color)
         else:
             icon = QtGui.QIcon(icon)
     if isinstance(column, basestring):
         self._icon[column] = icon
     else:
         self._pixmap[column] = None
         QtWidgets.QTreeWidgetItem.setIcon(self, column, icon)
Пример #14
0
def example():
    """
    Example to show/test the HColorBar.

    :rtype: None
    """

    def _colorChanged(color):
        print "colorChanged:", color

    theme = studioqt.Theme()

    colors = [
        studioqt.Color(230, 60, 60, 255),
        studioqt.Color(255, 90, 40),
        studioqt.Color(255, 125, 100, 255),
        studioqt.Color(250, 200, 0, 255),
        studioqt.Color(80, 200, 140, 255),
        studioqt.Color(50, 180, 240, 255),
        studioqt.Color(110, 110, 240, 255),
    ]

    browserColors = []
    browserColors_ = [
        # Top row, Bottom row
        (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)
    ]

    for colorR, colorG, colorB in browserColors_:
        for i in range(0, 3):
            color = QtGui.QColor(colorR, colorG, colorB)
            browserColors.append(color)

    colorBar = HColorBar()
    colorBar.setColors(colors)
    colorBar.setBrowserColors(browserColors)
    colorBar.colorChanged.connect(_colorChanged)
    colorBar.show()
Пример #15
0
    def setColors(self, colors, width=24):
        """
        Set the colors for the color bar.

        :type colors: list[studioqt.Color]
        :type width: int
        :rtype: None
        """
        self.deleteButtons()

        for color in colors:

            if not isinstance(color, studioqt.Color):
                color = studioqt.Color(color)

            callback = partial(self._colorChanged, color)
            css = "background-color: " + color.toString()

            button = QtWidgets.QPushButton()
            button.setStyleSheet(css)
            button.setMinimumWidth(width)
            button.setSizePolicy(
                QtWidgets.QSizePolicy.Preferred,
                QtWidgets.QSizePolicy.Preferred
            )
            button.clicked.connect(callback)
            self.layout().addWidget(button)

        button = QtWidgets.QPushButton("...")
        button.setMinimumWidth(width*2)
        button.setMaximumWidth(width*2)
        button.setSizePolicy(
            QtWidgets.QSizePolicy.Fixed,
            QtWidgets.QSizePolicy.Preferred
        )

        button.clicked.connect(self.browseColor)
        self.layout().addWidget(button)
Пример #16
0
 def iconColor(self):
     return studioqt.Color(250, 250, 250)
Пример #17
0
 def accentForgroundColor(self):
     return studioqt.Color(255, 255, 255, 225)
Пример #18
0
 def forgroundColor(self):
     return studioqt.Color(250, 250, 250, 225)
Пример #19
0
 def setBackground4(self):
     """
     """
     c = studioqt.Color(40, 40, 50)
     self.setBackgroundColor(c)
Пример #20
0
 def setTheme2(self):
     """
     """
     c = studioqt.Color(255, 90, 40)
     self.setColor(c)
Пример #21
0
 def setBackground2(self):
     """
     """
     c = studioqt.Color(65, 65, 65)
     self.setBackgroundColor(c)
Пример #22
0
 def setBackground1(self):
     """
     """
     c = studioqt.Color(80, 80, 80)
     self.setBackgroundColor(c)
Пример #23
0
 def setTheme7(self):
     """
     """
     c = studioqt.Color(110, 110, 240, 255)
     self.setColor(c)
Пример #24
0
 def setTheme6(self):
     """
     """
     c = studioqt.Color(50, 180, 240, 255)
     self.setColor(c)
Пример #25
0
 def setTheme5(self):
     """
     """
     c = studioqt.Color(80, 200, 140, 255)
     self.setColor(c)
Пример #26
0
 def setTheme3(self):
     """
     """
     c = studioqt.Color(255, 125, 100, 255)
     self.setColor(c)
 def iconColor(self):
     """
     :rtype: studioqt.Color
     """
     return studioqt.Color(245, 245, 245)
Пример #28
0
 def setBackground3(self):
     """
     """
     c = studioqt.Color(50, 50, 52)
     self.setBackgroundColor(c)
Пример #29
0
 def setTheme4(self):
     """
     """
     c = studioqt.Color(250, 200, 0, 255)
     self.setColor(c)
Пример #30
0
 def setTheme1(self):
     """
     """
     c = studioqt.Color(230, 60, 60, 255)
     self.setColor(c)