Beispiel #1
0
 def set_area_widgets(self, widgets):
     qtutils.clear_layout(self._grid)
     self._widgets = widgets
     for drop_area, widget in self._widgets.items():
         opts = self.grid_pos_for_area(drop_area=drop_area)
         self._grid.addWidget(widget, opts[0].x(), opts[0].y(), opts[1])
     self.reset()
Beispiel #2
0
    def update_asset_categories(self, asset_categories):
        """
        Updates current categories with the given ones
        :param asset_categories: list(str)
        """

        for btn in self._categories_btn_grp.buttons():
            self._categories_btn_grp.removeButton(btn)

        qtutils.clear_layout(self._categories_menu_layout)

        all_asset_categories = [defines.ArtellaFileStatus.ALL]
        all_asset_categories.extend(asset_categories)
        for category in all_asset_categories:
            new_btn = QPushButton(category)
            new_btn.setMinimumWidth(
                QFontMetrics(new_btn.font()).width(category) + 10)
            new_btn.setIcon(tpDcc.ResourcesMgr().icon(category.lower()))
            new_btn.setCheckable(True)
            self._categories_menu_layout.addWidget(new_btn)
            self._categories_btn_grp.addButton(new_btn)
            if category == defines.ArtellaFileStatus.ALL:
                new_btn.setIcon(tpDcc.ResourcesMgr().icon('home'))
                new_btn.setChecked(True)
            new_btn.toggled.connect(partial(self._change_category, category))
Beispiel #3
0
    def _update_ui(self, allow_sync=True):
        light_rigs_path = self.get_light_rigs_path()
        if not light_rigs_path:
            return
        if not os.path.exists(light_rigs_path) and allow_sync:
            result = qtutils.show_question(
                None, 'Light Rigs Folder is not available!',
                'Do you want to synchronize Light Rigs Folder from Artella to your computer? \n\n{}'
                .format(light_rigs_path))
            if result == QMessageBox.Yes:
                self.synchronize_light_rigs()
                if not os.path.exists(light_rigs_path):
                    msg = 'Was not possible to synchronize Light Rigs folder from Artella: "{}"'.format(
                        light_rigs_path)
                    self.show_warning_message(msg)
                    LOGGER.warning(msg)
                    return
            else:
                self._stack.slide_in_index(0)
                return
        if not light_rigs_path or not os.path.isdir(light_rigs_path):
            return

        qtutils.clear_layout(self._light_rigs_layout)
        light_rig_file_type = self.config.get('lightrig_file_type',
                                              default='lightrig')
        for f in os.listdir(light_rigs_path):
            light_rig = self.LIGHT_RIG_CLASS(project=self._project,
                                             name=f,
                                             path=light_rigs_path,
                                             file_type=light_rig_file_type,
                                             config=self._config)
            self._light_rigs_layout.addWidget(light_rig)
        self._stack.slide_in_index(1)
    def update_supported_types(self):
        """
        Updates current supported types
        """

        for btn in self._supported_types_btn_grp.buttons():
            self._supported_types_btn_grp.removeButton(btn)

        qtutils.clear_layout(self._supported_types_layout)

        if not self._supported_files:
            LOGGER.warning('No Supported Files for AssetsLibrary!')
            return

        total_buttons = 0
        for supported_file in self._supported_files:
            for type_name, file_info in supported_file.items():
                new_btn = QPushButton(type_name.title())
                new_btn.setIcon(tp.ResourcesMgr().icon(
                    type_name.lower().replace(' ', '')))
                new_btn.setCheckable(True)
                new_btn.file_info = file_info
                self._supported_types_layout.addWidget(new_btn)
                self._supported_types_btn_grp.addButton(new_btn)
                if total_buttons == 0:
                    new_btn.setChecked(True)
                total_buttons += 1
Beispiel #5
0
    def update_sequences_categories(self):
        """
        Updates current sequences categories
        """

        from artellapipe.widgets import sequence as sequence_widgets

        for btn in self._sequences_btn_grp.buttons():
            self._sequences_btn_grp.removeButton(btn)

        qtutils.clear_layout(self._sequences_menu_layout)

        all_sequences_categories = ['All']
        all_sequences = artellapipe.SequencesMgr().find_all_sequences()
        if all_sequences:
            sequence_names = [
                sequence.get_name() for sequence in all_sequences
            ]
            all_sequences_categories.extend(sequence_names)

        for sequence_name in all_sequences_categories:
            sequence = artellapipe.SequencesMgr().find_sequence(sequence_name)
            new_btn = sequence_widgets.SequenceCategoryButton(
                sequence_name, sequence)
            new_btn.setMinimumWidth(
                QFontMetrics(new_btn.font()).width(sequence_name) + 10)
            new_btn.setCheckable(True)
            self._sequences_menu_layout.addWidget(new_btn)
            self._sequences_btn_grp.addButton(new_btn)
            if sequence_name == 'All':
                new_btn.setIcon(tpDcc.ResourcesMgr().icon('home'))
                new_btn.setChecked(True)
            new_btn.toggled.connect(
                partial(self._on_change_sequence, sequence_name))
    def update_categories(self):
        """
        Updates current tag categories with the given ones
        """

        for btn in self._tags_btn_grp.buttons():
            self._tags_btn_grp.removeButton(btn)

        qtutils.clear_layout(self._tags_menu_layout)

        if not self._outliners:
            return

        total_buttons = 0

        categories_list = self._outliners.keys()
        for category in categories_list:
            new_btn = QPushButton(category.title())
            new_btn.category = category
            category_icon = tpDcc.ResourcesMgr().icon(category.strip().lower())
            new_btn.setIcon(category_icon)
            new_btn.setCheckable(True)
            new_btn.clicked.connect(partial(self._on_change_outliner, new_btn))
            self._tags_menu_layout.addWidget(new_btn)
            self._tags_btn_grp.addButton(new_btn)
            if total_buttons == 0:
                new_btn.blockSignals(True)
                new_btn.setChecked(True)
                new_btn.blockSignals(False)
            total_buttons += 1
Beispiel #7
0
    def clear_layout(self, reset_title=True):
        """
        Clears main layout and resetes editor title
        """

        qtutils.clear_layout(self._main_group_layout)
        if reset_title:
            self._main_group.setTitle('')
Beispiel #8
0
    def clear(self):
        """
        Clears all toolbar widgets
        """

        self._overflow_menu_button.clear_menu(Qt.LeftButton)
        self._flow_layout.removeWidget(self._overflow_menu_button)
        self._flow_layout.clear()
        qtutils.clear_layout(self._overflow_layout)
Beispiel #9
0
    def update_projects(self):

        qtutils.clear_layout(self.main_layout)

        if not self._projects_path or not os.path.isdir(self._projects_path):
            return

        projects_found = get_projects(self._projects_path, project_class=self._project_class)
        for project_found in projects_found:
            self.add_project_widget(project_found)
Beispiel #10
0
    def _set_asset_shaders_info(self, shaders_info):
        """
        Sets the asset shaders info widget currently being showed
        :param shaders_info: AssetsShadersWidget
        """

        if self._assets_shaders_widget == shaders_info:
            return

        qtutils.clear_layout(self._asset_shaders_layout)

        if shaders_info:
            self._assets_shaders_widget = shaders_info
            self._asset_shaders_layout.addWidget(shaders_info)
            self._stack.slide_in_index(1)
    def _set_sequence_info(self, sequence_info):
        """
        Sets the sequence info widget currently being showed
        :param sequence_info: SequenceInfoWidget
        """

        if self._shots_info_widget == sequence_info:
            return

        qtutils.clear_layout(self._shots_info_layout)

        if sequence_info:
            self._shots_info_widget = sequence_info
            self._shots_info_layout.addWidget(sequence_info)
            self._shots_stack.slide_in_index(1)
    def _set_asset_info(self, asset_info):
        """
        Sets the asset info widget currently being showed
        :param asset_info: AssetInfoWidget
        """

        if self._user_info_widget == asset_info:
            return

        qtutils.clear_layout(self._user_info_layout)

        if asset_info:
            self._user_info_widget = asset_info
            self._user_info_layout.addWidget(asset_info)
            self._attrs_stack.slide_in_index(2)
Beispiel #13
0
    def update_projects(self, project_path=None):

        qtutils.clear_layout(self.main_layout)

        # self.clear()

        if not project_path:
            if self._settings is None:
                LOGGER.debug('No Projects Path defined yet ...')
                return
            if self._settings.has_setting('project_directory'):
                project_path = self._settings.get('project_directory')

        projects_found = get_projects(project_path,
                                      project_class=self._project_class)
        for project_found in projects_found:
            self.add_project(project_found)
Beispiel #14
0
 def clear_templates(self):
     qtutils.clear_layout(self.main_layout)
Beispiel #15
0
    def _on_update_active_rule(self, active_rule):
        if not active_rule:
            return

        qtutils.clear_layout(self.main_auto_layout)

        if not active_rule:
            return

        tokens = self._model.tokens

        active_tokens = list()
        for field in active_rule.fields():
            for token in tokens:
                if token.name == field:
                    active_tokens.append(token)

        self._token_widgets.clear()

        for token in reversed(active_tokens):
            token_name = token.name
            token_value = token.get_items()
            token_default = token.default

            if token_name == 'id':
                continue

            if token_value:
                w = combobox.BaseComboBox(parent=self)
                w_l = label.BaseLabel(parent=self)
                w.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
                w_l.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
                self._add_token(
                    token_name,
                    qtutils.get_line_layout('', self, w, QLabel(u'\u25ba'),
                                            w_l))
                for key, value in token_value.items():
                    if key == 'default':
                        continue
                    w.addItem(key)
                try:
                    if token_default > 0:
                        w.setCurrentIndex(token_default - 1)
                except Exception:
                    w.setCurrentIndex(0)
                current_text = w.currentText()
                try:
                    current_value = token.solve(self._naming_lib.active_rule(),
                                                current_text)
                    w_l.setText(str(current_value))
                except Exception:
                    pass
                w.currentTextChanged.connect(
                    partial(self._on_combo_changed, token))
                self._token_widgets[token_name] = {
                    'widget': [w, w_l],
                    'fn': w.currentText
                }
            else:
                w = lineedit.BaseLineEdit(parent=self)
                # w.textChanged.connect(self._on_text_changed)
                w.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
                self._token_widgets[token_name] = {'widget': [w], 'fn': w.text}
                self._add_token(token_name,
                                qtutils.get_line_layout('', self, w))
Beispiel #16
0
    def _fill_bug_data(self):
        qtutils.clear_layout(self._bug_data_layout)

        def _add_info(title, data, row, column):
            title_lbl = QLabel('{}: '.format(title))
            title_lbl.setStyleSheet('font-weight: bold')
            title_lbl.setAlignment(Qt.AlignRight)
            data_text = str(bug_data.get(data, '-not found-'))
            data_lbl = QLabel(data_text)
            data_lbl.setToolTip(data_text)
            data_lbl.setStatusTip(data_text)
            data_lbl.setStyleSheet('background-color: rgba(45, 85, 45, 50);')
            self._bug_data_layout.setColumnStretch(column + 1, 1)
            self._bug_data_layout.addWidget(title_lbl, row, column)
            self._bug_data_layout.addWidget(data_lbl, row, column + 1)

        def _add_drives_info(row, column):
            drives = bug_data.get('drives')
            if not drives:
                return
            i = 0
            for drive_letter, drive_info in drives.items():
                title_lbl = QLabel(
                    'Hard Drive Usage ({})'.format(drive_letter))
                title_lbl.setStyleSheet('font-weight: bold')
                title_lbl.setAlignment(Qt.AlignRight)
                data_text = '{} of {} ({}%)'.format(
                    drive_info['used'], drive_info['total'],
                    drive_info['usage_percentage'])
                data_lbl = QLabel(data_text)
                data_lbl.setToolTip(data_text)
                data_lbl.setStatusTip(data_text)
                data_lbl.setStyleSheet(
                    'background-color: rgba(45, 85, 45, 50);')
                self._bug_data_layout.setColumnStretch(column + i + 1, 1)
                self._bug_data_layout.addWidget(title_lbl, row + i, column)
                self._bug_data_layout.addWidget(data_lbl, row + i, column + 1)
                i += 1

        def _add_gpu_info(row, column):
            def _add_info(gpu_id, title, data, index, row, column):
                title_lbl = QLabel('{}: '.format(title))
                title_lbl.setStyleSheet('font-weight: bold')
                title_lbl.setAlignment(Qt.AlignRight)
                data_text = str(gpus[gpu_id].get(data, '-not found-'))
                data_lbl = QLabel(data_text)
                data_lbl.setToolTip(data_text)
                data_lbl.setStatusTip(data_text)
                data_lbl.setStyleSheet(
                    'background-color: rgba(45, 85, 45, 50);')
                self._bug_data_layout.setColumnStretch(column + index + 1, 1)
                self._bug_data_layout.addWidget(title_lbl, row + index, column)
                self._bug_data_layout.addWidget(data_lbl, row + index,
                                                column + 1)

            gpus = bug_data.get('gpus')
            if not gpus:
                return
            row_index = 0
            for i, gpu_id in enumerate(gpus.keys()):
                _add_info(gpu_id, 'GPU Name ({})'.format(i), 'name', row_index,
                          row, column)
                row_index += 1
                _add_info(gpu_id, 'GPU Driver ({})'.format(i), 'driver',
                          row_index, row, column)
                row_index += 1
                title_lbl = QLabel('GPU Usage ({})'.format(i))
                title_lbl.setStyleSheet('font-weight: bold')
                title_lbl.setAlignment(Qt.AlignRight)
                data_text = '{} of {} ({}%)'.format(
                    str(round((gpus[gpu_id]['memoryUsed'] / 1000), 2)) + 'GB',
                    str(round((gpus[gpu_id]['memoryTotal'] / 1000), 2)) + 'GB',
                    str(round(float(gpus[gpu_id]['memoryUtil']) * 100, 2)))
                data_lbl = QLabel(data_text)
                data_lbl.setToolTip(data_text)
                data_lbl.setStatusTip(data_text)
                data_lbl.setStyleSheet(
                    'background-color: rgba(45, 85, 45, 50);')
                self._bug_data_layout.setColumnStretch(column + row_index + 1,
                                                       1)
                self._bug_data_layout.addWidget(title_lbl, row + row_index,
                                                column)
                self._bug_data_layout.addWidget(data_lbl, row + row_index,
                                                column + 1)

        bug_data = self._get_bug_data()

        _add_info('User', 'user', 0, 0)
        _add_info('Time', 'time', 1, 0)
        _add_info('Computer Type', 'machineType', 2, 0)
        _add_info('Platform OS', 'OSVersion', 3, 0)
        _add_info('Platform Version', 'OSRelease', 4, 0)
        _add_info('Python Version', 'friendlyPythonVersion', 5, 0)
        _add_drives_info(6, 0)

        _add_info('DCC Name', 'dcc_name', 0, 2)
        _add_info('DCC Version', 'dcc_version', 1, 2)
        _add_info('CPU Cores', 'Count', 2, 2)
        _add_info('CPU Bits', 'Bits', 3, 2)
        _add_info('CPU Vendor', 'Brand', 4, 2)
        _add_gpu_info(5, 2)

        self._bug_data = bug_data