コード例 #1
0
    def _create_sequence_widget(self):
        """
        Internal function that creates a sequence widget to replace the static thumbnail widget
        """

        self._sequence_widget = sequence.ImageSequenceWidget(self)
        self._sequence_widget.setObjectName('thumbnailButton')
        self._thumbnail_frame.layout().insertWidget(0, self._sequence_widget)
        self._sequence_widget.clicked.connect(self._on_thumbnail_capture)
        self._sequence_widget.setToolTip(
            'Click to capture a thumbnail from the current model panel.\n'
            'CTRL + Click to show the capture window for better framing.')

        camera_icon = resources.get('icons',
                                    self.theme().style(), 'camera.png')
        expand_icon = resources.get('icons',
                                    self.theme().style(), 'full_screen.png')
        folder_icon = resources.get('icons',
                                    self.theme().style(), 'folder.png')

        self._sequence_widget.addAction(camera_icon, 'Capture new image',
                                        'Capture new image',
                                        self._on_thumbnail_capture)
        self._sequence_widget.addAction(expand_icon, 'Show Capture window',
                                        'Show Capture window',
                                        self._on_show_capture_window)
        self._sequence_widget.addAction(folder_icon, 'Load image from disk',
                                        'Load image from disk',
                                        self._on_show_browse_image_dialog)

        self._sequence_widget.setIcon(resources.icon('tpdcc'))
コード例 #2
0
    def create_sequence_widget(self):
        """
        Creates a sequence widget to replace the static thumbnail widget
        """

        sequence_widget = widgets.LibraryImageSequenceWidget(self)
        sequence_widget.setObjectName('thumbnailButton')
        sequence_widget.setStyleSheet(self._thumbnail_btn.styleSheet())
        sequence_widget.setToolTip(self._thumbnail_btn.toolTip())

        camera_icon = resources.get('icons', 'camera.svg')
        expand_icon = resources.get('icons', 'expand.svg')
        folder_icon = resources.get('icons', 'folder.svg')

        sequence_widget.addAction(camera_icon, 'Capture new image',
                                  'Capture new image',
                                  self._on_thumbnail_capture)
        sequence_widget.addAction(expand_icon, 'Show Capture window',
                                  'Show Capture window',
                                  self._on_show_capture_window)
        sequence_widget.addAction(folder_icon, 'Load image from disk',
                                  'Load image from disk',
                                  self._on_show_browse_image_dialog)

        sequence_widget.setIcon(resources.icon('thumbnail2'))
        self._thumbnail_frame.layout().insertWidget(0, sequence_widget)
        self._thumbnail_btn.hide()
        self._thumbnail_btn = sequence_widget
        self._thumbnail_btn.clicked.connect(self._on_thumbnail_capture)
コード例 #3
0
    def _create_pixmap(self, path, color):
        """
        Internal function that creates a new item pixmap from the given path
        :param path: str
        :param color: str or QColor
        :return: QPixmap
        """

        if not path:
            return QPixmap()

        dpi = self.treeWidget().dpi()
        key = path + color + 'DPI-' + str(dpi)
        item_pixmap = self._PIXMAP_CACHE.get(key)
        if not item_pixmap:
            width = 20 * dpi
            height = 18 * dpi
            if '/' not in path and '\\' not in path:
                path = resources.get('icons', path)
            if not path or not os.path.exists(path):
                path = self.default_icon_path()
            pixmap2 = pixmap.Pixmap(path)
            pixmap2.set_color(color)
            pixmap2 = pixmap2.scaled(16 * dpi, 16 * dpi, Qt.KeepAspectRatio, Qt.SmoothTransformation)
            x = (width - pixmap2.width()) / 2
            y = (height - pixmap2.height()) / 2
            item_pixmap = QPixmap(QSize(width, height))
            item_pixmap.fill(Qt.transparent)
            painter = QPainter(item_pixmap)
            painter.drawPixmap(x, y, pixmap2)
            painter.end()
            self._PIXMAP_CACHE[key] = item_pixmap

        return item_pixmap
コード例 #4
0
    def collapsed_icon_path(self):
        """
        Returns the icon path to be shown when collapsed
        :return: str
        """

        return self._collapsed_icon_path or resources.get('icons', 'black', 'folder.png') or self.default_icon_path()
コード例 #5
0
    def expanded_icon_path(self):
        """
        Returns the icon path to be shown when expanded
        :return: str
        """

        return self._expanded_icon_path or resources.get('icons', 'black', 'open_folder.png')
コード例 #6
0
    def default_icon_path(self):
        """
        Returns the default icon path
        :return: str
        """

        return resources.get('icons', 'folder.svg')
コード例 #7
0
    def format(cls, data=None, options=None, dpi=1, **kwargs):
        """
        Returns style with proper format
        :param data: str
        :param options: dict
        :param dpi: float
        :return: str
        """

        if options:
            keys = options.keys()
            if python.is_python2():
                keys.sort(key=len, reverse=True)
            else:
                keys = sorted(keys, key=len, reverse=True)
            for key in keys:
                key_value = options[key]
                str_key_value = str(key_value)
                option_value = str(key_value)
                if str_key_value.startswith('@^'):
                    option_value = str(utils.dpi_scale(int(str_key_value[2:])))
                elif str_key_value.startswith('^'):
                    option_value = str(utils.dpi_scale(int(str_key_value[1:])))
                elif 'icon' in key:
                    theme_name = kwargs.get('theme_name', 'default') or 'default'
                    resource_path = resources.get('icons', theme_name, str(key_value))
                    if resource_path and os.path.isfile(resource_path):
                        option_value = resource_path
                elif color.string_is_hex(str_key_value):
                    try:
                        color_list = color.hex_to_rgba(str_key_value)
                        option_value = 'rgba({}, {}, {}, {})'.format(
                            color_list[0], color_list[1], color_list[2], color_list[3])
                    except ValueError:
                        # This exception will be raised if we try to convert an attribute that is not a color.
                        option_value = key_value

                data = data.replace('@{}'.format(key), option_value)

        re_dpi = re.compile('[0-9]+[*]DPI')
        new_data = list()

        for line in data.split('\n'):
            dpi_ = re_dpi.search(line)
            if dpi_:
                new = dpi_.group().replace('DPI', str(dpi))
                val = int(eval(new))
                line = line.replace(dpi_.group(), str(val))
            new_data.append(line)

        data = '\n'.join(new_data)

        return data
コード例 #8
0
ファイル: project.py プロジェクト: tpDcc/tpDcc-core
    def _set_default_settings(self):

        from tpDcc.libs.qt.core import image

        project_file_path = self.get_project_file()
        project_path = path.get_dirname(project_file_path)
        self._settings = settings.JSONSettings()
        self._set_settings_path(project_path)
        self._settings.set('version', '0.0.0')
        self._settings.set('name', self.name)
        self._settings.set('path', self._project_path)
        self._settings.set('full_path', self.full_path)
        self._settings.set(
            'image',
            str(
                image.image_to_base64(
                    resources.get('icons', 'default', 'tpdcc.png'))))
コード例 #9
0
ファイル: theme.py プロジェクト: tpDcc/tpDcc-libs-resources
    def stylesheet_file(self):
        """
        Returns path where theme stylesheet is located
        :return: str
        """

        style_name = self._style or 'default'
        dcc_name = dcc.get_name()
        dcc_version = dcc.get_version()
        dcc_style = '{}_{}{}'.format(style_name, dcc_name, dcc_version)
        all_styles = [dcc_style, style_name]

        style_extension = style.StyleSheet.EXTENSION
        if not style_extension.startswith('.'):
            style_extension = '.{}'.format(style_extension)

        for style_name in all_styles:
            style_file_name = '{}{}'.format(style_name, style_extension)
            style_path = resources.get('styles', style_file_name)
            if style_path and os.path.isfile(style_path):
                return style_path

        return style_path
コード例 #10
0
ファイル: item.py プロジェクト: tpDcc/tpDcc-tools-datalibrary
    def __init__(self, data_item, *args, **kwargs):
        super(ItemView, self).__init__(*args, **kwargs)

        self._size = None
        self._rect = None
        self._text_column_order = list()

        self._item = data_item

        self._icon = dict()
        self._thumbnail_icon = None
        self._fonts = dict()
        self._thread = None
        self._pixmap = dict()
        self._pixmap_rect = None
        self._pixmap_scaled = None
        self._type_pixmap = None

        self._mime_text = None
        self._drag_enabled = True
        self._under_mouse = False
        self._search_text = None
        self._info_widget = None
        self._viewer = None
        self._stretch_to_widget = None

        self._group_item = None
        self._group_column = 0

        self._image_sequence = None
        self._image_sequence_path = ''

        self._blend_down = False
        self._blend_value = 0.0
        self._blend_prev_value = 0.0
        self._blend_position = None
        self._blending_enabled = False

        self._worker = image.ImageWorker()
        self._worker.setAutoDelete(False)
        self._worker.signals.triggered.connect(self._on_thumbnail_from_image)
        self._worker_started = False

        self._icon_path = None

        icons_path = path_utils.join_path('icons', self.theme().name().lower())
        color_icons_path = path_utils.join_path('icons', 'color')

        icon_name = data_item.icon() if data_item else None
        if not icon_name:
            icon_name = self.DEFAULT_THUMBNAIL_NAME
        else:
            icon_name, icon_extension = os.path.splitext(icon_name)
            if not icon_extension:
                icon_name = '{}.png'.format(icon_name)

        dcc_name = dcc.client().get_name()
        type_icon = icon_name if icon_name == dcc_name + '.png' else None
        self._type_icon_path = resources.get(color_icons_path,
                                             type_icon) if type_icon else ''

        self._default_thumbnail_path = resources.get(
            icons_path, icon_name) or resources.get(
                icons_path, self.DEFAULT_THUMBNAIL_NAME)