def create_context_menu(self): self.menu = QtWidgets.QMenu(self) self.addStepMenu = QtWidgets.QMenu('Add pipeline step', self) self.addTypeMenu = QtWidgets.QMenu('Add file type', self) for step in PIPELINE_STEPS: action = QtWidgets.QAction(step, self.addStepMenu) action.triggered.connect(self.add_new_step_to_list) self.addStepMenu.addAction(action) for type in FILE_TYPES: action = QtWidgets.QAction(type, self.addTypeMenu) action.triggered.connect(self.add_new_type_to_list) self.addTypeMenu.addAction(action) self.menu.addMenu(self.addStepMenu) self.menu.addMenu(self.addTypeMenu)
def create_context_menu(self): self.menu = QtWidgets.QMenu(self.scene().parent()) self.show_detail_action = QtWidgets.QAction("Open in Browser", self.menu) self.show_detail_action.triggered.connect( self._show_details_action_triggered) self.open_in_file_action = QtWidgets.QAction("Open in File Browser", self.menu) self.open_in_file_action.triggered.connect( self._open_file_action_triggered) self.menu.addAction(self.show_detail_action) self.menu.addAction(self.open_in_file_action) self.menu.setStyleSheet(""" QMenu::item:selected{ background:rgb(100, 100, 150) } """)
def element_widget(self): show_label = QtWidgets.QLabel("Show") self.path_label = QtWidgets.QLabel("Reference Path") mode_label = QtWidgets.QLabel("Mode") upload_type = QtWidgets.QLabel("Type") self.tree_view = QtWidgets.QTreeView() self.tree_view.setModel(self.model.none_tree) self.tree_view.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.tree_view.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectItems) self.tree_view.setColumnWidth(0, 450) self.tree_view.setColumnWidth(1, 80) self.tree_view.setColumnWidth(2, 50) self.tree_view.setDragEnabled(True) self.tree_view.setAcceptDrops(True) rename_label = QtWidgets.QLabel("Selected File ") rename_label.setFont(QtGui.QFont('Timer', 13)) delete_action = QtWidgets.QAction('Delete row', self) delete_action.triggered.connect(self.delete_row) file_name_item = QtWidgets.QAction('Create alias name', self) file_name_item.triggered.connect( lambda: self.rename_dialog(type='alias_name')) alias_name_item = QtWidgets.QAction('Modify alias name', self) alias_name_item.triggered.connect( lambda: self.rename_dialog(type='modify_alias_name')) self.file_name_menu = QtWidgets.QMenu('Create alias name', self) self.file_name_menu.addAction(delete_action) self.file_name_menu.addAction(file_name_item) self.alias_name_menu = QtWidgets.QMenu('Modify alias name', self) self.alias_name_menu.addAction(delete_action) self.alias_name_menu.addAction(alias_name_item) self.rename_table = CustomTablewidget() self.rename_table.customDataChanged.connect(self.rename_command) self.rename_table.customContextMenuRequested.connect( self.set_item_menu) self.uploader_button = QtWidgets.QPushButton("Upload") self.uploader_button.setFont(QtGui.QFont('Timer', 13)) self.uploader_button.setMinimumHeight(40) self.uploader_button.setEnabled(False) self.uploader_button.clicked.connect(self.upload_button_command) self.copy_file_path_label = QtWidgets.QLabel("Copy reference to:") self.copy_file_path_edit = QtWidgets.QLineEdit() self.copy_file_path_edit.setText("") self.show_line_combox = QtWidgets.QComboBox() self.show_line_combox.setModel(self.model.show_model) self.show_line_combox.currentIndexChanged.connect( self.show_line_command) self.show_line_combox.setFixedWidth(90) self.mode_combo_box = QtWidgets.QComboBox() self.mode_combo_box.setModel(self.model.mode_model) self.mode_combo_box.currentIndexChanged.connect( self.mode_combo_box_command) self.path_edit = QtWidgets.QLineEdit() self.path_completer = QtWidgets.QCompleter() self.path_completer.setModel(self.model.path_model) self.path_edit.setCompleter(self.path_completer) self.path_edit.returnPressed.connect(self.path_completion) self.path_edit.setFixedWidth(300) self.path_edit.textChanged.connect(self.set_root_path) self.file_select = QtWidgets.QToolButton() self.file_select.setIcon(QtGui.QIcon(FILE_ICON)) self.file_select.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.file_select.clicked.connect(self.open_file_path) self.upload_type = QtWidgets.QComboBox() self.upload_type.setFixedWidth(95) self.upload_type.setModel(self.model.upload_type) self.upload_type.currentIndexChanged.connect(self.upload_type_command) show_mode_hbox = QtWidgets.QHBoxLayout() show_hbox = QtWidgets.QHBoxLayout() show_hbox.addWidget(show_label) show_hbox.addWidget(self.show_line_combox) show_hbox.addStretch(1) mode_hbox = QtWidgets.QHBoxLayout() mode_hbox.addWidget(mode_label) mode_hbox.addWidget(self.mode_combo_box) mode_hbox.addStretch(1) type_hbox = QtWidgets.QHBoxLayout() type_hbox.addWidget(upload_type) type_hbox.addWidget(self.upload_type) type_hbox.addStretch(1) show_mode_hbox.addLayout(show_hbox) show_mode_hbox.addLayout(mode_hbox) show_mode_hbox.addLayout(type_hbox) path_file_select_hbox = QtWidgets.QHBoxLayout() path_file_select_hbox.addWidget(self.path_label) path_file_select_hbox.addWidget(self.path_edit) path_file_select_hbox.addWidget(self.file_select) show_mode_hbox.addLayout(path_file_select_hbox) copy_path_hbox = QtWidgets.QHBoxLayout() copy_path_hbox.addWidget(self.copy_file_path_label) copy_path_hbox.addWidget(self.copy_file_path_edit) vbox = QtWidgets.QVBoxLayout() vbox.addLayout(show_mode_hbox) vbox.addSpacing(10) vbox.addLayout(copy_path_hbox) vbox.addSpacing(10) vbox.addWidget(self.tree_view) vbox.addWidget(rename_label, 0, QtCore.Qt.AlignCenter) vbox.addWidget(self.rename_table) self.attachment_widget = QtWidgets.QWidget() attachment_vbox = QtWidgets.QVBoxLayout() self.attachment_widget.setLayout(attachment_vbox) self.attachment_widget.setVisible(True) vbox.addWidget(self.attachment_widget) vbox.addWidget(self.uploader_button) self.setLayout(vbox) self.show_line_combox.currentIndexChanged.emit(0)