예제 #1
0
    def __init__(self, *args, **kwargs):

        margins = kwargs.pop('margins', (0, 0, 0, 0))
        spacing = kwargs.pop('spacing', consts.DEFAULT_SUB_WIDGET_SPACING)
        column_min_width = kwargs.pop('column_min_width', None)
        column_min_width_b = kwargs.pop('column_min_width_b', None)
        vertical_spacing = kwargs.pop('vertical_spacing', None)
        horizontal_spacing = kwargs.pop('horizontal_spacing', None)

        super(GridLayout, self).__init__(*args, **kwargs)

        self.setContentsMargins(*qtutils.margins_dpi_scale(*margins))

        if not vertical_spacing and not horizontal_spacing:
            self.setHorizontalSpacing(qtutils.dpi_scale(spacing))
            self.setVerticalSpacing(qtutils.dpi_scale(spacing))
        elif vertical_spacing and not horizontal_spacing:
            self.setHorizontalSpacing(qtutils.dpi_scale(horizontal_spacing))
            self.setVerticalSpacing(qtutils.dpi_scale(vertical_spacing))
        elif horizontal_spacing and not vertical_spacing:
            self.setHorizontalSpacing(qtutils.dpi_scale(horizontal_spacing))
            self.setVerticalSpacing(qtutils.dpi_scale(spacing))
        else:
            self.setHorizontalSpacing(qtutils.dpi_scale(horizontal_spacing))
            self.setVerticalSpacing(qtutils.dpi_scale(vertical_spacing))

        if column_min_width:
            self.setColumnMinimumWidth(column_min_width[0], qtutils.dpi_scale(column_min_width[1]))
        if column_min_width_b:
            self.setColumnMinimumWidth(column_min_width_b[0], qtutils.dpi_scale(column_min_width_b[1]))
예제 #2
0
    def set_spacing_y(self, spacing):
        """
        Sets the Y spacing for each item
        :param spacing: float
        """

        self._spacing_y = qtutils.dpi_scale(spacing)
예제 #3
0
    def _init(self):
        """
        Overrides base WindowResizer _int function
        """

        super(HorizontalResizer, self)._init()
        self.setFixedWidth(qtutils.dpi_scale(4))
예제 #4
0
    def _init(self):
        """
        Overrides base WindowResizer _int function
        """

        super(VerticalResizer, self)._init()
        self.setFixedHeight(qtutils.dpi_scale(4))
예제 #5
0
    def set_icon_padding(self, padding):
        """
        Sets the padding for the icons of the toolbar
        :param padding: int
        """

        self._icon_padding = qtutils.dpi_scale(padding)
예제 #6
0
    def set_height(self, value):
        """
        Sets the size of the dragger and updates icon
        :param value: float
        """

        self.setFixedHeight(qtutils.dpi_scale(value))
예제 #7
0
    def __init__(self, *args, **kwargs):

        margins = kwargs.pop('margins', (0, 0, 0, 0))
        spacing = kwargs.pop('spacing', consts.DEFAULT_SUB_WIDGET_SPACING)

        super(FormLayout, self).__init__(*args, **kwargs)

        self.setContentsMargins(*qtutils.margins_dpi_scale(*margins))
        self.setSpacing(qtutils.dpi_scale(spacing))
예제 #8
0
 def keyPressEvent(self, event):
     if event.key() == self._tt_key:
         pos = self.mapFromGlobal(QCursor.pos())
         action = self.actionAt(pos)
         if tooltips.has_expanded_tooltips(action):
             self._popup_tooltip = tooltips.ExpandedTooltipPopup(
                 widget=action,
                 icon_size=qtutils.dpi_scale(40),
                 popup_release=self._tt_key)
             self._tt_key_pressed = True
     super(BaseMenuButton.SearchMenu, self).keyPressEvent(event)
예제 #9
0
    def resizeEvent(self, event):
        super(SnapshotWindow, self).resizeEvent(event)

        widgets_to_hide = ((self._image_size_lbl, 250), (self._lock_button, 240),
                           (self._aspect_link_button, 185), (self._cancel_button, 155))
        for widget, size in widgets_to_hide:
            widget.setVisible(self.width() > qtutils.dpi_scale(size))

        spacer_threshold = 120

        self._bottom_bar.layout().setSpacing(0) if self.width() < spacer_threshold else \
            self._bottom_bar.layout().setSpacing(6)
예제 #10
0
    def ui(self):
        super(Project, self).ui()

        self.setMaximumWidth(qtutils.dpi_scale(160))
        self.setMaximumHeight(qtutils.dpi_scale(200))

        widget_layout = layouts.VerticalLayout(spacing=0, margins=(0, 0, 0, 0))
        main_frame = QFrame()
        main_frame.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        main_frame.setLineWidth(1)
        main_frame.setLayout(widget_layout)
        self.main_layout.addWidget(main_frame)

        self.project_btn = QPushButton('', self)
        self.project_btn.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.project_btn.setIconSize(QSize(120, 120))
        project_lbl = label.BaseLabel(self.name, parent=self)
        project_lbl.setObjectName('projectLabel')
        project_lbl.setAlignment(Qt.AlignCenter)
        widget_layout.addWidget(self.project_btn)
        widget_layout.addWidget(project_lbl)
예제 #11
0
def get_vertical_separator_widget(max_height=30, parent=None):
    """
    Returns horizontal separator widget
    :param max_height: int, maximum height for the separator
    :param parent: QWidget or None, parent widget
    :return: QWidget
    """

    h_div_w = QWidget(parent=parent)
    h_div_l = layouts.VerticalLayout(spacing=0, margins=(5, 5, 5, 5))
    h_div_l.setAlignment(Qt.AlignLeft)
    h_div_w.setLayout(h_div_l)
    h_div = QFrame(parent=h_div_w)
    h_div.setObjectName('dividerSeparator')  # ID selector used by style
    h_div.setMaximumHeight(qtutils.dpi_scale(max_height))
    h_div.setFrameShape(QFrame.VLine)
    h_div.setFrameShadow(QFrame.Sunken)
    h_div_l.addWidget(h_div)

    return h_div_w
예제 #12
0
 def setFixedSize(self, size):
     super(BaseMenuButton, self).setFixedSize(qtutils.dpi_scale(size))
예제 #13
0
 def setFixedHeight(self, height):
     return super(BaseMenuButton,
                  self).setFixedHeight(qtutils.dpi_scale(height))
예제 #14
0
파일: dpi.py 프로젝트: tpDcc/tpDcc-libs-qt
 def setMinimumHeight(self, height):
     return super(DPIScaling,
                  self).setMinimumHeight(qtutils.dpi_scale(height))
예제 #15
0
 def setFixedWidth(self, width):
     return super(BaseMenuButton,
                  self).setFixedWidth(qtutils.dpi_scale(width))
예제 #16
0
    def ui(self):
        super(SnapshotWindow, self).ui()

        camera_icon = resources.icon('camera')
        cancel_icon = resources.icon('delete')
        self._link_icon = resources.icon('link')
        self._unlink_icon = resources.icon('unlink')
        self._lock_icon = resources.icon('lock')
        self._unlock_icon = resources.icon('unlock')

        self.window().setWindowFlags(self.window().windowFlags() | Qt.WindowStaysOnTopHint)

        self._setup_dragger()
        self.main_widget.setStyleSheet('WindowContents { background-color: transparent; }')

        snap_layout = layouts.HorizontalLayout(spacing=0)

        self._snap_widget = QWidget()
        self._snap_widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        left_panel = SnapshotFrame(self)
        left_panel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        left_panel.setFixedWidth(qtutils.dpi_scale(5))
        right_panel = SnapshotFrame(self)
        right_panel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding)
        right_panel.setFixedWidth(qtutils.dpi_scale(5))
        snap_layout.addWidget(left_panel)
        snap_layout.addWidget(self._snap_widget, stretch=1)
        snap_layout.addWidget(right_panel)

        buttom_layout = layouts.HorizontalLayout(margins=(5, 5, 5, 5))
        self._bottom_bar = SnapshotFrame(self)
        self._bottom_bar.setLayout(buttom_layout)
        self._bottom_bar.setFixedHeight(qtutils.dpi_scale(33))

        self._image_size_lbl = label.BaseLabel('Image Size')
        qtutils.set_horizontal_size_policy(self._image_size_lbl, QSizePolicy.Ignored)
        self._image_size_lbl.setMaximumWidth(self._image_size_lbl.sizeHint().width())
        self._width_line = lineedit.BaseLineEdit(input_mode='int')
        self._width_line.setMinimumWidth(qtutils.dpi_scale(19))
        qtutils.set_size_hint(self._width_line, qtutils.size_by_dpi(QSize(40, self._width_line.sizeHint().height())))
        self._height_line = lineedit.BaseLineEdit(input_mode='int')
        self._height_line.setMinimumHeight(qtutils.dpi_scale(19))
        qtutils.set_size_hint(self._height_line, qtutils.size_by_dpi(QSize(40, self._height_line.sizeHint().height())))
        self._aspect_link_button = buttons.BaseToolButton()
        self._aspect_link_button.setIcon(self._link_icon)
        self._aspect_link_button.setCheckable(True)
        self._aspect_link_button.setMinimumWidth(qtutils.dpi_scale(24))
        self._aspect_link_button.setChecked(True)
        self._lock_button = buttons.BaseToolButton()
        self._lock_button.setCheckable(True)
        self._lock_button.setIcon(self._unlock_icon)
        self._snapshot_button = buttons.BaseButton('Snapshot', camera_icon)
        self._snapshot_button.setMaximumWidth(self._snapshot_button.sizeHint().width())
        self._cancel_button = buttons.BaseButton('Cancel', cancel_icon)
        qtutils.set_horizontal_size_policy(self._cancel_button, QSizePolicy.Ignored)
        self._cancel_button.setMaximumWidth(self._cancel_button.sizeHint().width())

        self._cancel_button.setMinimumWidth(qtutils.dpi_scale(24))

        buttom_layout.addWidget(self._image_size_lbl, 4)
        buttom_layout.addWidget(self._width_line)
        buttom_layout.addWidget(self._aspect_link_button)
        buttom_layout.addWidget(self._height_line)
        buttom_layout.addWidget(self._lock_button)
        buttom_layout.addStretch()
        buttom_layout.addWidget(self._snapshot_button, 3)
        buttom_layout.addWidget(self._cancel_button, 3)

        self.main_layout.addLayout(snap_layout)
        self.main_layout.addWidget(self._bottom_bar)

        self.window().setMinimumSize(98, 142)
예제 #17
0
 def _get_bottom_size(self):
     return self._bottom_bar.height() + self._bottom_resizer.height() + qtutils.dpi_scale(2)
예제 #18
0
    def ui(self):
        self.setFixedHeight(qtutils.dpi_scale(40))

        main_layout = layouts.HorizontalLayout(spacing=5,
                                               margins=(15, 0, 15, 0))
        self.setLayout(main_layout)

        self._logo_button = self._setup_logo_button()
        self._title_text = label.ClippedLabel(text=self._window.windowTitle())
        self._title_text.setObjectName('WindowDraggerLabel')
        self._contents_layout = layouts.HorizontalLayout()
        self._corner_contents_layout = layouts.HorizontalLayout()

        main_layout.addWidget(self._logo_button)
        main_layout.addWidget(self._title_text)
        main_layout.addItem(
            QSpacerItem(25, 0, QSizePolicy.Fixed, QSizePolicy.Fixed))
        main_layout.addLayout(self._contents_layout)
        main_layout.addLayout(self._corner_contents_layout)

        buttons_widget = QWidget()
        self.buttons_layout = layouts.HorizontalLayout(spacing=0,
                                                       margins=(0, 0, 0, 0))
        self.buttons_layout.setAlignment(Qt.AlignRight)
        buttons_widget.setLayout(self.buttons_layout)
        main_layout.addWidget(buttons_widget)

        self._button_minimized = QPushButton()
        self._button_minimized.setIconSize(QSize(25, 25))
        # self._button_minimized.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self._button_minimized.setIcon(
            resources.icon('minimize', theme='window'))
        self._button_minimized.setStyleSheet(
            'QWidget {background-color: rgba(255, 255, 255, 0); border:0px;}')
        self._button_maximized = QPushButton()
        self._button_maximized.setIcon(
            resources.icon('maximize', theme='window'))
        # self._button_maximized.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self._button_maximized.setStyleSheet(
            'QWidget {background-color: rgba(255, 255, 255, 0); border:0px;}')
        self._button_maximized.setIconSize(QSize(25, 25))
        self._button_restored = QPushButton()
        # self._button_restored.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self._button_restored.setVisible(False)
        self._button_restored.setIcon(resources.icon('restore',
                                                     theme='window'))
        self._button_restored.setStyleSheet(
            'QWidget {background-color: rgba(255, 255, 255, 0); border:0px;}')
        self._button_restored.setIconSize(QSize(25, 25))
        self._button_closed = QPushButton()
        # button_closed.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
        self._button_closed.setIcon(resources.icon('close', theme='window'))
        self._button_closed.setStyleSheet(
            'QWidget {background-color: rgba(255, 255, 255, 0); border:0px;}')
        self._button_closed.setIconSize(QSize(25, 25))

        self.buttons_layout.addWidget(self._button_minimized)
        self.buttons_layout.addWidget(self._button_maximized)
        self.buttons_layout.addWidget(self._button_restored)
        self.buttons_layout.addWidget(self._button_closed)

        self._button_maximized.clicked.connect(self._on_maximize_window)
        self._button_minimized.clicked.connect(self._on_minimize_window)
        self._button_restored.clicked.connect(self._on_restore_window)
        self._button_closed.clicked.connect(self._on_close_window)
예제 #19
0
파일: dpi.py 프로젝트: tpDcc/tpDcc-libs-qt
 def setMinimumWidth(self, width):
     return super(DPIScaling,
                  self).setMinimumWidth(qtutils.dpi_scale(width))
예제 #20
0
    def addAction(self,
                  name,
                  mouse_menu=Qt.LeftButton,
                  connect=None,
                  checkable=False,
                  checked=True,
                  action=None,
                  action_icon=None,
                  data=None,
                  icon_text=None,
                  icon_color=None,
                  icon_size=16):
        """
        Overrides base addAction function
        Adds a new menu item through an action
        :param name: str, name of the menu item
        :param mouse_menu: button that will launch menu (Qt.LeftButton or Qt.MidButton or Qt.RightButton)
        :param connect: fn, function to launch when the item is pressed
        :param checkable: bool, Whether or not this menu is checkable
        :param checked: bool, Whether or not this menu is checked by default
        :param action:
        :param action_icon:
        :param data:
        :param icon_text:
        :param icon_color:
        :param icon_size:
        :return:
        """

        new_menu = self.menu(mouse_menu, searchable=False)
        if action is not None:
            new_menu.addAction(action)
            return

        new_action = menu.SearchableTaggedAction(label=name, parent=new_menu)
        new_action.setCheckable(checkable)
        new_action.setChecked(checked)
        new_action.tags = set(self._string_to_tags(name))
        new_action.setData(data)
        new_menu.addAction(new_action)

        if action_icon is not None:
            if isinstance(action_icon, QIcon):
                new_action.setIcon(action_icon)
                new_action.setIconText(icon_text or '')
            elif python.is_string(action_icon):
                new_action.setIconText(action_icon or icon_text or None)
                action_icon = resources.icon(action_icon)
                new_action.setIcon(
                    icon.colorize_layered_icon(
                        action_icon,
                        colors=[icon_color],
                        size=qtutils.dpi_scale(icon_size)))

        if connect is not None:
            if checkable:
                new_action.triggered.connect(partial(connect, new_action))
            else:
                new_action.triggered.connect(connect)

        return new_action
예제 #21
0
파일: dpi.py 프로젝트: tpDcc/tpDcc-libs-qt
 def setFixedSize(self, size):
     return super(DPIScaling, self).setFixedSize(qtutils.dpi_scale(size))