Пример #1
0
        def add_section(label, description, data):
            """Utility method for creating the layout needed to edit default paths."""
            height = common.ROW_HEIGHT() * 0.8
            o = common.MARGIN()

            grp = common_ui.get_group(parent=self)
            grp.layout().setContentsMargins(o, o, o, o)
            grp.layout().setSpacing(0)

            label = common_ui.PaintedLabel(label,
                                           size=common.LARGE_FONT_SIZE(),
                                           parent=self)
            grp.layout().addWidget(label)
            grp.layout().addSpacing(o)

            if description:
                common_ui.add_description(description, label=None, parent=grp)
                grp.layout().addSpacing(o)

            scroll_area = QtWidgets.QScrollArea(parent=self)
            scroll_area.setWidgetResizable(True)
            scroll_area.setMaximumHeight(common.HEIGHT() * 0.66)
            scroll_area.setAttribute(QtCore.Qt.WA_NoBackground)
            scroll_area.setAttribute(QtCore.Qt.WA_TranslucentBackground)
            grp.layout().addWidget(scroll_area)

            _row = common_ui.add_row(None,
                                     vertical=True,
                                     padding=None,
                                     height=None,
                                     parent=grp)
            _row.layout().setContentsMargins(0, 0, 0, 0)
            _row.layout().setSpacing(0)
            scroll_area.setWidget(_row)

            for k, v in sorted(data.items()):
                label = u'<span style="color:rgba({ADD});">{k}</span> - {v}:'.format(
                    ADD=common.rgb(common.ADD),
                    k=k.upper(),
                    v=v[u'description'])
                row = common_ui.add_row(None,
                                        padding=None,
                                        height=height,
                                        parent=_row)
                common_ui.add_description(label, label=u'', parent=row)
                row = common_ui.add_row(None,
                                        padding=None,
                                        height=height,
                                        parent=_row)
                line_edit = common_ui.add_line_edit(v[u'default'], parent=row)
                line_edit.setAlignment(QtCore.Qt.AlignLeft)
                line_edit.setText(v[u'value'])
                line_edit.textChanged.connect(
                    functools.partial(text_changed, data, k))
Пример #2
0
 def __init__(self, parent=None):
     super(RectanglesWidget, self).__init__(parent=parent)
     self._width = 0.0
     self._height = 0.0
     self._fps = 0.0
     self._prefix = u''
     self._start = 0.0
     self._duration = 0.0
     self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
     self.setAttribute(QtCore.Qt.WA_NoSystemBackground)
     self.setMinimumHeight(common.HEIGHT() * 0.30)
     self.setMinimumWidth(common.WIDTH() * 0.15)
Пример #3
0
 def sizeHint(self):
     return QtCore.QSize(common.HEIGHT(), common.HEIGHT() * 0.5)
Пример #4
0
 def sizeHint(self):
     """The widget's default size."""
     return QtCore.QSize(common.WIDTH(), common.HEIGHT())
Пример #5
0
 def sizeHint(self):
     return QtCore.QSize(common.WIDTH() * 0.8, common.HEIGHT() * 1.2)
Пример #6
0
    def create_menu(self, menu_set, parent=None):
        """This action populates the menu using the action-set dictionaries,
        and it automatically connects the action with a corresponding method based
        on the key/method-name.

        Args:
            menu_set (OrderedDict):    The set of menu items. See keys below.
            parent (QMenu):

        Implemented keys:
            action_set[k][u'action'] (bool): The action to execute when the item is clicked.
            action_set[k][u'text'] (str): The action's text
            action_set[k][u'data'] (object): User data stored in the action
            action_set[k][u'disabled'] (bool): Sets wheter the item is disabled.
            action_set[k][u'tool_tip'] (str):The description of the action.
            action_set[k][u'status_tip'] (str): The description of the action.
            action_set[k][u'icon'] (QPixmap): The action's icon.
            action_set[k][u'shortcut'] (QKeySequence): The action's icon.
            action_set[k][u'checkable'] (bool): Sets wheter the item is checkable.
            action_set[k][u'checked'] (bool): The state of the checkbox.
            action_set[k][u'visible'] (bool): The visibility of the action.

        """
        def _showEvent(parent, event):
            """Elides the action text to fit the size of the widget upon showing."""
            w = []
            for action in parent.actions():
                if not action.text():
                    continue
                font, metrics = common.font_db.primary_font(
                    common.MEDIUM_FONT_SIZE())
                width = metrics.width(action.text())
                width += (common.MARGIN() * 4)
                w.append(int(width))
            if w:
                parent.setFixedWidth(max(w))

        if not parent:
            parent = self

        for k in menu_set:
            if u':' in k:  # Skipping `speudo` keys
                continue

            # Recursive menu creation
            if isinstance(menu_set[k], collections.OrderedDict):
                parent = QtWidgets.QMenu(k, parent=self)
                parent.setMaximumHeight(common.HEIGHT() * 1.5)
                parent.showEvent = functools.partial(_showEvent, parent)

                if u'{}:icon'.format(k) in menu_set:
                    icon = QtGui.QIcon(menu_set[u'{}:icon'.format(k)])
                    parent.setIcon(icon)
                if u'{}:text'.format(k) in menu_set:
                    parent.setTitle(menu_set[u'{}:text'.format(k)])
                if u'{}:action'.format(k) in menu_set:
                    name = menu_set[u'{}:text'.format(k)] if u'{}:text'.format(
                        k) in menu_set else k
                    icon = menu_set[u'{}:icon'.format(k)] if u'{}:icon'.format(
                        k) in menu_set else QtGui.QPixmap()
                    action = parent.addAction(name)
                    action.setIconVisibleInMenu(True)
                    action.setIcon(icon)

                    if isinstance(menu_set[u'{}:action'.format(k)], collections.Iterable):
                        for func in menu_set[u'{}:action'.format(k)]:
                            action.triggered.connect(func)
                    else:
                        action.triggered.connect(
                            menu_set[u'{}:action'.format(k)])
                    parent.addAction(action)
                    parent.addSeparator()

                self.addMenu(parent)
                self.create_menu(menu_set[k], parent=parent)
                continue

            if u'separator' in k:
                parent.addSeparator()
                continue

            action = parent.addAction(k)

            if u'data' in menu_set[k]:  # Skipping disabled items
                action.setData(menu_set[k][u'data'])
            if u'disabled' in menu_set[k]:  # Skipping disabled items
                action.setDisabled(menu_set[k][u'disabled'])
            if u'action' in menu_set[k]:
                if isinstance(menu_set[k][u'action'], collections.Iterable):
                    for func in menu_set[k][u'action']:
                        action.triggered.connect(func)
                else:
                    action.triggered.connect(menu_set[k][u'action'])
            if u'text' in menu_set[k]:
                action.setText(menu_set[k][u'text'])
            else:
                action.setText(k)
            if u'status_tip' in menu_set[k]:
                action.setStatusTip(menu_set[k][u'status_tip'])
            if u'tool_tip' in menu_set[k]:
                action.setToolTip(menu_set[k][u'tool_tip'])
            if u'checkable' in menu_set[k]:
                action.setCheckable(menu_set[k][u'checkable'])
            if u'checked' in menu_set[k]:
                action.setChecked(menu_set[k][u'checked'])
            if u'icon' in menu_set[k]:
                action.setIconVisibleInMenu(True)
                icon = QtGui.QIcon(menu_set[k][u'icon'])
                action.setIcon(icon)
            if u'shortcut' in menu_set[k]:
                action.setShortcut(menu_set[k][u'shortcut'])
            if u'visible' in menu_set[k]:
                action.setVisible(menu_set[k][u'visible'])
            else:
                action.setVisible(True)
Пример #7
0
 def __init__(self, index, parent=None):
     super(BaseContextMenu, self).__init__(parent=parent)
     self.index = index
     self.setMaximumHeight(common.HEIGHT() * 1.5)
     self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
Пример #8
0
        def add_extensions():
            height = common.ROW_HEIGHT() * 0.8
            o = common.MARGIN()

            grp = common_ui.get_group(parent=self)
            grp.layout().setContentsMargins(o, o, o, o)
            grp.layout().setSpacing(0)

            description = \
                u'Edit the list of valid extensions. Use \
    <span style="color:rgba({ADD});">*</span> to allow all files.'                                                                  .format(
                    p=common.PRODUCT,
                    ADD=common.rgb(common.ADD))

            label = common_ui.PaintedLabel(u'Default extension filters',
                                           size=common.LARGE_FONT_SIZE(),
                                           parent=self)
            grp.layout().addWidget(label)
            grp.layout().addSpacing(o)

            if description:
                common_ui.add_description(description, label=None, parent=grp)
                grp.layout().addSpacing(o)

            scroll_area = QtWidgets.QScrollArea(parent=self)
            scroll_area.setWidgetResizable(True)
            scroll_area.setMaximumHeight(common.HEIGHT() * 0.66)
            scroll_area.setAttribute(QtCore.Qt.WA_NoBackground)
            scroll_area.setAttribute(QtCore.Qt.WA_TranslucentBackground)
            grp.layout().addWidget(scroll_area)

            _row = common_ui.add_row(None,
                                     vertical=True,
                                     padding=None,
                                     height=None,
                                     parent=grp)
            _row.layout().setContentsMargins(0, 0, 0, 0)
            _row.layout().setSpacing(0)
            scroll_area.setWidget(_row)

            for k, v in sorted(defaultpaths.FORMAT_FILTERS.items(),
                               key=lambda x: x[0]):
                label = u'<span style="color:rgba({ADD});">{k}</span> - {v}:'.format(
                    ADD=common.rgb(common.ADD),
                    k=v[u'name'],
                    v=v[u'description'])
                row = common_ui.add_row(None,
                                        padding=None,
                                        height=height,
                                        parent=_row)
                common_ui.add_description(label, label=u'', parent=row)
                row = common_ui.add_row(None,
                                        padding=None,
                                        height=height,
                                        parent=_row)
                line_edit = common_ui.add_line_edit(v[u'default'], parent=row)
                line_edit.textChanged.connect(
                    functools.partial(text_changed,
                                      defaultpaths.FORMAT_FILTERS, k))
                line_edit.setAlignment(QtCore.Qt.AlignLeft)
                line_edit.setText(v[u'value'])
Пример #9
0
 def sizeHint(self):
     """Custom size hint"""
     return QtCore.QSize(common.WIDTH(), common.HEIGHT())
Пример #10
0
 def sizeHint(self):
     """The default size of the widget."""
     if self.parent():
         return QtCore.QSize(self.parent().width(), self.parent().height())
     else:
         return QtCore.QSize(common.WIDTH() * 0.6, common.HEIGHT() * 0.6)