Пример #1
0
    def __init__(self, text="", parent=None):
        super(MTag, self).__init__(text=text, parent=parent)
        self._is_pressed = False
        self._close_button = MToolButton().tiny().svg(
            "close_line.svg").icon_only()
        self._close_button.clicked.connect(self.sig_closed)
        self._close_button.clicked.connect(self.close)
        self._close_button.setVisible(False)

        self._main_lay = QHBoxLayout()
        self._main_lay.setContentsMargins(0, 0, 0, 0)
        self._main_lay.addStretch()
        self._main_lay.addWidget(self._close_button)

        self.setLayout(self._main_lay)

        self._clickable = False
        self._border = True
        self._border_style = QssTemplate("""
            MTag{
                font-size: @font_size_base@font_unit;
                padding: @padding_small@unit;
                color: @text_color;
                border-radius: @border_radius;
                border: 1px solid @border_color;
                background-color: @background_color;
            }
            MTag:hover{
                color: @hover_color;
            }
            """)
        self._no_border_style = QssTemplate("""
            MTag{
                font-size: @font_size_base@font_unit;
                padding: @padding@unit;
                border-radius: @border_radius;
                color: @text_color;
                border: 0 solid @border_color;
                background-color: @background_color;
            }
            MTag:hover{
                background-color:@hover_color;
            }
        """)
        self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)

        self._color = None
        self.set_dayu_color(dayu_theme.secondary_text_color)
Пример #2
0
    def __init__(self, text="New Tag", parent=None):
        super(MNewTag, self).__init__(parent)
        self.setAttribute(Qt.WA_StyledBackground)
        self._add_button = MToolButton().text_beside_icon().small().svg(
            "add_line.svg")
        self._add_button.setText(text)
        self._add_button.clicked.connect(self._slot_show_edit)
        self._line_edit = MLineEdit().small()
        self._line_edit.returnPressed.connect(self._slot_return_pressed)
        self._line_edit.setVisible(False)
        self._line_edit.installEventFilter(self)

        self._main_lay = QGridLayout()
        self._main_lay.setContentsMargins(3, 3, 3, 3)
        self._main_lay.addWidget(self._add_button, 0, 0)
        self._main_lay.addWidget(self._line_edit, 0, 0)
        self.setLayout(self._main_lay)
        scale_x, _ = get_scale_factor()
        style = QssTemplate("""
            MNewTag{
                border: @border@unit dashed @border_color;
            }
            MNewTag MToolButton:hover{
                border:none;
            }
            """)
        self.setStyleSheet(
            style.substitute(
                border_color=utils.fade_color(dayu_theme.secondary_text_color,
                                              "35%"),
                unit=dayu_theme.unit,
                border=1 * scale_x,
            ))
Пример #3
0
    def __init__(self, text='New Tag', parent=None):
        super(MNewTag, self).__init__(parent)
        self.setAttribute(Qt.WA_StyledBackground)
        self._add_button = MToolButton().text_beside_icon().tiny().svg(
            'add_line.svg')
        self._add_button.setText(text)
        self._add_button.clicked.connect(self._slot_show_edit)
        self._line_edit = MLineEdit().tiny()
        self._line_edit.returnPressed.connect(self._slot_return_pressed)
        self._line_edit.setVisible(False)
        self._line_edit.installEventFilter(self)

        self._main_lay = QGridLayout()
        self._main_lay.setContentsMargins(3, 3, 3, 3)
        self._main_lay.addWidget(self._add_button, 0, 0)
        self._main_lay.addWidget(self._line_edit, 0, 0)
        self.setLayout(self._main_lay)
        style = QssTemplate('''
            MNewTag{
                border: 1px dashed @border_color;
            }
            MNewTag MToolButton:hover{
                border:none;
            }
            ''')
        self.setStyleSheet(style.substitute(vars(dayu_theme)))
Пример #4
0
 def __init__(self, text, parent=None):
     super(MCheckableTag, self).__init__(text, parent)
     scale_x, x = get_scale_factor()
     self.setCheckable(True)
     style = QssTemplate("""
         MCheckableTag{
             spacing: @spaceing@unit;
             padding-top: @padding@unit;
             padding-bottom: @padding@unit;
             padding-right: @spaceing@unit;
             border-radius: @border_radius_base@unit;
             font-size: @font_size_base@font_unit;
         }
         MCheckableTag::indicator{
             width: 0;
             height: 0;
             background: transparent;
         }
         MCheckableTag:pressed{
             background-color: @primary_7;
         }
         MCheckableTag:checked{
             color: @text_color_inverse;
             background-color: @primary_color;
         }
         MCheckableTag:checked:hover{
             background-color: @primary_5;
         }
         MCheckableTag:unchecked{
             color: @secondary_text_color;
             background-color: transparent;
         }
         MCheckableTag:unchecked:hover{
             color: @primary_5;
         }
         """)
     self.setStyleSheet(
         style.substitute(
             spaceing=8 * scale_x,
             padding=4 * scale_x,
             border_radius_base=dayu_theme.border_radius_base,
             unit=dayu_theme.unit,
             font_unit=dayu_theme.font_unit,
             font_size_base=dayu_theme.font_size_base,
             primary_5=dayu_theme.primary_5,
             primary_7=dayu_theme.primary_7,
             primary_color=dayu_theme.primary_color,
             secondary_text_color=dayu_theme.secondary_text_color,
             text_color_inverse=dayu_theme.text_color_inverse,
         ))
Пример #5
0
 def __init__(self, text, parent=None):
     super(MCheckableTag, self).__init__(text, parent)
     self.setCheckable(True)
     style = QssTemplate('''
         MCheckableTag{
             spacing: 8px;
             padding-top: 4px;
             padding-bottom: 4px;
             padding-right: 8px;
             border-radius: @border_radius_base@unit;
             font-size: @font_size_small@unit;
         }
         MCheckableTag::indicator{
             width: 0;
             height: 0;
             background: transparent;
         }
         MCheckableTag:pressed{
             background-color: @primary_7;
         }
         MCheckableTag:checked{
             color: @text_color_inverse;
             background-color: @primary_color;
         }
         MCheckableTag:checked:hover{
             background-color: @primary_5;
         }
         MCheckableTag:unchecked{
             color: @secondary_text_color;
             background-color: transparent;
         }
         MCheckableTag:unchecked:hover{
             color: @primary_5;
         }
         ''')
     self.setStyleSheet(style.substitute(vars(dayu_theme)))