Ejemplo n.º 1
0
    def __init__(self, app):
        QtGui.QWidget.__init__(self)
        # set up the UI
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self._app = app

        self._settings = QtCore.QSettings("Shotgun Software",
                                          "tk-multi-setcontext")

        # set up the browsers
        self.ui.left_browser.set_app(self._app)
        self.ui.right_browser.set_app(self._app)

        self.ui.left_browser.selection_changed.connect(self.setup_task_list)
        self.ui.right_browser.action_requested.connect(self.set_context)
        self.ui.change_context.clicked.connect(self.set_context)

        self.toggle_load_button_enabled()
        self.ui.left_browser.selection_changed.connect(
            self.toggle_load_button_enabled)
        self.ui.right_browser.selection_changed.connect(
            self.toggle_load_button_enabled)

        # create
        types_to_load = self._app.get_setting("sg_entity_types", [])

        # now resolve the entity types into display names
        types_nice_names = [
            tank.util.get_entity_type_display_name(self._app.tank, x)
            for x in types_to_load
        ]

        plural_types = ["%ss" % x for x in types_nice_names
                        ]  # no fanciness (sheep, box, nucleus etc)
        if len(plural_types) == 1:
            # "Shots"
            types_str = plural_types[0]
        else:
            # "Shots, Assets & Sequences"
            types_str = ", ".join(plural_types[:-1])
            types_str += " & %s" % plural_types[-1]

        self.ui.left_browser.set_label(types_str)
        self.ui.right_browser.set_label("Tasks")

        # refresh when the checkbox is clicked
        self.ui.hide_tasks.toggled.connect(self.setup_entity_list)
        self.ui.hide_tasks.toggled.connect(self.remember_checkbox)

        # should we show create tasks?
        create_tasks = self._app.get_setting("enable_create_tasks", False)

        if create_tasks:
            self.ui.new_task.clicked.connect(self.create_new_task)
        else:
            self.ui.new_task.setVisible(False)

        # load data from shotgun
        self.setup_entity_list()
        self.ui.right_browser.set_message(
            "Please select an item in the listing to the left.")

        # remember state of checkbox
        # this qsettings stuff seems super flaky on different platforms
        try:
            # this qsettings stuff seems super flaky on different platforms
            # - although setting is saved as an int, it can get loaded as either an
            # int or a string, hence the double casting to int and then bool.
            prev_hide_tasks = bool(
                int(self._settings.value("hide_tasks", True)))
            self.ui.hide_tasks.setChecked(prev_hide_tasks)
        except Exception, e:
            self._app.log_warning(
                "Cannot restore state of hide tasks checkbox: %s" % e)
Ejemplo n.º 2
0
    def __init__(self, app):
        QtGui.QWidget.__init__(self)
        
        # set up the UI
        self.ui = Ui_Dialog() 
        self.ui.setupUi(self)

        self._app = app
        
        self._settings = QtCore.QSettings("Shotgun Software", "tk-multi-loader")
        
        # set up the browsers
        self.ui.left_browser.set_app(self._app)
        self.ui.middle_browser.set_app(self._app)
        self.ui.right_browser.set_app(self._app)

        # set the browser labels        
        entity_cfg = self._app.get_setting("sg_entity_types", {})
        # example: {"Shot": [["desc", "startswith", "foo"]] }        
        types_to_load = entity_cfg.keys()
        
        # now resolve the entity types into display names
        types_nice_names = [ tank.util.get_entity_type_display_name(self._app.tank, x) for x in types_to_load ]
        
        # generate menu heading
        plural_types = [ "%ss" % x for x in types_nice_names] # no fanciness (sheep, box, nucleus etc)
        if len(plural_types) == 1:
            # "Shots"
            types_str = plural_types[0]
        else:
            # "Shots, Assets & Sequences"
            types_str = ", ".join(plural_types[:-1])
            types_str += " & %s" % plural_types[-1]
            
        self.ui.left_browser.set_label(types_str)

        self.ui.middle_browser.set_label("Publishes")
        
        if self._app.get_setting("dependency_mode"):
            self.ui.right_browser.set_label("Contents")
        else:
            self.ui.right_browser.set_label("Versions")
        
        # set the caption on the load button
        self.ui.load_selected.setText( self._app.get_setting("button_name") )
        
        self.toggle_load_button_enabled()
        self.ui.load_selected.clicked.connect( self.load_item )
        self.ui.close.clicked.connect( self.close )
        
        self.ui.left_browser.selection_changed.connect( self.setup_publish_list )
        self.ui.middle_browser.selection_changed.connect( self.setup_version_list )
        self.ui.right_browser.action_requested.connect( self.load_item )
        
        self.ui.left_browser.selection_changed.connect( self.toggle_load_button_enabled )
        self.ui.middle_browser.selection_changed.connect( self.toggle_load_button_enabled )
        self.ui.right_browser.selection_changed.connect( self.toggle_load_button_enabled )
                
        # load data from shotgun
        # this qsettings stuff seems super flaky on different platforms
        prev_selection = {}
        show_only_current = False
        try:            
            type_key = "%s/curr_entity_type" % self._app.get_setting("menu_name")
            id_key = "%s/curr_entity_id" % self._app.get_setting("menu_name")
            current_key = "%s/only_show_current" % self._app.get_setting("menu_name")
            
            if self._settings.value(id_key) and self._settings.value(type_key):
                # we have a stored setting 
                entity_id = int(self._settings.value(id_key))
                entity_type = str(self._settings.value(type_key))
                prev_selection = {"type": entity_type, "id": entity_id}
                        
            if self._settings.value(current_key): 
                # belt and braces for pyqt/pyside nuts casting
                show_only_current = bool(int(self._settings.value(current_key)))
            
        except Exception, e:
            self._app.log_warning("Cannot restore previous settings: %s" % e)
Ejemplo n.º 3
0
    def __init__(self, app, handler, mode=SELECT_WORK_AREA, parent=None):
        """
        Construction
        """
        QtGui.QWidget.__init__(self, parent)
        
        self._app = app
        self._handler = handler
        self._mode = mode
        self._do_new_scene = False
        
        # get the current work area's entity and task
        ctx = self._handler.get_current_work_area()
        self._current_context_task = ctx.task if ctx else None
        self._current_context_entity = ctx.entity if ctx else None        
        
        self._exit_code = QtGui.QDialog.Rejected
        self._settings = QtCore.QSettings("Shotgun Software", "tk-multi-workfiles")

        # set up the UI
        from .ui.select_work_area_form import Ui_SelectWorkAreaForm
        self._ui = Ui_SelectWorkAreaForm() 
        self._ui.setupUi(self)
        
        # set up the entity browser:
        self._ui.entity_browser.set_app(self._app)
        self._ui.entity_browser.selection_changed.connect(self._on_entity_selected)
        
        types_to_load = self._app.get_setting("sg_entity_types", [])
        types_str = "Entities"
        if types_to_load:
            types_nice_names = [ tank.util.get_entity_type_display_name(self._app.tank, x) for x in types_to_load ]
            
            plural_types = [ "%ss" % x for x in types_nice_names] # no fanciness (sheep, box, nucleus etc)
            if len(plural_types) == 1:
                # "Shots"
                types_str = plural_types[0]
            else:
                # "Shots, Assets & Sequences"
                types_str = ", ".join(plural_types[:-1])
                types_str += " & %s" % plural_types[-1]
        self._ui.entity_browser.set_label(types_str)
        
        # set up the task browser:
        self._ui.task_browser.set_app(self._app)
        self._ui.task_browser.selection_changed.connect(self._on_task_selected)
        self._ui.task_browser.action_requested.connect(self._on_context_selected)
        self._ui.task_browser.set_label("Tasks")
        
        # mode specific:
        self._ui.select_new_btn.setVisible(self._mode == SelectWorkAreaForm.CHANGE_WORK_AREA)
        self._ui.select_btn.setText("Change Work Area" if self._mode != SelectWorkAreaForm.SELECT_WORK_AREA else "Select")
        
        # connect the buttons:
        self._ui.cancel_btn.clicked.connect(self._on_cancel)
        self._ui.select_btn.clicked.connect(self._on_context_selected)
        self._ui.select_new_btn.clicked.connect(self._on_select_and_new)
       
       # enable/disable task creation 
        self._can_create_tasks = self._app.get_setting("allow_task_creation")
        if self._can_create_tasks:
            self._ui.new_task_btn.clicked.connect( self._on_create_new_task )
        else:
            self._ui.new_task_btn.setVisible(False)
        
        # set up the 'Only Show My Tasks' checkbox:
        self._ui.mine_only_cb.toggled.connect(self._on_mine_only_cb_toggled)
        try:
            # this qsettings stuff seems super flaky on different platforms
            # - although setting is saved as an int, it can get loaded as either an 
            # int or a string, hence the double casting to int and then bool.
            show_mine_only = bool(int(self._settings.value("show_mine_only", True)))
            self._ui.mine_only_cb.setChecked(show_mine_only)    
        except Exception, e:
            self._app.log_warning("Cannot restore state of 'Only Show My Tasks' checkbox: %s" % e)