Пример #1
0
    def create_ui(self):
        self.dialog = QtGui.QDialog()
        self.dialog.setWindowTitle('Select Item Type')
        self.dialog.setMinimumWidth(300)
        self.dialog.setMinimumHeight(100)
        self.dialog.setWindowFlags(QtCore.Qt.CustomizeWindowHint
                                   | QtCore.Qt.WindowTitleHint)
        self.dialog.keyPressEvent = self.key_press_event
        main_layout = QtGui.QVBoxLayout(self.dialog)

        qtwidgets = sgtk.platform.framework.load_framework(
            self.engine, self.engine.context, self.engine.env,
            "tk-framework-qtwidgets_v2.x.x")
        elided_label = qtwidgets.import_module("elided_label")

        path_label = elided_label.ElidedLabel()
        path_label.setText("File Name: {}".format(self.path))
        main_layout.addWidget(path_label)
        # create list widget with items
        self.items_list_widget = QtGui.QListWidget()
        self.items_list_widget.addItems(self.item_types)
        main_layout.addWidget(self.items_list_widget)
        # select first item
        self.items_list_widget.setCurrentRow(0)
        # create "OK" button
        ok_button = QtGui.QPushButton("OK")
        ok_button.clicked.connect(self.get_selected_item)
        main_layout.addWidget(ok_button)
        self.dialog.exec_()
Пример #2
0
    def _show_image(self):
        """
        The user requested to show the file.

        Display the image in a transient, modeless QDialog.
        """

        # don't continue unless there's somethign to show
        if not self._pixmap:
            return

        if self._image_path:
            # try to use the local path if there is one
            display_pixmap = QtGui.QPixmap(self._image_path)
        else:
            # may only have the pixmap (delegates)
            display_pixmap = QtGui.QPixmap(self._pixmap)

        # construct the dialog, display label, and a button box to close it.

        img_dialog = QtGui.QDialog(self)
        img_dialog.setWindowTitle(
            "Viewing: %s %s"
            % (
                shotgun_globals.get_type_display_name(self._entity_type),
                self._field_name,
            )
        )

        lbl = QtGui.QLabel()
        lbl.setPixmap(display_pixmap)

        btn_box = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)

        layout = QtGui.QVBoxLayout(img_dialog)
        layout.addWidget(lbl)
        layout.addWidget(btn_box)

        btn_box.accepted.connect(img_dialog.accept)

        img_dialog.show()
    def playblast_submit_dialog(self):
        """A dialog UI widget that allows the user to enter comments and then
        initiate the upload to Shotgun as a Version if they choose, by entering
        text + clicking the button. Intercepts before the standard upload.
        NOTE: sgtk's implementation of Qt doesn't have libraries available for
        using .ui files directly, so we have to program it explicitly.
        """
        # main dialog
        self.dialog = QtGui.QDialog(
            None,
            QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint
        )

        self.dialog.setObjectName('PlayblastDialog')
        self.dialog.resize(440, 240)
        self.dialog.setMinimumSize(QtCore.QSize(440, 240))
        self.dialog.setMaximumSize(QtCore.QSize(440, 240))

        self.dialog.setWindowFlags(
            self.dialog.windowFlags() | QtCore.Qt.WindowStaysOnTopHint
        )

        self.dialog.setWindowTitle(
            QtGui.QApplication.translate(
                'PlayblastDialog',
                'Playblast to Shotgun - Sinking Ship',
                None,
                QtGui.QApplication.UnicodeUTF8
            )
        )

        # main layout & grid
        self.dialog.gridLayoutWidget = QtGui.QWidget(self.dialog)
        self.dialog.gridLayoutWidget.setGeometry(QtCore.QRect(9, 9, 421, 221))
        self.dialog.gridLayoutWidget.setObjectName('gridLayoutWidget')

        self.dialog.gridLayout_main = QtGui.QGridLayout(
            self.dialog.gridLayoutWidget
        )

        self.dialog.gridLayout_main.setContentsMargins(0, 0, 0, 0)
        self.dialog.gridLayout_main.setObjectName('gridLayout_main')

        # upload button
        self.dialog.pushButton_upload = QtGui.QPushButton(
            self.dialog.gridLayoutWidget
        )
        self.dialog.pushButton_upload.setObjectName('pushButton_upload')

        self.dialog.pushButton_upload.setText(
            QtGui.QApplication.translate(
                'PlayblastDialog',
                'Upload as Version to Shotgun',
                None,
                QtGui.QApplication.UnicodeUTF8
            )
        )

        self.dialog.gridLayout_main.addWidget(
            self.dialog.pushButton_upload,
            2,
            0,
            1,
            1
        )

        # comments groupbox
        self.dialog.groupBox_comments = QtGui.QGroupBox(
            self.dialog.gridLayoutWidget
        )

        self.dialog.groupBox_comments.setAlignment(QtCore.Qt.AlignCenter)
        self.dialog.groupBox_comments.setFlat(False)
        self.dialog.groupBox_comments.setObjectName('groupBox_comments')

        self.dialog.groupBox_comments.setTitle(
            QtGui.QApplication.translate(
                'PlayblastDialog',
                'Artist Comments',
                None,
                QtGui.QApplication.UnicodeUTF8
            )
        )

        # comments textedit
        self.dialog.textEdit_comments = QtGui.QTextEdit(
            self.dialog.groupBox_comments
        )

        self.dialog.textEdit_comments.setGeometry(
            QtCore.QRect(12, 20, 395, 131)
        )

        self.dialog.textEdit_comments.setMinimumSize(QtCore.QSize(395, 131))
        self.dialog.textEdit_comments.setMaximumSize(QtCore.QSize(395, 131))
        self.dialog.textEdit_comments.setObjectName('textEdit_comments')

        self.dialog.gridLayout_main.addWidget(
            self.dialog.groupBox_comments,
            1,
            0,
            1,
            1
        )

        # signals and slots
        self.dialog.pushButton_upload.clicked.connect(
            self.maya_shot_playblast_version
        )

        # launch dialog
        self.dialog.exec_()
Пример #4
0
    def create_ui(self):
        """
        Create a dialog with the list of items received on object initialisation and,
        based on the choice to publish or not, and to reuse or export,
        modify the properties of each item
        """
        # create dialog
        self.dialog = QtGui.QDialog()
        self.dialog.setWindowTitle('%s or Export Channels' % self.reuse_text)
        self.dialog.setMinimumWidth(600)
        # show only title (no close button)
        self.dialog.setWindowFlags(QtCore.Qt.CustomizeWindowHint
                                   | QtCore.Qt.WindowTitleHint)

        main_layout = QtGui.QVBoxLayout(self.dialog)
        # add usage instructions
        instruction_label = QtGui.QLabel(
            "Select the channels to be published.\n"
            "Choose `%s` to %s the channel from previous publish.\n"
            "Choose `Export` to export it from the current Mari session.\n" %
            (self.reuse_text, self.reuse_text))
        instruction_label.setFrameStyle(QtGui.QFrame.StyledPanel)
        instruction_label.setMaximumHeight(60)
        instruction_label.setContentsMargins(1, 5, 1, 5)
        main_layout.addWidget(instruction_label)

        channels_heading_label = QtGui.QLabel("Channels:")
        channels_heading_label.setMaximumHeight(20)
        channels_heading_label.setContentsMargins(1, 5, 1, 5)
        main_layout.addWidget(channels_heading_label)

        # add scroll area for item list
        self.channel_layout = QtGui.QVBoxLayout()
        scroll_widget = QtGui.QWidget()
        scroll_widget.setLayout(self.channel_layout)

        channel_scroll_area = QtGui.QScrollArea()
        channel_scroll_area.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOn)
        channel_scroll_area.setWidgetResizable(True)
        channel_scroll_area.setWidget(scroll_widget)

        main_layout.addWidget(channel_scroll_area)

        # add checkbox per item
        for item in self.items:
            self.add_checkable(item)

        # add select all/none and OK buttons
        select_all_button = QtGui.QPushButton("Select All")
        select_all_button.setMaximumWidth(120)
        select_all_button.clicked.connect(
            lambda: self.set_channel_check_status(True))

        select_none_button = QtGui.QPushButton("Select None")
        select_none_button.setMaximumWidth(120)
        select_none_button.clicked.connect(
            lambda: self.set_channel_check_status(False))

        ok_button = QtGui.QPushButton("OK")
        ok_button.setMinimumWidth(75)
        ok_button.clicked.connect(self.ok_button_cb)

        button_layout = QtGui.QHBoxLayout()
        button_layout.addWidget(select_all_button)
        button_layout.addWidget(select_none_button)
        button_layout.addStretch()
        button_layout.addWidget(ok_button)

        main_layout.addLayout(button_layout)
        self.dialog.exec_()