Esempio n. 1
0
    def updateTheme(self):
        """Update the GUI theme from theme files.
        """
        self.guiTheme = self.mainConf.guiTheme
        self.guiSyntax = self.mainConf.guiSyntax

        self.themeFile = self._availThemes.get(self.guiTheme, None)
        if self.themeFile is None:
            logger.error("Could not find GUI theme '%s'", self.guiTheme)
        else:
            self.cssFile = self.themeFile[:-5] + ".css"
            self.loadTheme()

        self.syntaxFile = self._availSyntax.get(self.guiSyntax, None)
        if self.syntaxFile is None:
            logger.error("Could not find syntax theme '%s'", self.guiSyntax)
        else:
            self.loadSyntax()

        # Update dependant colours
        backCol = qApp.palette().window().color()
        textCol = qApp.palette().windowText().color()

        backLCol = backCol.lightnessF()
        textLCol = textCol.lightnessF()

        if backLCol > textLCol:
            helpLCol = textLCol + 0.65 * (backLCol - textLCol)
        else:
            helpLCol = backLCol + 0.65 * (textLCol - backLCol)

        self.helpText = [int(255 * helpLCol)] * 3

        return True
Esempio n. 2
0
    def updateTheme(self):
        """Update the GUI theme from theme files.
        """
        self.guiTheme = self.mainConf.guiTheme
        self.guiSyntax = self.mainConf.guiSyntax
        self.themeRoot = self.mainConf.themeRoot
        self.themePath = os.path.join(self.mainConf.themeRoot, self.guiPath,
                                      self.guiTheme)
        self.syntaxFile = os.path.join(self.themeRoot, self.syntaxPath,
                                       self.guiSyntax + ".conf")
        self.confFile = os.path.join(self.themePath, self.confName)
        self.cssFile = os.path.join(self.themePath, self.cssName)

        self.loadTheme()
        self.loadSyntax()

        # Update dependant colours
        backCol = qApp.palette().window().color()
        textCol = qApp.palette().windowText().color()

        backLCol = backCol.lightnessF()
        textLCol = textCol.lightnessF()

        if backLCol > textLCol:
            helpLCol = textLCol + 0.65 * (backLCol - textLCol)
        else:
            helpLCol = backLCol + 0.65 * (textLCol - backLCol)

        self.helpText = [int(255 * helpLCol)] * 3

        return True
Esempio n. 3
0
def appPalette():
    p = qApp.palette()
    c = p.color(p.Window)
    # p.setColor(p.Window, QColor(window))
    # p.setColor(p.Base, c.lighter(115))
    # p.setColor(p.Base, QColor("#FFF"))
    return p
Esempio n. 4
0
def appPalette():
    p = qApp.palette()
    c = p.color(p.Window)
    # p.setColor(p.Window, QColor(window))
    # p.setColor(p.Base, c.lighter(115))
    # p.setColor(p.Base, QColor("#FFF"))
    return p
Esempio n. 5
0
def apply_style(style_name):
    if style_name == 'LiSP':
        qApp.setStyleSheet(QLiSPTheme)

        # Change link color
        palette = qApp.palette()
        palette.setColor(QPalette.Link, QColor(65, 155, 230))
        palette.setColor(QPalette.LinkVisited, QColor(43, 103, 153))
        qApp.setPalette(palette)
    else:
        qApp.setStyleSheet('')
        qApp.setStyle(QStyleFactory.create(style_name))
Esempio n. 6
0
def apply_style(name):
    """Load a style given its name."""
    style = LiSPStyles.get(name.title())

    if isinstance(style, Style):
        if style.has_py:
            __load_py_style(os.path.join(style.path, 'style.py'))

        if style.has_qss:
            __load_qss_style(os.path.join(style.path, 'style.qss'))

        # Change link color
        palette = qApp.palette()
        palette.setColor(QPalette.Link, QColor(65, 155, 230))
        palette.setColor(QPalette.LinkVisited, QColor(43, 103, 153))
        qApp.setPalette(palette)
    else:
        qApp.setStyleSheet('')
        qApp.setStyle(QStyleFactory.create(name))
Esempio n. 7
0
 def __init__(self):
     super(LightTheme, self).__init__()
     palette = qApp.palette()
     palette.setColor(QPalette.Window, QColor(239, 240, 241))
     palette.setColor(QPalette.WindowText, QColor(49, 54, 59))
     palette.setColor(QPalette.Base, QColor(252, 252, 252))
     palette.setColor(QPalette.AlternateBase, QColor(239, 240, 241))
     palette.setColor(QPalette.ToolTipBase, QColor(239, 240, 241))
     palette.setColor(QPalette.ToolTipText, QColor(49, 54, 59))
     palette.setColor(QPalette.Text, QColor(49, 54, 59))
     palette.setColor(QPalette.Button, QColor(239, 240, 241))
     palette.setColor(QPalette.ButtonText, QColor(49, 54, 59))
     palette.setColor(QPalette.BrightText, QColor(255, 255, 255))
     palette.setColor(QPalette.Link, QColor(41, 128, 185))
     palette.setColor(QPalette.Highlight, QColor(126, 71, 130))
     palette.setColor(QPalette.HighlightedText, Qt.white)
     palette.setColor(QPalette.Disabled, QPalette.Light, Qt.white)
     palette.setColor(QPalette.Disabled, QPalette.Shadow, QColor(234, 234, 234))
     qApp.setPalette(palette)
Esempio n. 8
0
 def __init__(self):
     super(VideoStyleDark, self).__init__()
     palette = qApp.palette()
     palette.setColor(QPalette.Window, QColor(27, 35, 38))
     palette.setColor(QPalette.WindowText, QColor(234, 234, 234))
     palette.setColor(QPalette.Base, QColor(27, 35, 38))
     palette.setColor(QPalette.AlternateBase, QColor(12, 15, 16))
     palette.setColor(QPalette.ToolTipBase, QColor(27, 35, 38))
     palette.setColor(QPalette.ToolTipText, Qt.white)
     palette.setColor(QPalette.Text, QColor(234, 234, 234))
     palette.setColor(QPalette.Button, QColor(27, 35, 38))
     palette.setColor(QPalette.ButtonText, Qt.white)
     palette.setColor(QPalette.BrightText, QColor(100, 215, 222))
     palette.setColor(QPalette.Link, QColor(126, 71, 130))
     # palette.setColor(QPalette.Highlight, QColor(126, 71, 130))
     # palette.setColor(QPalette.HighlightedText, Qt.white)
     palette.setColor(QPalette.Disabled, QPalette.Light, Qt.black)
     palette.setColor(QPalette.Disabled, QPalette.Shadow,
                      QColor(12, 15, 16))
     qApp.setPalette(palette)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Make the combo editable to set a custom text, but readonly
        self.setEditable(True)
        self.lineEdit().setReadOnly(True)
        # Make the lineedit the same color as QPushButton
        palette = qApp.palette()
        palette.setBrush(QPalette.Base, palette.button())
        self.lineEdit().setPalette(palette)

        # Use custom delegate
        self.setItemDelegate(CheckableComboBox.Delegate())

        # Update the text when an item is toggled
        self.model().dataChanged.connect(self.updateText)

        # Hide and show popup when clicking the line edit
        self.lineEdit().installEventFilter(self)
        self.closeOnLineEditClick = False

        # Prevent popup from closing when clicking on an item
        self.view().viewport().installEventFilter(self)
Esempio n. 10
0
    def data(self, index: QModelIndex, role=Qt.DisplayRole):
        i, j = index.row(), index.column()
        lbl = self.message_type[i]  # type: SimulatorProtocolLabel

        if role == Qt.DisplayRole:
            if j == 0:
                return lbl.name
            elif j == 1:
                return ProtocolLabel.DISPLAY_FORMATS[lbl.display_format_index]
            elif j == 2:
                if lbl.is_checksum_label:
                    return "Checksum"
                else:
                    return lbl.VALUE_TYPES[lbl.value_type_index]
            elif j == 3:
                if lbl.value_type_index == 0:
                    message = lbl.parent()

                    try:
                        data = message.plain_bits[lbl.start:lbl.end]
                    except IndexError:
                        return None

                    return util.convert_bits_to_string(
                        data, lbl.display_format_index, pad_zeros=True)
                elif lbl.value_type_index == 1:
                    return "-"
                elif lbl.value_type_index == 2:
                    return lbl.formula
                elif lbl.value_type_index == 3:
                    return lbl.external_program
                elif lbl.value_type_index == 4:
                    return "Range (Decimal): " + str(
                        lbl.random_min) + " - " + str(lbl.random_max)
        elif role == Qt.EditRole:
            if j == 0:
                return lbl.name
            elif j == 1:
                return lbl.display_format_index
            elif j == 2:
                return lbl.value_type_index
            elif j == 3:
                if lbl.value_type_index == 2:
                    return lbl.formula
                elif lbl.value_type_index == 3:
                    return lbl.external_program
                elif lbl.value_type_index == 4:
                    return [lbl.random_min, lbl.random_max]
        elif role == Qt.FontRole:
            if j == 0:
                font = QFont()
                font.setItalic(lbl.field_type is None)
                return font
            elif j == 2 and self.link_index(index):
                font = QFont()
                font.setUnderline(True)
                return font
        elif role == Qt.BackgroundColorRole:
            if j == 0:
                return constants.LABEL_COLORS[lbl.color_index]
            elif j == 3:
                if (lbl.value_type_index == 2
                        and not self.controller.sim_expression_parser.
                        validate_expression(lbl.formula)[0]):
                    return constants.ERROR_BG_COLOR
        elif role == Qt.TextColorRole:
            if self.link_index(index):
                return qApp.palette().link().color()
Esempio n. 11
0
#!/usr/bin/env python
# --!-- coding: utf8 --!--

# default window color (linux):
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QPalette
from PyQt5.QtWidgets import qApp

from manuskript import settings
from manuskript import functions as F

# Loading palette colors.
# Manuskript as to restart to reload
p = qApp.palette()
# window = "#d6d2d0" #"#eee" / #eff0f1
window = p.color(QPalette.Window).name()  # General background
windowText = p.color(QPalette.WindowText).name()  # General foregroung
base = p.color(QPalette.Base).name()  # Other background
alternateBase = p.color(QPalette.AlternateBase).name()  # Other background
text = p.color(QPalette.Text).name()  # Base Text
brightText = p.color(QPalette.BrightText).name()  # Contrast Text
button = p.color(QPalette.Button).name()  # Button background
buttonText = p.color(QPalette.ButtonText).name()  # Button Text
highlight = p.color(QPalette.Highlight).name()  # Other background
highlightedText = p.color(QPalette.HighlightedText).name()  # Base Text

light = p.color(QPalette.Light).name()  # Lighter than Button color
midlight = p.color(QPalette.Midlight).name()  # Between Button and Light
dark = p.color(QPalette.Dark).name()  # Darker than Button
mid = p.color(QPalette.Mid).name()  # Between Button and Dark
shadow = p.color(QPalette.Shadow).name()  # A very dark color
Esempio n. 12
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.p = qApp.palette()
     self.oldclr = {}
     self.newclr = {}
     self.initUI()
Esempio n. 13
0
#!/usr/bin/env python
# --!-- coding: utf8 --!--


# default window color (linux):
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QPalette
from PyQt5.QtWidgets import qApp

# window = "#d6d2d0" #"#eee" / #eff0f1
window = qApp.palette().color(QPalette.Window).name()

bgHover = "#ccc"
bgChecked = "#bbb"
borderColor = "darkGray"
blue = "#268bd2"


def mainWindowSS():
    return """
            QScrollBar{background:transparent;}
            QScrollBar:handle{
                background:rgba(0, 0, 0, 32);
                border-radius:2px;}
            QScrollBar:vertical{width: 6px;}
            QScrollBar:horizontal{width: 6px;}
            QScrollBar:add-line{background:none;border:none;}
            QScrollBar:sub-line{background:none;border:none;}
            
            QGroupBox{border:none; margin: 2ex 0 0 2ex; font-weight: bold;}
            QGroupBox:title{subcontrol-origin: margin;}
Esempio n. 14
0
#!/usr/bin/env python
# --!-- coding: utf8 --!--


# default window color (linux):
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QPalette
from PyQt5.QtWidgets import qApp

from manuskript import settings
from manuskript import functions as F

# Loading palette colors.
# Manuskript as to restart to reload
p = qApp.palette()
# window = "#d6d2d0" #"#eee" / #eff0f1
window = p.color(QPalette.Window).name()            # General background
windowText = p.color(QPalette.WindowText).name()    # General foreground
base = p.color(QPalette.Base).name()                # Other background
alternateBase = p.color(QPalette.AlternateBase).name() # Other background
text = p.color(QPalette.Text).name()                # Base Text
brightText = p.color(QPalette.BrightText).name()    # Contrast Text
button = p.color(QPalette.Button).name()            # Button background
buttonText = p.color(QPalette.ButtonText).name()    # Button Text
highlight = p.color(QPalette.Highlight).name()      # Other background
highlightedText = p.color(QPalette.HighlightedText).name() # Base Text
link = p.color(QPalette.Link).name()                # Link
linkVisited = p.color(QPalette.LinkVisited).name()  # Link visited

light = p.color(QPalette.Light).name()       # Lighter than Button color
midlight = p.color(QPalette.Midlight).name() # Between Button and Light
Esempio n. 15
0
    def data(self, index: QModelIndex, role=Qt.DisplayRole):
        i, j = index.row(), index.column()
        lbl = self.message_type[i]  # type: SimulatorProtocolLabel

        if role == Qt.DisplayRole:
            if j == 0:
                return lbl.name
            elif j == 1:
                return ProtocolLabel.DISPLAY_FORMATS[lbl.display_format_index]
            elif j == 2:
                if lbl.is_checksum_label:
                    return "Checksum"
                else:
                    return lbl.VALUE_TYPES[lbl.value_type_index]
            elif j == 3:
                if lbl.value_type_index == 0:
                    message = lbl.parent()

                    try:
                        data = message.plain_bits[lbl.start:lbl.end]
                    except IndexError:
                        return None

                    return util.convert_bits_to_string(data, lbl.display_format_index, pad_zeros=True)
                elif lbl.value_type_index == 1:
                    return "-"
                elif lbl.value_type_index == 2:
                    return lbl.formula
                elif lbl.value_type_index == 3:
                    return lbl.external_program
                elif lbl.value_type_index == 4:
                    return "Range (Decimal): " + str(lbl.random_min) + " - " + str(lbl.random_max)
        elif role == Qt.EditRole:
            if j == 0:
                return lbl.name
            elif j == 1:
                return lbl.display_format_index
            elif j == 2:
                return lbl.value_type_index
            elif j == 3:
                if lbl.value_type_index == 2:
                    return lbl.formula
                elif lbl.value_type_index == 3:
                    return lbl.external_program
                elif lbl.value_type_index == 4:
                    return [lbl.random_min, lbl.random_max]
        elif role == Qt.FontRole:
            if j == 0:
                font = QFont()
                font.setItalic(lbl.field_type is None)
                return font
            elif j == 2 and self.link_index(index):
                font = QFont()
                font.setUnderline(True)
                return font
        elif role == Qt.BackgroundColorRole:
            if j == 0:
                return constants.LABEL_COLORS[lbl.color_index]
            elif j == 3:
                if (lbl.value_type_index == 2 and
                        not self.controller.sim_expression_parser.validate_expression(lbl.formula)[0]):
                    return constants.ERROR_BG_COLOR
        elif role == Qt.TextColorRole:
            if self.link_index(index):
                return qApp.palette().link().color()