def build(self):
        '''Build widgets and layout.'''
        self.setLayout(QtWidgets.QHBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.thumbnailWidget = QtWidgets.QLabel()
        self.thumbnailWidget.setFrameStyle(QtWidgets.QFrame.StyledPanel)
        self.thumbnailWidget.setAlignment(QtCore.Qt.AlignCenter)
        self.thumbnailWidget.setFixedWidth(240)

        self.layout().addWidget(self.thumbnailWidget)

        self.propertyTableWidget = QtWidgets.QTableWidget()
        self.propertyTableWidget.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.propertyTableWidget.setSelectionMode(
            QtWidgets.QAbstractItemView.NoSelection)

        self.propertyTableWidget.setRowCount(len(self.headers))
        self.propertyTableWidget.setVerticalHeaderLabels(self.headers)

        self.propertyTableWidget.setColumnCount(1)
        horizontalHeader = self.propertyTableWidget.horizontalHeader()
        horizontalHeader.hide()
        horizontalHeader.setResizeMode(QtWidgets.QHeaderView.Stretch)

        verticalHeader = self.propertyTableWidget.verticalHeader()
        verticalHeader.setResizeMode(QtWidgets.QHeaderView.ResizeToContents)

        # Fix missing horizontal scrollbar when only single column
        self.propertyTableWidget.setHorizontalScrollMode(
            QtWidgets.QAbstractItemView.ScrollPerPixel)

        for index in range(len(self.headers)):
            self.propertyTableWidget.setItem(index, 0,
                                             QtWidgets.QTableWidgetItem(''))

        self.layout().addWidget(self.propertyTableWidget)
    def build(self):
        '''Build widgets and layout.'''
        self.setLayout(QtWidgets.QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.optionsLayout = QtWidgets.QHBoxLayout()
        self.assetTypeSelector = QtWidgets.QComboBox()
        self.optionsLayout.addWidget(self.assetTypeSelector)

        self.refreshButton = QtWidgets.QPushButton(self.tr('Refresh'))
        self.optionsLayout.addWidget(self.refreshButton)
        self.optionsLayout.addStretch(1)

        self.layout().addLayout(self.optionsLayout)

        self.assetTable = QtWidgets.QTableWidget()
        self.assetTable.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.assetTable.setSelectionMode(
            QtWidgets.QAbstractItemView.SingleSelection)
        self.assetTable.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)

        self.assetTable.setColumnCount(len(self.assetTableColumns))
        self.assetTable.setRowCount(0)
        self.assetTable.verticalHeader().hide()

        self.assetTable.setHorizontalHeaderLabels(self.assetTableColumns)

        horizontalHeader = self.assetTable.horizontalHeader()
        horizontalHeader.setResizeMode(QtWidgets.QHeaderView.Fixed)

        self.assetTable.horizontalHeader().setDefaultSectionSize(100)
        self.assetTable.setColumnWidth(1, 63)
        self.assetTable.horizontalHeader().setResizeMode(
            0, QtWidgets.QHeaderView.Stretch)

        self.layout().addWidget(self.assetTable)
Example #3
0
    def create_validate_failed_overlay_widgets(self, label, failed_validators):
        '''Create overlay widgets to report validation failures.'''
        congrat_text = '<h2>Validation Failed!</h2>'
        success_text = 'Your <b>{0}</b> failed to validate.'.format(label)

        self.activeWidget = QtWidgets.QWidget()
        self.activeWidget.setLayout(QtWidgets.QVBoxLayout())
        self.layout().addWidget(self.activeWidget)
        main_layout = self.activeWidget.layout()

        main_layout.addStretch(1)

        congrat_label = QtWidgets.QLabel(congrat_text)
        congrat_label.setAlignment(QtCore.Qt.AlignCenter)

        success_label = QtWidgets.QLabel(success_text)
        success_label.setAlignment(QtCore.Qt.AlignCenter)

        main_layout.addWidget(congrat_label)
        main_layout.addWidget(success_label)

        validators_table_container = QtWidgets.QWidget()
        table_layout = QtWidgets.QVBoxLayout()
        table_layout.setContentsMargins(15, 10, 15, 10)
        validators_table_container.setLayout(table_layout)

        validators_table = QtWidgets.QTableWidget()
        validators_table.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
        validators_table.setSelectionMode(QtWidgets.QTableWidget.NoSelection)

        validators_table.setColumnCount(2)
        validators_table.setHorizontalHeaderLabels(['Validation', 'Error'])
        validators_table.horizontalHeader().setResizeMode(
            0, QtWidgets.QHeaderView.ResizeToContents)
        validators_table.horizontalHeader().setSectionResizeMode(
            QtWidgets.QHeaderView.Stretch)
        validators_table.horizontalHeader().setVisible(True)

        validators_table.setRowCount(len(failed_validators))
        validators_table.verticalHeader().setVisible(False)

        icon = QtGui.QIcon(':ftrack/image/dark/remove')
        font = QtGui.QFont()
        font.setBold(True)

        for row, validator in enumerate(failed_validators):
            item = QtWidgets.QTableWidgetItem(icon, validator[0])
            item.setFont(font)
            validators_table.setItem(row, 0, item)

            error_msg = validator[1]

            # Remove quotes from error message, if present.
            if ((error_msg[0] == error_msg[-1]) and error_msg.startswith(
                ("'", '"'))):
                error_msg = error_msg[1:-1]

            item = QtWidgets.QTableWidgetItem(error_msg)
            validators_table.setItem(row, 1, item)

        table_layout.addWidget(validators_table)
        main_layout.addWidget(validators_table_container)

        main_layout.addStretch(1)
        label = QtWidgets.QLabel('See details for more information.')
        label.setAlignment(QtCore.Qt.AlignCenter)
        main_layout.addWidget(label)

        buttons_layout = QtWidgets.QHBoxLayout()
        main_layout.addLayout(buttons_layout)

        self.details_button = QtWidgets.QPushButton('Details')
        buttons_layout.addWidget(self.details_button)
        self.details_button.clicked.connect(self.on_show_details)

        self.close_button = QtWidgets.QPushButton('Close')
        buttons_layout.addWidget(self.close_button)
        self.close_button.clicked.connect(self.close_window_callback)

        if self.details_window_callback is None:
            self.details_button.setDisabled(True)
Example #4
0
    def setupUi(self, AssetManager):
        '''Setup ui for *AssetManager*.'''
        AssetManager.setObjectName('AssetManager')
        AssetManager.resize(549, 419)
        self.verticalLayout = QtWidgets.QVBoxLayout(AssetManager)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setObjectName('verticalLayout')
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName('horizontalLayout')
        self.AssetManagerComboBox = QtWidgets.QComboBox(AssetManager)
        self.AssetManagerComboBox.setMaximumSize(QtCore.QSize(120, 16777215))
        self.AssetManagerComboBox.setObjectName('AssetManagerComboBox')
        self.horizontalLayout.addWidget(self.AssetManagerComboBox)
        self.versionDownButton = QtWidgets.QPushButton(AssetManager)
        self.versionDownButton.setMinimumSize(QtCore.QSize(20, 0))
        self.versionDownButton.setMaximumSize(QtCore.QSize(20, 16777215))
        self.versionDownButton.setObjectName('versionDownButton')
        self.horizontalLayout.addWidget(self.versionDownButton)
        self.versionUpButton = QtWidgets.QPushButton(AssetManager)
        self.versionUpButton.setMinimumSize(QtCore.QSize(20, 0))
        self.versionUpButton.setMaximumSize(QtCore.QSize(20, 16777215))
        self.versionUpButton.setObjectName('versionUpButton')
        self.horizontalLayout.addWidget(self.versionUpButton)
        self.latestButton = QtWidgets.QPushButton(AssetManager)
        self.latestButton.setMinimumSize(QtCore.QSize(60, 0))
        self.latestButton.setMaximumSize(QtCore.QSize(60, 16777215))
        self.latestButton.setObjectName('latestButton')
        self.horizontalLayout.addWidget(self.latestButton)
        self.selectAllButton = QtWidgets.QPushButton(AssetManager)
        self.selectAllButton.setMinimumSize(QtCore.QSize(80, 0))
        self.selectAllButton.setMaximumSize(QtCore.QSize(80, 16777215))
        self.selectAllButton.setObjectName('selectAllButton')
        self.horizontalLayout.addWidget(self.selectAllButton)
        self.menuButton = QtWidgets.QPushButton(AssetManager)
        self.menuButton.setMaximumSize(QtCore.QSize(70, 16777215))
        self.menuButton.setObjectName('menuButton')
        self.horizontalLayout.addWidget(self.menuButton)
        self.whiteSpaceLabel = QtWidgets.QLabel(AssetManager)
        self.whiteSpaceLabel.setText('')
        self.whiteSpaceLabel.setObjectName('whiteSpaceLabel')
        self.horizontalLayout.addWidget(self.whiteSpaceLabel)
        self.refreshButton = QtWidgets.QPushButton(AssetManager)
        self.refreshButton.setMaximumSize(QtCore.QSize(80, 16777215))
        self.refreshButton.setObjectName('refreshButton')
        self.horizontalLayout.addWidget(self.refreshButton)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.AssertManagerTableWidget = QtWidgets.QTableWidget(AssetManager)
        self.AssertManagerTableWidget.setFrameShape(QtWidgets.QFrame.Box)
        self.AssertManagerTableWidget.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.AssertManagerTableWidget.setSelectionBehavior(
            QtWidgets.QAbstractItemView.SelectRows)
        self.AssertManagerTableWidget.setObjectName('AssertManagerTableWidget')
        self.AssertManagerTableWidget.setColumnCount(0)
        self.AssertManagerTableWidget.setRowCount(0)
        self.verticalLayout.addWidget(self.AssertManagerTableWidget)

        self.retranslateUi(AssetManager)

        # Connect signals.
        self.refreshButton.clicked.connect(AssetManager.refreshAssetManager)

        self.AssetManagerComboBox.currentIndexChanged[int].connect(
            AssetManager.filterAssets)

        self.versionDownButton.clicked.connect(
            AssetManager.versionDownSelected)

        self.versionUpButton.clicked.connect(AssetManager.versionUpSelected)

        self.latestButton.clicked.connect(AssetManager.versionLatestSelected)

        self.selectAllButton.clicked.connect(AssetManager.selectAll)

        QtCore.QMetaObject.connectSlotsByName(AssetManager)