def __createOptionsWidget(self): menu = qt.QMenu(self) # Load peak selection as file loadPeaksFromFile = qt.QAction(self) icon = icons.getQIcon('document-open') loadPeaksFromFile.setIcon(icon) loadPeaksFromFile.setText("Load peak selection from file") loadPeaksFromFile.triggered.connect(self.__loadPeaksFromFile) loadPeaksFromFile.setIconVisibleInMenu(True) menu.addAction(loadPeaksFromFile) # Save peak selection as file savePeaksAsFile = qt.QAction(self) icon = icons.getQIcon('document-save') savePeaksAsFile.setIcon(icon) savePeaksAsFile.setText("Save peak selection as file") savePeaksAsFile.triggered.connect(self.__savePeaksAsFile) savePeaksAsFile.setIconVisibleInMenu(True) menu.addAction(savePeaksAsFile) options = qt.QToolButton(self) icon = icons.getQIcon('options') options.setIcon(icon) options.setPopupMode(qt.QToolButton.InstantPopup) options.setMenu(menu) return options
def createEditor(self, parent, option, index): if not index.isValid(): return super(_PeakToolItemDelegate, self).createEditor(parent, option, index) editor = qt.QToolBar(parent=parent) editor.setIconSize(qt.QSize(32, 32)) editor.setStyleSheet("QToolBar { border: 0px }") editor.setMinimumSize(32, 32) editor.setMaximumSize(32, 32) editor.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed) remove = qt.QAction(editor) remove.setIcon(icons.getQIcon("remove-peak")) remove._customSignal = None persistantIndex = qt.QPersistentModelIndex(index) remove.triggered.connect(functools.partial(self.__removePeak, persistantIndex)) editor.addAction(remove) return editor