def __init__(self, manager): self.manager = manager KDialog.__init__(self, manager.mainwin) self.setCaption(i18n("Expansion Manager")) self.setButtons(KDialog.ButtonCode( KDialog.Help | KDialog.Ok | KDialog.Close | KDialog.User1 | KDialog.User2 )) self.setButtonGuiItem(KDialog.User1, KStandardGuiItem.remove()) self.setButtonGuiItem(KDialog.User2, KStandardGuiItem.add()) self.setHelp("expand") layout = QVBoxLayout(self.mainWidget()) layout.setContentsMargins(0, 0, 0, 0) search = KTreeWidgetSearchLine() search.setClickMessage(i18n("Search...")) layout.addWidget(search) splitter = QSplitter() splitter.setOrientation(Qt.Vertical) layout.addWidget(splitter) tree = QTreeWidget() tree.setColumnCount(3) tree.setHeaderLabels((i18n("Name"), i18n("Description"), i18n("Shortcut"))) tree.setRootIsDecorated(False) tree.setAllColumnsShowFocus(True) search.setTreeWidget(tree) splitter.addWidget(tree) box = KVBox() splitter.addWidget(box) key = KKeySequenceWidget(box) key.layout().setContentsMargins(0, 0, 0, 0) key.layout().insertStretch(0, 1) key.setEnabled(False) edit = QTextEdit(box) edit.setAcceptRichText(False) edit.setStyleSheet("QTextEdit { font-family: monospace; }") edit.item = None edit.dirty = False ExpandHighlighter(edit.document()) # whats this etc. tree.setWhatsThis(i18n( "This is the list of defined expansions.\n\n" "Click on a row to see or change the associated text. " "Doubleclick a shortcut or its description to change it. " "You can also press F2 to edit the current shortcut.\n\n" "Use the buttons below to add or remove expansions.\n\n" "There are two ways to use the expansion: either type the " "shortcut in the text and then call the Expand function, or " "just call the Expand function (default shortcut: Ctrl+.), " "choose the expansion from the list and press Enter or click Ok." )) edit.setWhatsThis( "<html><head><style type='text/css'>" "td.short {{ font-family: monospace; font-weight: bold; }}" "</style></head><body>" "<p>{0}</p><table border=0 width=300 cellspacing=2><tbody>" "<tr><td class=short align=center>(|)</td><td>{1}</td></tr>" "<tr><td class=short align=center>@</td><td>{2}</td></tr>" "</tbody></table></body></html>".format( i18n("This is the text associated with the selected shortcut. " "Some characters have special meaning:"), i18n("Place the cursor on this spot."), i18n("Translate the following pitch."), )) self.searchLine = search self.treeWidget = tree self.key = key self.edit = edit self.restoreDialogSize(config()) # load the expansions for name in sorted(self.manager.expansionsList()): self.createItem(name, self.manager.description(name)) tree.sortByColumn(1, Qt.AscendingOrder) tree.setSortingEnabled(True) tree.resizeColumnToContents(1) self.user1Clicked.connect(self.removeItem) self.user2Clicked.connect(self.addItem) edit.textChanged.connect(self.editChanged) search.textChanged.connect(self.checkMatch) tree.itemSelectionChanged.connect(self.updateSelection) tree.itemChanged.connect(self.itemChanged, Qt.QueuedConnection) key.keySequenceChanged.connect(self.keySequenceChanged)