def click_on_edit_line(self, id_line_edit):
        #reset target path
        self.target_path = fs.asset_base_path
        #assemble all value of the dictionary preceding the key
        for i in self.asset_input_fields:
            if (i.text() == id_line_edit.text()):
                break
            self.target_path = os.path.join(self.target_path, i.text())

        print("self.target_path  " + self.target_path)
        self.datas_Type = QtGui.QStandardItemModel()
        completer = self.update_autocompletion(self.datas_Type)
        id_line_edit.setCompleter(completer)
Beispiel #2
0
    def __init__(self, canvas, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.setupUi(self)
        self.canvas = canvas

        self.pushButtonAddClass.clicked.connect(self.add_class)
        self.pushButtonRemoveClass.clicked.connect(self.remove_class)
        self.pushButtonImport.clicked.connect(self.import_metadata)
        self.pushButtonSave.clicked.connect(self.save)
        self.pushButtonLoadPoints.clicked.connect(self.load)
        self.pushButtonReset.clicked.connect(self.reset)
        self.pushButtonExport.clicked.connect(self.export)

        self.pushButtonExport.setIcon(QtGui.QIcon('icons:export.svg'))
        self.pushButtonReset.setIcon(QtGui.QIcon('icons:reset.svg'))
        self.pushButtonImport.setIcon(QtGui.QIcon('icons:import.svg'))
        self.pushButtonSave.setIcon(QtGui.QIcon('icons:save.svg'))
        self.pushButtonLoadPoints.setIcon(QtGui.QIcon('icons:load.svg'))
        self.pushButtonRemoveClass.setIcon(QtGui.QIcon('icons:delete.svg'))
        self.pushButtonAddClass.setIcon(QtGui.QIcon('icons:add.svg'))

        self.tableWidgetClasses.verticalHeader().setVisible(False)
        self.tableWidgetClasses.horizontalHeader().setMinimumSectionSize(1)
        self.tableWidgetClasses.horizontalHeader().setStretchLastSection(False)
        self.tableWidgetClasses.horizontalHeader().setSectionResizeMode(
            0, QtWidgets.QHeaderView.ResizeMode.Stretch)
        self.tableWidgetClasses.setColumnWidth(1, 30)
        self.tableWidgetClasses.cellClicked.connect(self.cell_clicked)
        self.tableWidgetClasses.cellChanged.connect(self.cell_changed)
        self.tableWidgetClasses.selectionModel().selectionChanged.connect(
            self.selection_changed)

        self.checkBoxDisplayPoints.toggled.connect(self.display_points)
        self.checkBoxDisplayGrid.toggled.connect(self.display_grid)
        self.canvas.image_loaded.connect(self.image_loaded)
        self.canvas.update_point_count.connect(self.update_point_count)
        self.canvas.points_loaded.connect(self.points_loaded)
        self.canvas.metadata_imported.connect(self.display_count_tree)

        self.model = QtGui.QStandardItemModel()
        self.current_model_index = QtCore.QModelIndex()
        self.treeView.setModel(self.model)
        self.reset_model()
        self.treeView.doubleClicked.connect(self.select_model_item)

        self.previous_file_name = None  # used for quick save

        self.spinBoxPointRadius.valueChanged.connect(
            self.canvas.set_point_radius)
        self.spinBoxGrid.valueChanged.connect(self.canvas.set_grid_size)

        icon = QtGui.QPixmap(20, 20)
        icon.fill(QtCore.Qt.GlobalColor.yellow)
        self.labelPointColor.setPixmap(icon)
        self.labelPointColor.mousePressEvent = self.change_active_point_color
        icon = QtGui.QPixmap(20, 20)
        icon.fill(QtCore.Qt.GlobalColor.white)
        self.labelGridColor.setPixmap(icon)
        self.labelGridColor.mousePressEvent = self.change_grid_color

        self.checkBoxImageFields.clicked.connect(self.hide_custom_fields.emit)
    def draw_gui(self):

        self.main_layout = QtWidgets.QHBoxLayout()
        #self.setGeometry(1000,50,100,200)
        self.right_panel = QtWidgets.QVBoxLayout()

        ##picture##
        self.image = QtWidgets.QLabel()
        pixmap = QtGui.QPixmap(
            r"C:\Users\Natspir\Documents\Code\Python\NSVFXPipeline\pipeline\tools\GUI\Resources\saveAsset_GUIdraw.png"
        )
        #pixmap.setAttribute(QtCore.Qt.WA_TranslucentBackground)
        #pixmap.fill(QtCore.Qt.yellow)
        pixmap = pixmap.scaledToHeight(200)
        self.image.setPixmap(pixmap)
        self.right_panel.addWidget(self.image)
        ####
        self.open_asset_folder_btn = QtWidgets.QPushButton("Open Asset Folder")
        self.open_asset_folder_btn.clicked.connect(self.open_asset_folder)
        self.right_panel.addWidget(self.open_asset_folder_btn)
        #
        self.type_input = self.add_line_edit("Type : ", self.asset_type)
        self.asset_input_fields.append(self.type_input)
        #self.type_input.textEdited.connect(self.update_target_path)
        #self.datas_Type = QtGui.QStandardItemModel()
        #completer = self.update_autocompletion(self.datas_Type)
        #self.type_input.setCompleter(completer)
        self.type_input.clicked.connect(
            lambda: self.click_on_edit_line(self.type_input))

        self.name_input = self.add_line_edit("Asset name : ", self.asset_name)
        self.asset_input_fields.append(self.name_input)
        #self.name_input.textEdited.connect(self.update_target_path)
        #self.model2 = QtGui.QStandardItemModel()
        #completer = self.update_autocompletion(self.model2)
        #self.name_input.setCompleter(completer)
        #self.name_input = self.update_autocompletion(self.name_input)
        self.name_input.clicked.connect(
            lambda: self.click_on_edit_line(self.name_input))
        """self.model = QtGui.QStandardItemModel()
        self.completer = QtWidgets.QCompleter(self.model, self)
        self.model.appendRow(QtGui.QStandardItem("test"))
        self.type_input.setCompleter(self.completer)"""
        self.task_input = self.add_line_edit("Task : ", self.asset_task)
        self.asset_input_fields.append(self.task_input)
        #self.task_input.textEdited.connect(self.update_target_path)
        #self.update_autocompletion(self.task_input)
        self.task_input.clicked.connect(
            lambda: self.click_on_edit_line(self.task_input))

        self.subtask_input = self.add_line_edit("Subtask : ",
                                                self.asset_subtask)
        self.asset_input_fields.append(self.subtask_input)
        self.subtask_input.clicked.connect(
            lambda: self.click_on_edit_line(self.subtask_input))

        self.version_input = self.add_line_edit("Version : ",
                                                self.asset_version)
        self.asset_input_fields.append(self.version_input)
        self.version_input.clicked.connect(
            lambda: self.click_on_edit_line(self.version_input))

        self.console = QtWidgets.QLabel("")
        self.right_panel.addWidget(self.console)
        #buttons valid or cancel
        h_button_layout = QtWidgets.QHBoxLayout()
        button_validate = QtWidgets.QPushButton("Save")
        button_validate.clicked.connect(self.save)
        h_button_layout.addWidget(button_validate)
        button_cancel = QtWidgets.QPushButton("Cancel")
        button_cancel.clicked.connect(self.cancel)
        h_button_layout.addWidget(button_cancel)
        self.right_panel.addLayout(h_button_layout)
        self.main_layout.addLayout(self.right_panel)
        #left panel tree view
        self.left_panel = QtWidgets.QVBoxLayout()
        tree_view = QtWidgets.QTreeView()
        tree_model = QtGui.QStandardItemModel()
        tree_model = self.fill_tree_view(tree_model)
        tree_view.setModel(tree_model)
        if self.asset_type:
            pass
            #item = tree_view.findItems(self.asset_type)
            #print("item found : "+str(item))
        #tree_view.expandAll()
        self.left_panel.addWidget(tree_view)
        self.main_layout.addLayout(self.left_panel)
        self.setLayout(self.main_layout)