def setup_ui(self): self.l = l = QVBoxLayout(self) self.recipes = r = QTreeView(self) r.setAnimated(True) r.setHeaderHidden(True) self.model = ChooseBuiltinRecipeModel(self) self.model.setSourceModel(self.recipe_model) r.setModel(self.model) r.doubleClicked.connect(self.accept) self.search = s = SearchBox2(self) self.search.initialize('scheduler_search_history') self.search.setMinimumContentsLength(15) self.search.search.connect(self.recipe_model.search) self.recipe_model.searched.connect( self.search.search_done, type=Qt.ConnectionType.QueuedConnection) self.recipe_model.searched.connect(self.search_done) self.go_button = b = QToolButton(self) b.setText(_("Go")) b.clicked.connect(self.search.do_search) h = QHBoxLayout() h.addWidget(s), h.addWidget(b) l.addLayout(h) l.addWidget(self.recipes) l.addWidget(self.bb) self.search.setFocus(Qt.FocusReason.OtherFocusReason)
def __init__(self, parent=None): QWidget.__init__(self, parent) self._layout = l = QVBoxLayout(self) self.header = QLabel( _('Double click on any entry to change the' ' keyboard shortcuts associated with it')) l.addWidget(self.header) self.view = QTreeView(self) self.view.setAlternatingRowColors(True) self.view.setHeaderHidden(True) self.view.setAnimated(True) self.view.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.view.customContextMenuRequested.connect(self.show_context_menu) l.addWidget(self.view) self.delegate = Delegate() self.view.setItemDelegate(self.delegate) self.delegate.sizeHintChanged.connect( self.editor_opened, type=Qt.ConnectionType.QueuedConnection) self.delegate.changed_signal.connect(self.changed_signal) self.search = SearchBox2(self) self.search.initialize('shortcuts_search_history', help_text=_('Search for a shortcut by name')) self.search.search.connect(self.find) self._h = h = QHBoxLayout() l.addLayout(h) h.addWidget(self.search) self.nb = QPushButton(QIcon(I('arrow-down.png')), _('&Next'), self) self.pb = QPushButton(QIcon(I('arrow-up.png')), _('&Previous'), self) self.nb.clicked.connect(self.find_next) self.pb.clicked.connect(self.find_previous) h.addWidget(self.nb), h.addWidget(self.pb) h.setStretch(0, 100)