Ejemplo n.º 1
0
    def _on_before_paint(self, widget, model_index, style_options):
        """
        Called by the base class when the associated widget should be
        painted in the view. This method should implement setting of all
        static elements (labels, pixmaps etc) but not dynamic ones (e.g. buttons)

        :param widget: The widget to operate on (created via _create_widget)
        :param model_index: The model index to operate on
        :param style_options: QT style options
        """
        icon = shotgun_model.get_sanitized_data(model_index, QtCore.Qt.DecorationRole)
        widget.set_thumbnail(icon)

        # get the shotgun data
        sg_item = shotgun_model.get_sg_data(model_index)

        # fill the content of the widget with the data of the loaded ShotGrid
        # item
        widget.set_text(sg_item)

        # add an action to the widget toolbox to be able to open the ShotGrid Web page of the current item
        sg_url = sgtk.platform.current_bundle().shotgun.base_url
        url = "%s/page/project_overview?project_id=%d" % (sg_url, sg_item["id"])
        fn = lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
        a = QtGui.QAction("View in Shotgun", None)
        a.triggered[()].connect(fn)

        widget.set_actions([a])
    def _on_before_selection(self, widget, model_index, style_options):
        """
        Called when the associated widget is being set up. Initialize
        things that shall persist, for example action menu items.
        """
        # do std drawing first
        self._on_before_paint(widget, model_index, style_options)
        widget.set_selected(True)

        # set up the menu
        sg_item = shotgun_model.get_sg_data(model_index)
        actions = self._action_manager.get_actions_for_publish(
            sg_item, self._action_manager.UI_AREA_HISTORY)

        # if there is a version associated, add View in Screening Room Action
        if sg_item.get("version"):
            sg_url = sgtk.platform.current_bundle().shotgun.base_url
            url = "%s/page/screening_room?entity_type=%s&entity_id=%d" % (
                sg_url, sg_item["version"]["type"], sg_item["version"]["id"])

            fn = lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
            a = QtGui.QAction("View in Screening Room", None)
            a.triggered[()].connect(fn)
            actions.append(a)

        # add actions to actions menu
        widget.set_actions(actions)
 def _show_docs(self):
     """
     Internal action callback - Launch app documentation
     """
     self._app.log_debug("Opening url %s..." % self._app.documentation_url)
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(
         self._app.documentation_url))
Ejemplo n.º 4
0
 def _load_shotgun_activity_stream(self):
     """
     Called when someone clicks 'show activity stream in shotgun'
     """
     url = "%s/detail/%s/%s" % (self._bundle.sgtk.shotgun_url,
                                self._entity_type, self._entity_id)
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
def _jump_to_sg(engine):
    """
    Jump from context to Sg
    """
    from tank.platform.qt import QtCore, QtGui
    url = engine.context.shotgun_url
    QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
 def _on_before_selection(self, widget, model_index, style_options):
     """
     Called when the associated widget is selected. This method 
     implements all the setting up and initialization of the widget
     that needs to take place prior to a user starting to interact with it.
     
     :param widget: The widget to operate on (created via _create_widget)
     :param model_index: The model index to operate on
     :param style_options: QT style options
     """
     # do std drawing first
     self._on_before_paint(widget, model_index, style_options)        
     widget.set_selected(True)
     
     # set up the menu
     sg_item = shotgun_model.get_sg_data(model_index)
     actions = self._action_manager.get_actions_for_publish(sg_item, self._action_manager.UI_AREA_HISTORY)
     
     # if there is a version associated, add View in Screening Room Action
     if sg_item.get("version"):
         sg_url = sgtk.platform.current_bundle().shotgun.base_url
         url = "%s/page/screening_room?entity_type=%s&entity_id=%d" % (sg_url, 
                                                                       sg_item["version"]["type"], 
                                                                       sg_item["version"]["id"])                    
         
         fn = lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))                    
         a = QtGui.QAction("View in Screening Room", None)
         a.triggered[()].connect(fn)
         actions.append(a)
     
     # add actions to actions menu
     widget.set_actions(actions)            
Ejemplo n.º 7
0
 def _jump_to_shotgun(self):
     """
     Jump to shotgun, launch web browser
     """
     from sgtk.platform.qt import QtCore, QtGui
     url = self.context.shotgun_url
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 8
0
 def _launch_docs(self):
     """
     Launches documentation describing how to configure the app launch
     """
     if self._app:
         QtGui.QDesktopServices.openUrl(QtCore.QUrl(self._app.HELP_DOC_URL))
     self.close()
Ejemplo n.º 9
0
 def _launch_docs(self):
     """
     Launches documentation describing how to configure the app launch
     """
     app = sgtk.platform.current_bundle()
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(app.HELP_DOC_URL))
     self.close()
Ejemplo n.º 10
0
 def _jump_to_sg(self):
     """
     Jump to shotgun, launch web browser
     :param state: The state of the menu item
     :return: None
     """
     url = self._engine.context.shotgun_url
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 11
0
    def _jump_to_sg(self):
        """
        Jump to ShotGrid, launch web browser
        """
        url = self._engine.context.shotgun_url

        self._engine.logger.debug("Open URL: {}".format(url))
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 12
0
 def _show_in_sg(self, entity):
     """
     Callback - Shows a shotgun entity in the web browser
     
     :param entity: std sg entity dict with keys type, id and name
     """
     url = "%s/detail/%s/%d" % (self._app.sgtk.shotgun.base_url, entity["type"], entity["id"])                    
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 13
0
    def _jump_to_sg(self):
        """
        Jump from a context to Shotgun.
        """
        from sgtk.platform.qt import QtCore, QtGui

        url = self.engine.context.shotgun_url
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 14
0
    def _open_url(self, url):
        """Opens the supplied url in the appropriate browser."""

        try:
            logger.debug("Opening url: '%s'." % (url, ))
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
        except Exception, e:
            logger.error("Failed to open url: '%s'. Reason: %s" % (url, e))
Ejemplo n.º 15
0
 def _show_in_sr(self, entity):
     """
     Callback - Shows a shotgun entity in screening room
     
     :param entity: std sg entity dict with keys type, id and name
     """
     url = "%s/page/screening_room?entity_type=%s&entity_id=%d" % (
         self._app.sgtk.shotgun.base_url, entity["type"], entity["id"])
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
 def _show_in_sr(self, entity):
     """
     Callback - Shows a shotgun entity in the shotgun media center
     
     :param entity: std sg entity dict with keys type, id and name
     """
     url = "%s/page/media_center?type=%s&id=%s" % (
         self._app.sgtk.shotgun.base_url, entity["type"], entity["id"])
     QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 17
0
    def _check_url(self, text):
        """
        Enable add link button if the url is valid, disable otherwise

        :param text: The typed text
        """

        url = QtCore.QUrl(text)
        self._add_link_btn.setEnabled(url.isValid())
Ejemplo n.º 18
0
 def _navigate_to_entity(self, entity_type, entity_id):
     """
     Navigate to a particular entity 
     """
     sg_location = ShotgunLocation(entity_type, entity_id)
     if sg_location.sg_formatter.should_open_in_shotgun_web:
         sg_url = sg_location.get_external_url()
         QtGui.QDesktopServices.openUrl(QtCore.QUrl(sg_url))
     else:
         self._navigate_to(sg_location)
Ejemplo n.º 19
0
 def _on_help_url_clicked(self):
     """
     Called when someone clicks the help url
     """
     url = self._engine.documentation_url
     if url:
         self._engine.log_debug("Opening documentation url %s..." % url)
         QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
     else:
         self._engine.log_warning("No documentation found!")
Ejemplo n.º 20
0
def open_url(url):
    """
    Opens the supplied url via desktop services.

    :param url: The url to open
    """

    try:
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
    except Exception as e:
        logger.error("Failed to launch more info dialog. Reason: %s" % (e,))
Ejemplo n.º 21
0
    def show_engine_in_app_store(self):
        """
        Jump to app store
        """
        curr_selection = self.ui.environment_browser.get_selected_item()
        if curr_selection is None:
            return

        doc_url = curr_selection.data.get("documentation_url")
        if doc_url:
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(doc_url))
Ejemplo n.º 22
0
    def _navigate_sg_and_close(self, version_id):
        """
        Navigates to the given version in shotgun and closes
        the window.

        :prarm int version_id: Version id to navigate to
        """
        self.close()
        # open sg media center playback overlay page
        url = "%s/page/media_center?type=Version&id=%d" % (
            self._bundle.sgtk.shotgun.base_url, version_id)
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 23
0
    def _open_url_for_published_file(self, file):
        """
        """
        # construct the url:
        published_file_entity_type = sgtk.util.get_published_file_entity_type(
            self._app.sgtk)
        url = "%s/detail/%s/%d" % (self._app.sgtk.shotgun.base_url,
                                   published_file_entity_type,
                                   file.published_file_id)

        # and open it:
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 24
0
    def _playback_version(self, version_data):
        """
        Given version data, play back a version

        :param version_data: A version dictionary containing version data
        """
        url = ShotgunTypeFormatter.get_playback_url(version_data)
        if url:
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
        else:
            self._app.log_warning("Cannot play back version %s - "
                                  "no playback url defined." %
                                  version_data["id"])
Ejemplo n.º 25
0
    def _on_link_clicked(self, url):
        """
        When someone clicks a url
        """
        if url is None:
            return

        if url.startswith("http"):
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))

        else:
            (entity_type, entity_id) = url.split(":")
            entity_id = int(entity_id)
            self._navigate_to_entity(entity_type, entity_id)
Ejemplo n.º 26
0
    def navigate_to_entity(self, entity_type, entity_id):
        """
        Navigate to a particular entity.
        A history entry will be created and inserted into the
        history navigation stack.

        :param entity_type: Shotgun entity type
        :param entity_id: Shotgun entity id
        """
        sg_location = ShotgunLocation(entity_type, entity_id)
        if sg_location.sg_formatter.should_open_in_shotgun_web:
            sg_url = sg_location.get_external_url()
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(sg_url))
        else:
            self._navigate_to(sg_location)
Ejemplo n.º 27
0
    def show_app_in_app_store(self):
        """
        Jump to app store
        """
        curr_selection = self.ui.app_browser.get_selected_item()
        if curr_selection is None:
            return

        doc_url = curr_selection.data.get("documentation_url")
        if doc_url is None:
            QtGui.QMessageBox.critical(
                self,
                "No Documentation found!",
                "Sorry, this app does not have any associated documentation!",
            )
        else:
            QtGui.QDesktopServices.openUrl(QtCore.QUrl(doc_url))
Ejemplo n.º 28
0
def show_in_shotgun(entity):
    """
    Show the supplied path in Shotgun

    :param entity: A standard SG entity dictionary containing at least the
        "type" and "id" fields.
    """

    publisher = sgtk.platform.current_bundle()

    url = "%s/detail/%s/%d" % (publisher.sgtk.shotgun_url, entity["type"], entity["id"])

    try:
        logger.debug("Opening entity url: '%s'." % (url,))
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
    except Exception as e:
        logger.error("Failed to open url: '%s'. Reason: %s" % (url, e))
Ejemplo n.º 29
0
    def mousePressEvent(self, event):
        """
        Fires when the mouse is pressed
        """
        ClickableLabel.mousePressEvent(self, event)

        # {'attachment_links': [{'id': 6105,
        #                        'name': "Manne's Note on bunny_010_0050 - asdasdasdasd",
        #                        'type': 'Note'}],
        #  'created_at': 1438774776.0,
        #  'created_by': {'id': 38, 'name': 'Manne Ohrstrom', 'type': 'HumanUser'},
        #  'id': 266,
        #  'image': None,
        #  'this_file': {'content_type': 'application/pdf',
        #                'id': 266,
        #                'link_type': 'upload',
        #                'name': 'SustraMM_Costs_and_benefits_of_cycling.pdf',
        #                'type': 'Attachment',
        #                'url': 'https://manne-dev-1.shotgunstudio.com/file_serve/attachment/266'},
        #  'type': 'Attachment'}

        # {'attachment_links': [{'id': 6105,
        #                        'name': "Manne's Note on bunny_010_0050 - asdasdasdasd",
        #                        'type': 'Note'}],
        #  'created_at': 1438774085.0,
        #  'created_by': {'id': 38, 'name': 'Manne Ohrstrom', 'type': 'HumanUser'},
        #  'id': 265,
        #  'image': 'https://sg-media-usor-01.s3.amazonaws.com/...',
        #  'this_file': {'content_type': 'image/png',
        #                'id': 265,
        #                'link_type': 'upload',
        #                'name': 'screencapture_o9Pgb9.png',
        #                'type': 'Attachment',
        #                'url': 'https://sg-media-usor-01.s3.amazonaws.com/...'},
        #  'type': 'Attachment'}

        # the url to serve up attachments is on the form
        # https://manne-dev-1.shotgunstudio.com/file_serve/attachment/259/screencapture_3bVvcA.png

        file_name = self._data["this_file"]["name"]
        url = "%s/file_serve/attachment/%s/%s" % (
            self._bundle.sgtk.shotgun_url,
            self._data["id"],
            file_name,
        )
        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))
Ejemplo n.º 30
0
    def _start_screeningroom_web(self):
        """
        Launches the screening room web player
        """
        from sgtk.platform.qt import QtGui, QtCore

        entity = self._get_entity()

        # url format is
        # https://playbook.shotgunstudio.com/page/screening_room?entity_type=Version&entity_id=222
        url = "%s/page/screening_room?entity_type=%s&entity_id=%s" % (
            self.shotgun.base_url,
            entity.get("type"),
            entity.get("id"),
        )

        self.logger.debug("Opening url %s" % url)

        QtGui.QDesktopServices.openUrl(QtCore.QUrl(url))