예제 #1
0
 def __init__(self, view, host):
     UIWidget.__init__(self, host=host)
     QtWidgets.QSizeGrip.__init__(self, view)
     self.pressed = False
     self.adjust = None
     self.update_position()
     self.show()
예제 #2
0
파일: UIEmbed.py 프로젝트: osagha/Kataja
    def __init__(self, parent, host, text):
        UIWidget.__init__(self, host)
        QtWidgets.QWidget.__init__(self, parent)
        self._palette = None
        self.update_colors()
        self._drag_diff = None
        self.moved_by_hand = False

        self.top_row_layout = QtWidgets.QHBoxLayout()
        #close_button = QtWidgets.QPushButton("x")
        close_button = PanelButton(pixmap=qt_prefs.close_icon,
                                   tooltip='Close',
                                   parent=self,
                                   size=12,
                                   color_key='content1')
        close_button.setMaximumWidth(16)
        self.ui_manager.connect_element_to_action(close_button, 'close_embed')
        self.top_row_layout.addWidget(close_button)
        self.top_row_layout.setAlignment(QtCore.Qt.AlignLeft)
        self.top_row_layout.addSpacing(8)
        self.top_title = QtWidgets.QLabel(text)
        self.top_row_layout.addWidget(self.top_title)
        self.assumed_width = 300
        self.assumed_height = 100
        self._magnet = QtCore.QPoint(0, 0), 1
        # Effect will be disabled if QTextEdit is used.
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QtGui.QPalette.Window)
        self.hide()
예제 #3
0
    def __init__(self, name, default_position='bottom', parent=None, ui_manager=None, folded=False):
        """

        :param name:
        :param default_position:
        :param parent:
        """
        UIWidget.__init__(self)
        QtWidgets.QDockWidget.__init__(self, name, parent=parent)
        #self.ui_type = 'Panel'
        self.folded = folded
        self.name = name
        self._watched = False
        self._last_position = None
        self.resize_grip = None
        self.watchlist = []
        self.default_position = default_position

        if default_position == 'bottom':
            parent.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self)
        elif default_position == 'top':
            parent.addDockWidget(QtCore.Qt.TopDockWidgetArea, self)
        elif default_position == 'left':
            parent.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self)
        elif default_position == 'right':
            parent.addDockWidget(QtCore.Qt.RightDockWidgetArea, self)
        elif default_position == 'float':
            parent.addDockWidget(QtCore.Qt.RightDockWidgetArea, self)
            self.setFloating(True)
        self.dockLocationChanged.connect(self.report_dock_location)
        self.topLevelChanged.connect(self.report_top_level)
        self.setContentsMargins(0, 0, 0, 0)
        title_widget = PanelTitle(name, self)
        self.setTitleBarWidget(title_widget)
        self.report_top_level(self.isFloating())
예제 #4
0
 def __init__(self, host, parent=None, ui_key=None, text=None,
              size=16, color_key='accent8', tooltip=None, **kwargs):
     UIWidget.__init__(self, ui_key=ui_key or 'OverlayLabel', host=host)
     text = host.label_object.edited_field + "→"
     QtWidgets.QLabel.__init__(self, text, parent)
     if tooltip:
         self.setToolTip(tooltip)
예제 #5
0
파일: UIEmbed.py 프로젝트: jpurma/Kataja
    def __init__(self, parent, host, text):
        UIWidget.__init__(self, host=host)
        QtWidgets.QWidget.__init__(self, parent)
        self._palette = None
        self.update_colors()
        self._drag_diff = None
        self.moved_by_hand = False
        self.vlayout = QtWidgets.QVBoxLayout()

        self.top_row_layout = QtWidgets.QHBoxLayout()
        # close_button = QtWidgets.QPushButton("x")
        close_button = PanelButton(pixmap=qt_prefs.close_icon, parent=self, size=12,
                                   color_key='content1')
        close_button.setMaximumWidth(16)
        self.ui_manager.connect_element_to_action(close_button, 'close_embed')
        self.top_row_layout.addWidget(close_button)
        self.top_row_layout.setAlignment(QtCore.Qt.AlignLeft)
        self.top_row_layout.addSpacing(8)
        self.top_title = QtWidgets.QLabel(text)
        self.top_row_layout.addWidget(self.top_title)
        self.assumed_width = 300
        self.assumed_height = 100
        self._magnet = QtCore.QPoint(0, 0), 1
        # Effect will be disabled if QTextEdit is used.
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QtGui.QPalette.Window)
        self.hide()
        self.vlayout.addLayout(self.top_row_layout)  # close-button from UIEmbed
        self.vlayout.addSpacing(4)
        self.setLayout(self.vlayout)
예제 #6
0
 def __init__(self, host, parent=None, ui_key=None, text=None,
              size=16, color_key='accent8', tooltip=None, **kwargs):
     UIWidget.__init__(self, ui_key=ui_key or 'OverlayLabel', host=host)
     text = host.label_object.edited_field + "→"
     QtWidgets.QLabel.__init__(self, text, parent)
     if tooltip:
         self.setToolTip(tooltip)
예제 #7
0
 def __init__(self, view, host):
     UIWidget.__init__(self, host=host)
     QtWidgets.QSizeGrip.__init__(self, view)
     self.pressed = False
     self.adjust = None
     self.update_position()
     self.show()
예제 #8
0
 def __init__(self, parent=None, range_min=0, range_max=0, suffix='', wrapping=False, **kwargs):
     QtWidgets.QSpinBox.__init__(self, parent=parent)
     UIWidget.__init__(self, **kwargs)
     self.setAccelerated(True)
     self.setReadOnly(False)
     self.setButtonSymbols(QtWidgets.QAbstractSpinBox.PlusMinus)
     self.setRange(range_min, range_max)
     self.setSuffix(suffix)
     self.setWrapping(wrapping)
     self.setFixedWidth(50)
     self.setFocusPolicy(QtCore.Qt.StrongFocus)
예제 #9
0
 def __init__(self, parent=None, range_min=0, range_max=0, step=1.0, suffix='', wrapping=False,
              **kwargs):
     QtWidgets.QDoubleSpinBox.__init__(self, parent=parent)
     UIWidget.__init__(self, **kwargs)
     self.setAccelerated(True)
     self.setReadOnly(False)
     self.setButtonSymbols(QtWidgets.QAbstractSpinBox.PlusMinus)
     self.setRange(range_min, range_max)
     self.setSingleStep(step)
     self.setSuffix(suffix)
     self.setWrapping(wrapping)
     self.setFixedWidth(58)
예제 #10
0
 def __init__(self, text_options, ui_key, parent=None):
     UIWidget.__init__(self, ui_key=ui_key)
     PanelButton.__init__(self, None, text_options[0], size=24, parent=parent)
     self.setCheckable(True)
     self.text_options = text_options
     font = QtGui.QFont(qt_prefs.fonts[g.UI_FONT])
     font.setPointSize(font.pointSize() * 1.2)
     fm = QtGui.QFontMetrics(font)
     mw = max([fm.width(text) for text in text_options])
     self.setFlat(True)
     self.setMinimumWidth(mw + 12)
     self.setMinimumHeight(24)
     ctrl.add_watcher(self, 'ui_font_changed')
예제 #11
0
 def __init__(self, parent=None, text=None, size=None, **kwargs):
     QtWidgets.QPushButton.__init__(self, parent=parent)
     UIWidget.__init__(self, **kwargs)
     if text:
         self.setText(text)
     if size:
         if isinstance(size, QtCore.QSize):
             width = size.width()
             height = size.height()
         elif isinstance(size, tuple):
             width = size[0]
             height = size[1]
         else:
             width = size
             height = size
         size = QtCore.QSize(width, height)
         self.setIconSize(size)
     ctrl.ui.add_ui(self)
예제 #12
0
 def __init__(self, text_options, ui_key, parent=None, icon=None):
     UIWidget.__init__(self, ui_key=ui_key)
     self.negated_icon = None
     PanelButton.__init__(self,
                          icon,
                          text_options[0],
                          size=24,
                          parent=parent)
     self.setCheckable(True)
     self.text_options = text_options
     font = QtGui.QFont(qt_prefs.fonts[g.UI_FONT])
     font.setPointSize(font.pointSize() * 1.2)
     fm = QtGui.QFontMetrics(font)
     mw = max([fm.width(text) for text in text_options])
     self.setFlat(True)
     self.setMinimumWidth(mw + 12)
     self.setMinimumHeight(24)
     ctrl.add_watcher(self, 'ui_font_changed')
예제 #13
0
    def __init__(self, parent, tooltip='', font=None, prefill='', on_edit=None):
        UIWidget.__init__(self, tooltip=tooltip)
        QtWidgets.QPlainTextEdit.__init__(self, parent)
        if prefill:
            self.setPlaceholderText(prefill)
        self.setAcceptDrops(True)
        self.setSizeAdjustPolicy(QtWidgets.QTextEdit.AdjustToContents)
        self.setMinimumHeight(24)
        self.changed = False
        self.textChanged.connect(self.flag_as_changed)
        # if a font is provided here, it has to be updated manually. Default font (console) will get updated through
        # master stylesheet
        if font:
            self.setStyleSheet('font-family: "%s"; font-size: %spx;' % (
                font.family(), font.pointSize()))

        if on_edit:
            self.textChanged.connect(on_edit)
        self.updateGeometry()
예제 #14
0
    def __init__(self,
                 name,
                 default_position='bottom',
                 parent=None,
                 ui_manager=None,
                 folded=False):
        """

        :param name:
        :param default_position:
        :param parent:
        """
        UIWidget.__init__(self)
        QtWidgets.QDockWidget.__init__(self, name, parent=parent)
        #self.ui_type = 'Panel'
        self.folded = folded
        self.name = name
        self._watched = False
        self._last_position = None
        self.resize_grip = None
        self.watchlist = []
        self.default_position = default_position

        if default_position == 'bottom':
            parent.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self)
        elif default_position == 'top':
            parent.addDockWidget(QtCore.Qt.TopDockWidgetArea, self)
        elif default_position == 'left':
            parent.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self)
        elif default_position == 'right':
            parent.addDockWidget(QtCore.Qt.RightDockWidgetArea, self)
        elif default_position == 'float':
            parent.addDockWidget(QtCore.Qt.RightDockWidgetArea, self)
            self.setFloating(True)
        self.dockLocationChanged.connect(self.report_dock_location)
        self.topLevelChanged.connect(self.report_top_level)
        self.setContentsMargins(0, 0, 0, 0)
        title_widget = PanelTitle(name, self)
        self.setTitleBarWidget(title_widget)
        self.report_top_level(self.isFloating())
예제 #15
0
 def __init__(self, parent, tooltip='', font=None, prefill='', stretch=False, on_edit=None,
              on_finish=None, on_return=None):
     QtWidgets.QLineEdit.__init__(self, parent)
     UIWidget.__init__(self, tooltip=tooltip)
     if font:
         self.setFont(font)
     if prefill:
         self.setPlaceholderText(prefill)
     self.stretch = stretch
     if stretch:
         self.textChanged.connect(self.check_for_resize)
     self.textEdited.connect(self.flag_as_changed)
     if on_edit:
         self.textChanged.connect(on_edit)
     if on_finish:
         self.editingFinished.connect(on_finish)
     if on_return:
         self.returnPressed.connect(on_return)
     self.setAcceptDrops(True)
     self.setDragEnabled(True)
     self.changed = False
     self.original = ''
예제 #16
0
 def __init__(self, parent, tooltip='', big_font=None, smaller_font=None, prefill='',
              on_edit=None):
     QtWidgets.QWidget.__init__(self, parent)
     UIWidget.__init__(self, tooltip=tooltip)
     self.line_mode = True
     self.original_text = ''
     layout = QtWidgets.QVBoxLayout()
     self.line_edit = QtWidgets.QLineEdit(parent)
     #self.command_prompt.setClearButtonEnabled(True)
     self.text_area = QtWidgets.QPlainTextEdit(parent)
     self.text_area.setAutoFillBackground(True)
     self.text_area.setSizeAdjustPolicy(self.text_area.AdjustToContents)
     self.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)
     self.on_edit = on_edit
     self.line_edit.show()
     self.text_area.hide()
     self.text_area.setEnabled(False)
     self.line_edit.setEnabled(True)
     self.cut_point = 24
     layout.setContentsMargins(0, 0, 0, 0)
     layout.addWidget(self.line_edit)
     layout.addWidget(self.text_area)
     self.setLayout(layout)
     self.line_edit.setMinimumHeight(26)
     self.text_area.setMinimumHeight(40)
     self.k_tooltip = tooltip
     if big_font:
         self.line_edit.setFont(big_font)
     if smaller_font:
         self.text_area.setFont(smaller_font)
     if prefill:
         self.line_edit.setPlaceholderText(prefill)
         self.text_area.setPlaceholderText(prefill)
     self.line_edit.textChanged.connect(self.line_edit_check_for_resize)
     self.text_area.textChanged.connect(self.text_area_check_for_resize)
     self.setAcceptDrops(True)
     self.line_edit.setDragEnabled(True)
     self.original_size = None
     self.changed = False
예제 #17
0
    def __init__(self, parent=None, ui=None):
        UIWidget.__init__(self)
        QtWidgets.QFrame.__init__(self, parent=parent)
        layout = QtWidgets.QHBoxLayout()
        self.host_node = None  # find out if there are more benefits from connecting properly to
        # host -- now we use 'host_node' instead of host, because we don't want this to be
        # automatically destroyed with the host.
        self.doc = None
        self.show()
        self.current_format = QtGui.QTextCharFormat()
        self._left_buttons = []

        # Left align
        # self.italic_icon = icon('italic24.png')
        # self.bold_icon = icon('bold24.png')
        # self.strikethrough_icon = icon('strikethrough24.png')
        # self.underline_icon = icon('underline24.png')
        # self.subscript_icon = icon('align_bottom24.png')
        # self.superscript_icon = icon('align_top24.png')
        # self.left_align_icon = icon('align_left24.png')
        # self.center_align_icon = icon('align_center24.png')
        # self.right_align_icon = icon('align_right24.png')
        # self.remove_styles_icon = icon('no_format24.png')

        self.italic = QuickEditButton(action='toggle_italic', parent=self,
                                      pixmap=qt_prefs.italic_icon)
        ui.add_button(self.italic, action='toggle_italic')
        self.italic.setCheckable(True)
        self._left_buttons.append(self.italic)
        layout.addWidget(self.italic)

        self.bold = QuickEditButton(action='toggle_bold', parent=self, pixmap=qt_prefs.bold_icon)
        ui.add_button(self.bold, action='toggle_bold')
        self.bold.setCheckable(True)
        self._left_buttons.append(self.bold)
        layout.addWidget(self.bold)

        self.underline = QuickEditButton(action='toggle_underline', parent=self,
                                         pixmap=qt_prefs.underline_icon)
        ui.add_button(self.underline, action='toggle_underline')
        self.underline.setCheckable(True)
        self._left_buttons.append(self.underline)
        layout.addWidget(self.underline)

        self.strikethrough = QuickEditButton(action='toggle_strikethrough', parent=self,
                                             pixmap=qt_prefs.strikethrough_icon)
        ui.add_button(self.strikethrough, action='toggle_strikethrough')
        self.strikethrough.setCheckable(True)
        self._left_buttons.append(self.strikethrough)
        layout.addWidget(self.strikethrough)

        self.subscript = QuickEditButton(action='toggle_subscript', parent=self,
                                         pixmap=qt_prefs.subscript_icon)
        ui.add_button(self.subscript, action='toggle_subscript')
        self.subscript.setCheckable(True)
        self._left_buttons.append(self.subscript)
        layout.addWidget(self.subscript)

        self.superscript = QuickEditButton(action='toggle_superscript', parent=self,
                                           pixmap=qt_prefs.superscript_icon)
        ui.add_button(self.superscript, action='toggle_superscript')
        self.superscript.setCheckable(True)
        self._left_buttons.append(self.superscript)
        layout.addWidget(self.superscript)

        self.no_style = QuickEditButton(action='remove_styles', parent=self,
                                        pixmap=qt_prefs.remove_styles_icon)
        ui.add_button(self.no_style, action='remove_styles')
        self._left_buttons.append(self.no_style)
        layout.addWidget(self.no_style)

        layout.setContentsMargins(2, 0, 2, 0)
        self.setLayout(layout)
        self.setMinimumHeight(28)
        min_width = 0
        for item in self._left_buttons:
            min_width += item.width()
        self.setMinimumWidth(min_width)
예제 #18
0
 def __init__(self, parent=None, group=None, **kwargs):
     QtWidgets.QRadioButton.__init__(self, parent=parent)
     UIWidget.__init__(self, **kwargs)
     if group:
         group.addButton(self)
예제 #19
0
 def leaveEvent(self, event):
     UIWidget.leaveEvent(self, event)
     return QtWidgets.QPlainTextEdit.leaveEvent(self, event)
예제 #20
0
 def mouseMoveEvent(self, event):
     UIWidget.mouseMoveEvent(self, event)
     return QtWidgets.QPlainTextEdit.mouseMoveEvent(self, event)
예제 #21
0
 def enterEvent(self, event):
     UIWidget.enterEvent(self, event)
     return QtWidgets.QPlainTextEdit.enterEvent(self, event)
예제 #22
0
    def __init__(self, parent=None, ui=None):
        UIWidget.__init__(self)
        QtWidgets.QFrame.__init__(self, parent=parent)
        layout = QtWidgets.QHBoxLayout()
        self.host_node = None  # find out if there are more benefits from connecting properly to
        # host -- now we use 'host_node' instead of host, because we don't want this to be
        # automatically destroyed with the host.
        self.doc = None
        self.show()
        self.current_format = QtGui.QTextCharFormat()
        self._left_buttons = []

        # Left align
        #self.italic_icon = icon('italic24.png')
        #self.bold_icon = icon('bold24.png')
        #self.strikethrough_icon = icon('strikethrough24.png')
        #self.underline_icon = icon('underline24.png')
        #self.subscript_icon = icon('align_bottom24.png')
        #self.superscript_icon = icon('align_top24.png')
        #self.left_align_icon = icon('align_left24.png')
        #self.center_align_icon = icon('align_center24.png')
        #self.right_align_icon = icon('align_right24.png')
        #self.remove_styles_icon = icon('no_format24.png')

        self.italic = QuickEditButton('italic_button', parent=self,
                                      tooltip='Italic - \\emph{...} - <i>...</i>)',
                                      pixmap=qt_prefs.italic_icon, size=(24, 24))
        ui.add_button(self.italic, action='toggle_italic')
        self.italic.setCheckable(True)
        self._left_buttons.append(self.italic)
        layout.addWidget(self.italic)

        self.bold = QuickEditButton('bold_button', parent=self,
                                    tooltip='Bold - \\textbf{...} - <b>...</b>)',
                                    pixmap=qt_prefs.bold_icon, size=(24, 24))
        ui.add_button(self.bold, action='toggle_bold')
        self.bold.setCheckable(True)
        self._left_buttons.append(self.bold)
        layout.addWidget(self.bold)

        self.underline = QuickEditButton('underline_button', parent=self,
                                         tooltip='Underline - \\emph{...} - <u>...</u>)',
                                         pixmap=qt_prefs.underline_icon, size=(24, 24))
        ui.add_button(self.underline, action='toggle_underline')
        self.underline.setCheckable(True)
        self._left_buttons.append(self.underline)
        layout.addWidget(self.underline)

        self.strikethrough = QuickEditButton('strikethrough_button', parent=self,
                                             tooltip='Strikethrough',
                                             pixmap=qt_prefs.strikethrough_icon,
                                             size=(24, 24))
        ui.add_button(self.strikethrough, action='toggle_strikethrough')
        self.strikethrough.setCheckable(True)
        self._left_buttons.append(self.strikethrough)
        layout.addWidget(self.strikethrough)

        self.subscript = QuickEditButton('subscript_button', parent=self,
                                         tooltip='Subscript - \\_{...} - <sub>...</sub>)',
                                         pixmap=qt_prefs.subscript_icon, size=(24, 24))
        ui.add_button(self.subscript, action='toggle_subscript')
        self.subscript.setCheckable(True)
        self._left_buttons.append(self.subscript)
        layout.addWidget(self.subscript)

        self.superscript = QuickEditButton('superscript_button', parent=self,
                                           tooltip='Superscript - \\_{...} - <sup>...</sup>)',
                                           pixmap=qt_prefs.superscript_icon, size=(24, 24))
        ui.add_button(self.superscript, action='toggle_superscript')
        self.superscript.setCheckable(True)
        self._left_buttons.append(self.superscript)
        layout.addWidget(self.superscript)

        self.no_style = QuickEditButton('no_style_button', parent=self,
                                        tooltip='Remove styles',
                                        pixmap=qt_prefs.remove_styles_icon, size=(24, 24))
        ui.add_button(self.no_style, action='remove_styles')
        self._left_buttons.append(self.no_style)
        layout.addWidget(self.no_style)

        layout.setContentsMargins(2, 0, 2, 0)
        self.setLayout(layout)
        self.setMinimumHeight(28)
        min_width = 0
        for item in self._left_buttons:
            min_width += item.width()
        self.setMinimumWidth(min_width)
예제 #23
0
 def __init__(self, parent=None, **kwargs):
     QtWidgets.QCheckBox.__init__(self, parent=parent)
     UIWidget.__init__(self, **kwargs)
예제 #24
0
 def __init__(self, host, ui_key=None, pixmap=None, text=None, parent=None,
              size=16, color_key='accent8', draw_method=None, tooltip=None, **kwargs):
     UIWidget.__init__(self, ui_key=ui_key, host=host)
     PanelButton.__init__(self, pixmap=pixmap, text=text, parent=parent, size=size,
                          color_key=color_key, draw_method=draw_method, tooltip=tooltip)
     self.hover_icon = None
예제 #25
0
 def enterEvent(self, event):
     UIWidget.enterEvent(self, event)
     return QtWidgets.QPushButton.enterEvent(self, event)
예제 #26
0
 def leaveEvent(self, event):
     UIWidget.leaveEvent(self, event)
     return QtWidgets.QPushButton.leaveEvent(self, event)
예제 #27
0
    def __init__(self, parent=None, ui=None):
        UIWidget.__init__(self)
        QtWidgets.QFrame.__init__(self, parent=parent)
        layout = QtWidgets.QHBoxLayout()
        self.host_node = None  # find out if there are more benefits from connecting properly to
        # host -- now we use 'host_node' instead of host, because we don't want this to be
        # automatically destroyed with the host.
        self.doc = None
        self.show()
        self.current_format = QtGui.QTextCharFormat()
        self._left_buttons = []

        # Left align
        # self.italic_icon = icon('italic24.png')
        # self.bold_icon = icon('bold24.png')
        # self.strikethrough_icon = icon('strikethrough24.png')
        # self.underline_icon = icon('underline24.png')
        # self.subscript_icon = icon('align_bottom24.png')
        # self.superscript_icon = icon('align_top24.png')
        # self.left_align_icon = icon('align_left24.png')
        # self.center_align_icon = icon('align_center24.png')
        # self.right_align_icon = icon('align_right24.png')
        # self.remove_styles_icon = icon('no_format24.png')

        self.italic = QuickEditButton(
            "italic_button",
            parent=self,
            tooltip="Italic - \\emph{...} - <i>...</i>)",
            pixmap=qt_prefs.italic_icon,
            size=(24, 24),
        )
        ui.add_button(self.italic, action="toggle_italic")
        self.italic.setCheckable(True)
        self._left_buttons.append(self.italic)
        layout.addWidget(self.italic)

        self.bold = QuickEditButton(
            "bold_button",
            parent=self,
            tooltip="Bold - \\textbf{...} - <b>...</b>)",
            pixmap=qt_prefs.bold_icon,
            size=(24, 24),
        )
        ui.add_button(self.bold, action="toggle_bold")
        self.bold.setCheckable(True)
        self._left_buttons.append(self.bold)
        layout.addWidget(self.bold)

        self.underline = QuickEditButton(
            "underline_button",
            parent=self,
            tooltip="Underline - \\emph{...} - <u>...</u>)",
            pixmap=qt_prefs.underline_icon,
            size=(24, 24),
        )
        ui.add_button(self.underline, action="toggle_underline")
        self.underline.setCheckable(True)
        self._left_buttons.append(self.underline)
        layout.addWidget(self.underline)

        self.strikethrough = QuickEditButton(
            "strikethrough_button",
            parent=self,
            tooltip="Strikethrough",
            pixmap=qt_prefs.strikethrough_icon,
            size=(24, 24),
        )
        ui.add_button(self.strikethrough, action="toggle_strikethrough")
        self.strikethrough.setCheckable(True)
        self._left_buttons.append(self.strikethrough)
        layout.addWidget(self.strikethrough)

        self.subscript = QuickEditButton(
            "subscript_button",
            parent=self,
            tooltip="Subscript - \\_{...} - <sub>...</sub>)",
            pixmap=qt_prefs.subscript_icon,
            size=(24, 24),
        )
        ui.add_button(self.subscript, action="toggle_subscript")
        self.subscript.setCheckable(True)
        self._left_buttons.append(self.subscript)
        layout.addWidget(self.subscript)

        self.superscript = QuickEditButton(
            "superscript_button",
            parent=self,
            tooltip="Superscript - \\_{...} - <sup>...</sup>)",
            pixmap=qt_prefs.superscript_icon,
            size=(24, 24),
        )
        ui.add_button(self.superscript, action="toggle_superscript")
        self.superscript.setCheckable(True)
        self._left_buttons.append(self.superscript)
        layout.addWidget(self.superscript)

        self.no_style = QuickEditButton(
            "no_style_button", parent=self, tooltip="Remove styles", pixmap=qt_prefs.remove_styles_icon, size=(24, 24)
        )
        ui.add_button(self.no_style, action="remove_styles")
        self._left_buttons.append(self.no_style)
        layout.addWidget(self.no_style)

        layout.setContentsMargins(2, 0, 2, 0)
        self.setLayout(layout)
        self.setMinimumHeight(28)
        min_width = 0
        for item in self._left_buttons:
            min_width += item.width()
        self.setMinimumWidth(min_width)
        self.update_position()
예제 #28
0
 def __init__(self, host, ui_key=None, pixmap=None, text=None, parent=None,
              size=16, color_key='accent8', draw_method=None, tooltip=None, **kwargs):
     UIWidget.__init__(self, ui_key=ui_key, host=host)
     PanelButton.__init__(self, pixmap=pixmap, text=text, parent=parent, size=size,
                          color_key=color_key, draw_method=draw_method, tooltip=tooltip)