Example #1
0
    def __launch_blur_dialog(self, title, bundle, widget_class, is_modal,
                             *args, **kwargs):
        """
        Handle launching a TankQDialog using the blur library
        """
        if not self.has_ui:
            self.log_error(
                "Sorry, this environment does not support UI display! Cannot show "
                "the requested window '%s'." % title)
            return

        from tank.platform.qt import tankqdialog

        # first construct the widget object
        widget = self._create_widget(widget_class, *args, **kwargs)

        # temporary factory method which returns a dialog class instance
        # this is what the blur library needs to construct the classes
        def dialog_factory(parent):
            dlg = self._create_dialog(title, bundle, widget, parent)
            return dlg

        blur_result = blurdev.launch(dialog_factory, modal=is_modal)

        # get the dialog result from the returned blur result:
        dlg_res = None

        from tank.platform.qt import QtGui
        if isinstance(blur_result, QtGui.QDialog):
            # As of Blur 13312, the result returned from launching a dialog
            # using Blur seems to be the dialog iteslf rather than the dialog
            # code as was previously returned!
            dlg_res = blur_result.result()
        elif isinstance(blur_result, int):
            # the result is the dialog return code
            dlg_res = blur_result
        else:
            raise TankError(
                "Blur returned an unexpected result when launching a dialog: %s"
                % blur_result)

        return (dlg_res, widget)
Example #2
0
    def render_apps_menu(self, button_center_from_left, button_center_from_top):
        
        from . import menu_ui
        
        self._close_existing_menus()
        
        height = 300
        width = 200
        
        dialog_x = button_center_from_left - (width/2)
        dialog_y = button_center_from_top - height + 10
        
        self._current_app_menu = blurdev.launch(menu_ui.AppsMenu)
        self._current_app_menu.move(dialog_x, dialog_y)
        
        self._current_app_menu.resize(width, height)

        for (cmd_name, cmd_details) in self._engine.commands.items():
            properties = cmd_details["properties"]
            callback = cmd_details["callback"]
            if properties.get("type", "default") == "default":
                self._current_app_menu.add_item(cmd_name, callback)
Example #3
0
    def __launch_blur_dialog(self, title, bundle, widget_class, is_modal, *args, **kwargs):
        """
        Handle launching a TankQDialog using the blur library
        """
        if not self.has_ui:
            self.log_error("Sorry, this environment does not support UI display! Cannot show "
                           "the requested window '%s'." % title)
            return        
        
        from tank.platform.qt import tankqdialog 
        
        # first construct the widget object
        widget = self._create_widget(widget_class, *args, **kwargs)
        
        # temporary factory method which returns a dialog class instance
        # this is what the blur library needs to construct the classes
        def dialog_factory(parent):
            dlg = self._create_dialog(title, bundle, widget, parent)
            return dlg

        blur_result = blurdev.launch(dialog_factory, modal=is_modal) 

        # get the dialog result from the returned blur result:
        dlg_res = None
        
        from tank.platform.qt import QtGui
        if isinstance(blur_result, QtGui.QDialog):
            # As of Blur 13312, the result returned from launching a dialog
            # using Blur seems to be the dialog iteslf rather than the dialog
            # code as was previously returned!
            dlg_res = blur_result.result()
        elif isinstance(blur_result, int):
            # the result is the dialog return code
            dlg_res = blur_result
        else:
            raise TankError("Blur returned an unexpected result when launching a dialog: %s" % blur_result)
        
        return (dlg_res, widget)
Example #4
0
    def render_work_area_menu(self, button_center_from_left,
                              button_center_from_top):
        """
        Create a QT window and display
        """

        from . import menu_ui

        self._close_existing_menus()

        height = 300
        width = 200

        dialog_x = button_center_from_left - (width / 2)
        dialog_y = button_center_from_top - height + 10

        self._current_work_area_menu = blurdev.launch(menu_ui.WorkAreaMenu)

        self._current_work_area_menu.move(dialog_x, dialog_y)
        self._current_work_area_menu.resize(width, height)

        # make the context name
        ctx = self._engine.context
        ctx_name = str(ctx)
        self._current_work_area_menu.set_work_area_text(ctx_name)

        # link to UI
        self._current_work_area_menu.add_item("Jump to Shotgun",
                                              self._jump_to_sg)
        self._current_work_area_menu.add_item("Jump to File System",
                                              self._jump_to_fs)

        # add context apps
        for (cmd_name, cmd_details) in self._engine.commands.items():
            properties = cmd_details["properties"]
            callback = cmd_details["callback"]
            if properties.get("type", "default") == "context_menu":
                self._current_work_area_menu.add_item(cmd_name, callback)
Example #5
0
    def render_apps_menu(self, button_center_from_left,
                         button_center_from_top):

        from . import menu_ui

        self._close_existing_menus()

        height = 300
        width = 200

        dialog_x = button_center_from_left - (width / 2)
        dialog_y = button_center_from_top - height + 10

        self._current_app_menu = blurdev.launch(menu_ui.AppsMenu)
        self._current_app_menu.move(dialog_x, dialog_y)

        self._current_app_menu.resize(width, height)

        for (cmd_name, cmd_details) in self._engine.commands.items():
            properties = cmd_details["properties"]
            callback = cmd_details["callback"]
            if properties.get("type", "default") == "default":
                self._current_app_menu.add_item(cmd_name, callback)
Example #6
0
    def render_work_area_menu(self, button_center_from_left, button_center_from_top):
        """
        Create a QT window and display
        """
        
        from . import menu_ui
        
        self._close_existing_menus()
        
        height = 300
        width = 200
        
        dialog_x = button_center_from_left - (width/2)
        dialog_y = button_center_from_top - height + 10
        
        self._current_work_area_menu = blurdev.launch(menu_ui.WorkAreaMenu)
        
        self._current_work_area_menu.move(dialog_x, dialog_y)
        self._current_work_area_menu.resize(width, height)
        
        
        # make the context name
        ctx = self._engine.context
        ctx_name = str(ctx)        
        self._current_work_area_menu.set_work_area_text(ctx_name)
        
        # link to UI
        self._current_work_area_menu.add_item("Jump to Shotgun", self._jump_to_sg)
        self._current_work_area_menu.add_item("Jump to File System", self._jump_to_fs)

        # add context apps
        for (cmd_name, cmd_details) in self._engine.commands.items():
            properties = cmd_details["properties"]
            callback = cmd_details["callback"]
            if properties.get("type", "default") == "context_menu":
                self._current_work_area_menu.add_item(cmd_name, callback)
Example #7
0
def main():
	blurdev.registerScriptPath(__file__)
	blurdev.launch(PreviewCheckWindow)