Beispiel #1
0
    def fill_process_combo_box(self, process_dict, current_process=None):
        if current_process:
            current_process = current_process.get('name')

        builtin_processes = ['publish', 'icon', 'attachment']

        if process_dict:
            process_list = process_dict.keys()
        else:
            process_list = builtin_processes

        if gf.get_value_from_config(cfg_controls.get_checkin(), 'showAllProcessCheckBox') == 1:
            show_builtins = True
        else:
            show_builtins = False

        if show_builtins:
            for builtin_process in builtin_processes:
                if builtin_process not in process_list:
                    process_list.append(builtin_process)

        self.processComboBox.clear()
        for i, process in enumerate(process_list):
            self.processComboBox.addItem(process)
            if current_process and current_process == process:
                self.processComboBox.setCurrentIndex(i)
 def customize_controls_tabs(self):
     if self.checkin_out_config_projects:
         project_tabs_list = self.checkin_out_config_projects.get(self.current_project)
         if gf.get_value_from_config(self.checkin_out_config, 'applyToAllProjectsRadioButton'):
             tabs_list = self.checkin_out_config_projects.get('!tabs_list!')
         elif project_tabs_list:
             tabs_list = project_tabs_list['tabs_list']
         else:
             tabs_list = None
         if tabs_list:
             for i, tab in enumerate(tabs_list):
                 if tab[0] == 'Checkin / Checkout':
                     if not tab[2]:
                         self.main_tabWidget.removeTab(self.get_tab_index(self.checkInOutTab))
                     else:
                         self.main_tabWidget.insertTab(i, self.checkInOutTab, tab[1])
                 if tab[0] == 'My Tactic':
                     if not tab[2]:
                         self.main_tabWidget.removeTab(self.get_tab_index(self.myTacticTab))
                     else:
                         self.main_tabWidget.insertTab(i, self.myTacticTab, tab[1])
                 if tab[0] == 'Assets Browser':
                     if not tab[2]:
                         self.main_tabWidget.removeTab(self.get_tab_index(self.assetsBrowserTab))
                     else:
                         self.main_tabWidget.insertTab(i, self.assetsBrowserTab, tab[1])
    def add_items_to_tabs(self):
        """
        Adding process tabs marked for Maya
        """
        self.sObjTabWidget.setHidden(True)

        ignore_tabs_list = self.get_ignore_stypes_list()

        for i, stype in enumerate(self.stypes_items.itervalues()):

            tab_widget = QtGui.QWidget(self)
            tab_widget_layout = QtGui.QVBoxLayout()
            tab_widget_layout.setContentsMargins(0, 0, 0, 0)
            tab_widget_layout.setSpacing(0)
            tab_widget.setLayout(tab_widget_layout)
            tab_widget.setObjectName(stype.get_pretty_name())

            self.all_search_tabs.append(
                checkin_out.Ui_checkInOutWidget(stype, tab_widget,
                                                self.project, self))

        # Add tabs
        added_labels = []
        for i, tab in enumerate(self.all_search_tabs):
            if tab.stype.get_code() not in ignore_tabs_list:
                added_labels.append(tab.get_tab_label())
                self.sObjTabWidget.addTab(tab.tab_widget, '')

        self.sObjTabWidget.setCurrentIndex(self.current_tab_idx)

        self.sObjTabWidget.setStyleSheet(
            '#sObjTabWidget > QTabBar::tab {background: transparent;border: 2px solid transparent;'
            'border-top-left-radius: 3px;border-top-right-radius: 3px;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;padding: 0px;}'
            '#sObjTabWidget > QTabBar::tab:selected, #sObjTabWidget > QTabBar::tab:hover {'
            'background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgba(255, 255, 255, 48), stop: 1 rgba(255, 255, 255, 32));}'
            '#sObjTabWidget > QTabBar::tab:selected {border-color: transparent;}'
            '#sObjTabWidget > QTabBar::tab:!selected {margin-top: 0px;}')

        for i, tab in enumerate(self.all_search_tabs):
            tab.tab_widget.layout().addWidget(tab)

        if gf.get_value_from_config(cfg_controls.get_checkin_out(),
                                    'lastViewOnAllTabscheckBox'):
            # Every tab will read the widget seetings when creating ui
            current_tab = self.get_current_tab_widget()
            if current_tab:
                current_settings = current_tab.get_settings_dict(force=True)
                for tab in self.all_search_tabs:
                    tab.set_settings_from_dict(current_settings,
                                               apply_checkin_options=False,
                                               apply_search_options=False)

        # Add labels
        for i, label in enumerate(added_labels):
            self.sObjTabWidget.tabBar().setTabButton(i, QtGui.QTabBar.LeftSide,
                                                     label)

        self.sObjTabWidget.setHidden(False)
    def get_ignore_stypes_list(self):
        ignore_tabs_list = []
        if self.checkin_out_config and self.checkin_out_config_projects and self.checkin_out_config_projects.get(
                self.project.get_code()):
            if not gf.get_value_from_config(self.checkin_out_config,
                                            'processTabsFilterGroupBox'):
                ignore_tabs_list = []
            else:
                ignore_tabs_list = self.checkin_out_config_projects[
                    self.project.get_code()]['stypes_list']
                if not ignore_tabs_list:
                    ignore_tabs_list = []

        return ignore_tabs_list
Beispiel #5
0
    def create_control_buttons(self):
        self.addNewButton = QtGui.QPushButton('Create')
        self.addNewButton.setMaximumWidth(80)
        self.saveButton = QtGui.QPushButton('Save')
        self.saveButton.setMaximumWidth(80)
        self.cancelButton = QtGui.QPushButton('Cancel')
        self.cancelButton.setMaximumWidth(80)
        self.buildDirectoryButton = QtGui.QPushButton('Build Full Directory Structure')
        self.buildDirectoryButton.setIcon(gf.get_icon('database'))
        self.build_directory_checkbox = QtGui.QCheckBox('Build Full Directory Structure')
        self.build_directory_checkbox.setChecked(False)
        self.build_directory_checkbox.setIcon(gf.get_icon('database'))

        self.repositoryComboBox = QtGui.QComboBox()
        base_dirs = env_tactic.get_all_base_dirs()
        # Default repo states
        current_repo = gf.get_value_from_config(cfg_controls.get_checkin(), 'repositoryComboBox')
        for key, val in base_dirs:
            if val['value'][4]:
                self.repositoryComboBox.addItem(val['value'][1])
                self.repositoryComboBox.setItemData(self.repositoryComboBox.count() - 1, val)

        # Special for build all repos dirs
        self.repositoryComboBox.addItem('All Repos')

        if current_repo:
            self.repositoryComboBox.setCurrentIndex(current_repo)

        if self.tactic_widget.view == 'insert':
            self.main_layout.addWidget(self.build_directory_checkbox, 1, 0, 1, 1)
            self.main_layout.addWidget(self.repositoryComboBox, 1, 1, 1, 1)
            spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            self.main_layout.addItem(spacerItem, 1, 2, 1, 1)
            self.main_layout.addWidget(self.addNewButton, 1, 3, 1, 1)
            self.main_layout.addWidget(self.cancelButton, 1, 4, 1, 1)
            self.main_layout.setColumnStretch(1, 0)
        else:
            self.main_layout.addWidget(self.buildDirectoryButton, 1, 0, 1, 1)
            self.main_layout.addWidget(self.repositoryComboBox, 1, 1, 1, 1)
            spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
            self.main_layout.addItem(spacerItem, 1, 2, 1, 1)
            self.main_layout.addWidget(self.saveButton, 1, 3, 1, 1)
            self.main_layout.addWidget(self.cancelButton, 1, 4, 1, 1)
            self.main_layout.setColumnStretch(1, 0)

        if self.item:
            if self.item.type != 'sobject':
                self.buildDirectoryButton.setHidden(True)
                self.repositoryComboBox.setHidden(True)
    def fill_repo_combo_box(self):

        self.repo_combo_box.clear()

        base_dirs = env_tactic.get_all_base_dirs()

        for key, val in base_dirs:
            if val['value'][4]:
                self.repo_combo_box.addItem(val['value'][1])
                self.repo_combo_box.setItemData(self.repo_combo_box.count() - 1, val)

        current_repo = gf.get_value_from_config(cfg_controls.get_checkin(), 'repositoryComboBox')

        if current_repo:
            self.repo_combo_box.setCurrentIndex(current_repo)
    def __init__(self, project_code, parent=None):
        super(self.__class__, self).__init__(parent=parent)

        env_inst.ui_main_tabs[project_code] = self

        self.checkin_out_config_projects = cfg_controls.get_checkin_out_projects()
        self.checkin_out_config = cfg_controls.get_checkin_out()
        self.isCreated = False

        self.project = env_inst.projects.get(project_code)
        self.current_project = self.project.info['code']
        self.current_namespace = self.project.info['type']

        if self.checkin_out_config_projects and self.checkin_out_config:
            if gf.get_value_from_config(self.checkin_out_config, 'controlsTabsFilterGroupBox'):
                self.customize_controls_tabs()

        self.create_ui()
    def fill_repo_combo_box(self, exlude_list=None):

        self.repo_combo_box.clear()

        if not exlude_list:
            exlude_list = []

        base_dirs = env_tactic.get_all_base_dirs()

        # Default repo states
        for key, val in base_dirs:
            if val['value'][4] and val['value'][3] not in exlude_list:
                self.repo_combo_box.addItem(val['value'][1])
                self.repo_combo_box.setItemData(self.repo_combo_box.count() - 1, val)

        self.repo_combo_box.addItem('All Repos')

        current_repo = gf.get_value_from_config(cfg_controls.get_checkin(), 'repositoryComboBox')

        if current_repo:
            self.repo_combo_box.setCurrentIndex(current_repo)
    def open_file_from_tree(self, index=None):

        if gf.get_value_from_config(cfg_controls.get_checkin(), 'checkoutMethodComboBox') == 0:
            checkout_method = 'local'
        else:
            checkout_method = 'http'

        item = self.filesTreeWidget.currentItem()
        file_object = item.data(0, QtCore.Qt.UserRole)

        if checkout_method == 'http':
            repo_sync_widget = env_inst.ui_repo_sync_queue.schedule_file_object(file_object)

            # preventing double opening of the file
            connected = False
            if not connected:
                repo_sync_widget.downloaded.connect(file_object.open_file)
                connected = True
            repo_sync_widget.download()

        elif checkout_method == 'local':
            file_object.open_file()
    def open_file_from_graphics_view(self):
        if self.file_list:

            if gf.get_value_from_config(cfg_controls.get_checkin(), 'checkoutMethodComboBox') == 0:
                checkout_method = 'local'
            else:
                checkout_method = 'http'

            file_object = self.file_list[self.current_pix]

            if checkout_method == 'http':
                repo_sync_widget = env_inst.ui_repo_sync_queue.schedule_file_object(file_object)

                # preventing double opening of the file
                connected = False
                if not connected:
                    repo_sync_widget.downloaded.connect(file_object.open_file)
                    connected = True
                repo_sync_widget.download()

            elif checkout_method == 'local':
                file_object.open_file()
    def fill_files_tree(self):
        self.filesTreeWidget.clear()

        show_more_info = self.showMoreInfoCheckBox.isChecked()
        show_all_files = self.showAllCheckBox.isChecked()
        if not show_more_info:
            self.filesTreeWidget.setHeaderHidden(True)
            self.filesTreeWidget.setColumnCount(1)
        else:
            self.filesTreeWidget.setHeaderHidden(False)
            self.filesTreeWidget.setColumnCount(5)

        icon_provider = QtGui.QFileIconProvider()
        known_icon_ext = {}
        if self.snapshots:

            # Making versionless on top of tree
            if self.item_widget.type == 'snapshot':
                if self.item_widget.is_versionless():
                    versionless_snapshot = self.item_widget.get_snapshot()
                    if versionless_snapshot and versionless_snapshot not in self.snapshots:
                        self.snapshots.insert(0, versionless_snapshot)

            for snapshot in self.snapshots:
                snapshot_info = snapshot.get_snapshot()
                snapshot_files_objects = snapshot.get_files_objects(group_by='type')

                if show_all_files:
                    sn_item = QtGui.QTreeWidgetItem()
                    sn_item.setText(0, 'Snapshot ({0}), Version: {1}'.format(snapshot_info.get('id'), snapshot_info.get('version')))
                    self.filesTreeWidget.addTopLevelItem(sn_item)
                    sn_item.setExpanded(True)

                # Download from http
                for file_type, files_objects in snapshot_files_objects.items():
                    for file_object in files_objects:

                        if gf.get_value_from_config(cfg_controls.get_checkin(), 'getPreviewsThroughHttpCheckbox') == 1:
                            if file_type in ['icon', 'playblast', 'web', 'image']:
                                if file_object.is_exists():
                                    if file_object.get_file_size() != file_object.get_file_size(True):
                                        self.download_web_preview(file_object)
                                else:
                                    self.download_web_preview(file_object)

                preview = []
                if not show_all_files:
                    preview = ['icon', 'playblast', 'web']

                # Adding files to tree
                for i, (file_type, files_objects) in enumerate(snapshot_files_objects.items()):
                    type_item = QtGui.QTreeWidgetItem()
                    if file_type not in preview:
                        if show_all_files:
                            type_item.setText(0, file_type)
                            sn_item.addChild(type_item)
                            type_item.setExpanded(True)

                        for file_object in files_objects:

                            # removing unnecessary calls to icon provider
                            file_ext = file_object.get_ext()
                            if known_icon_ext.get(file_ext):
                                file_icon = known_icon_ext[file_ext]
                            else:
                                file_icon = icon_provider.icon(file_object.get_full_abs_path())
                                known_icon_ext[file_ext] = file_icon

                            # multiple files in snapshot
                            if file_object.is_meta_file_obj():
                                self.add_item_with_meta_file_object(file_object, show_more_info, show_all_files, snapshot_info, type_item, file_icon)
                            else:
                                self.add_item_with_tactic_file_object(file_object, show_more_info, show_all_files, snapshot_info, type_item, file_icon)

            self.filesTreeWidget.resizeColumnToContents(0)
            if show_more_info:
                self.filesTreeWidget.resizeColumnToContents(1)
                self.filesTreeWidget.resizeColumnToContents(2)
                self.filesTreeWidget.resizeColumnToContents(4)
                self.filesTreeWidget.resizeColumnToContents(5)