class LilyPondInfoDialog(KDialog): """ A dialog to edit attributes of a LilyPondInfo instance. """ def __init__(self, parent): KDialog.__init__(self, parent) self.setButtons(KDialog.ButtonCode(KDialog.Ok | KDialog.Cancel | KDialog.Help | KDialog.User1)) self.setCaption(i18n("LilyPond")) self.setHelp("settings-paths-lilypond") self.setButtonText(KDialog.User1, i18n("Download...")) self.setButtonIcon(KDialog.User1, KIcon("download")) self.setButtonToolTip(KDialog.User1, i18n("Download new binary LilyPond releases.")) self.user1Clicked.connect(self.downloadLilyPond) layout = QGridLayout(self.mainWidget()) l = QLabel(i18n("LilyPond Command:")) self.lilypond = KUrlRequester() l.setBuddy(self.lilypond) self.lilypond.lineEdit().setToolTip(i18n("Name or full path of the LilyPond program.")) self.lilypond.fileDialog().setCaption(i18n("LilyPond Command")) layout.addWidget(l, 0, 0, 1, 2) layout.addWidget(self.lilypond, 1, 0, 1, 2) self.commands = {} row = 2 for name, description in LilyPondInfo.commandNames(): l = QLabel(description) e = self.commands[name] = QLineEdit() l.setBuddy(e) layout.addWidget(l, row, 0, Qt.AlignRight) layout.addWidget(e, row, 1) row += 1 self.default = QCheckBox(i18n("Set as default")) layout.addWidget(self.default, row, 1) self.auto = QCheckBox(i18n("Include in automatic version selection")) layout.addWidget(self.auto, row + 1, 1) def loadInfo(self, info): """ Display the settings in the LilyPondInfo object in our dialog. """ self.lilypond.setText(info.lilypond) for name, value in info.commands.items(): self.commands[name].setText(value) self.default.setChecked(info.default) self.auto.setChecked(info.auto) def saveInfo(self, info): """ Write the settings in our dialog to the LilyPondInfo object. """ info.lilypond = self.lilypond.text() for name, widget in self.commands.items(): info.commands[name] = widget.text() info.default = self.default.isChecked() info.auto = self.auto.isChecked() def downloadLilyPond(self): from frescobaldi_app.download import LilyPondDownloadDialog LilyPondDownloadDialog(self).exec_()