def loadCompletions(self): """ Loads the completion data from the config. """ conf = config("scorewiz completion") for w in self.completableWidgets: compObj, name = w.completionObject(), str(w.name()) compObj.setOrder(KCompletion.Sorted) compObj.setItems(py2qstringlist(conf.get(name, '').splitlines()))
def setLanguage(self, lang): lang = unicode(lang).lower() # can be QString if lang not in keyNames: lang = 'nederlands' index = self.key.currentItem() self.key.clear() self.key.insertStringList(py2qstringlist(keyNames[lang])) self.key.setCurrentItem(index)
def askLanguage(): """ Ask the user which language to use. Returns None if the user cancels the dialog. """ conf = config("hyphenation") lang = conf["lastused"] or "" langs = list(sorted(hyphdicts.keys())) index = lang in langs and langs.index(lang) or 0 lang, ok = KInputDialog.getItem( _("Language selection"), _("Please select a language:"), py2qstringlist(langs), index, False, editor.topLevelWidget() ) if ok: lang = unicode(lang) conf["lastused"] = lang return lang
def __init__(self, parent): QDialog.__init__(self, parent) self.setCaption(_("Rumor Settings")) layout = QGridLayout(self, 8, 2, 8, 4) # MIDI input and output. # Get the list of available OSS and ALSA devices oslist = [('oss:%d' % i, _("OSS device %d") % i ) for i in range(getOSSnrMIDIs())] i = oslist + parseAconnect('i') + [("keyboard", _("Keyboard"))] o = oslist + parseAconnect('o') self.ilist, ititles = map(list, zip(*i)) self.olist, otitles = map(list, zip(*o)) # input layout.addWidget(QLabel(_("MIDI input:"), self), 1, 0) self.ibut = QComboBox(self) self.ibut.insertStringList(py2qstringlist(ititles)) QToolTip.add(self.ibut, _("MIDI input to use. Choose 'Keyboard' if " "you want to play on the keyboard of your computer.")) layout.addWidget(self.ibut, 1, 1) # output layout.addWidget(QLabel(_("MIDI output:"), self), 2, 0) self.obut = QComboBox(self) self.obut.insertStringList(py2qstringlist(otitles)) QToolTip.add(self.obut, _("MIDI output to use.")) layout.addWidget(self.obut, 2, 1) # Language layout.addWidget(QLabel(_("Language:"), self), 3, 0) self.lang = QComboBox(self) self.lang.insertStringList(py2qstringlist(( AUTO, 'ne', 'en', 'en-short', 'de', 'no', 'sv', 'it', 'ca', 'es'))) QToolTip.add(self.lang, _("The LilyPond language you want Rumor to " "output the pitches in.")) layout.addWidget(self.lang, 3, 1) hb = QHBoxLayout() layout.addMultiCellLayout(hb, 4, 4, 0, 1) # explicit durations self.explDur = QCheckBox(_("Explicit durations"), self) QToolTip.add(self.explDur, _( "Add a duration after every note, even if it is the same as the " "preceding note.")) hb.addWidget(self.explDur) # absolute pitches self.absPitches = QCheckBox(_("Absolute pitch"), self) QToolTip.add(self.absPitches, _( "Use absolute pitches instead of relative.")) hb.addWidget(self.absPitches) hb = QHBoxLayout() layout.addMultiCellLayout(hb, 5, 5, 0, 1) # No Barlines self.noBar = QCheckBox(_("No barlines"), self) QToolTip.add(self.noBar, _( "Filter the barlines out of Rumor's output.")) hb.addWidget(self.noBar) # No dots self.noDots = QCheckBox(_("No dots"), self) QToolTip.add(self.noDots, _( "Do not use dotted notes, but ties instead.")) hb.addWidget(self.noDots) # Legato self.legato = QCheckBox(_("Legato"), self) QToolTip.add(self.legato, _("Do not use rests, but give all notes " "the maximum length.")) hb.addWidget(self.legato) # Strip rests self.stripRests = QCheckBox(_("Strip rests"), self) QToolTip.add(self.stripRests, _( "Strip leading and trialing rests from output.")) hb.addWidget(self.stripRests) layout.addMultiCellWidget(QLabel(_( "Guile scripts to load:"), self), 6, 6, 0, 1) # Guile scripts listview self.scripts = QListView(self) self.scripts.addColumn(_("Name")) self.scripts.addColumn(_("Description")) QToolTip.add(self.scripts, _( "Here you can select which Guile scripts you want Rumor to load. " "Check \"What's this\" for more information.")) QWhatsThis.add(self.scripts, _( "Here you can select which Guile scripts you want Rumor to load. " "You can add your own scripts by putting them in %s. " "If the first line of your script starts with a semicolon (;) " "that line will be shown as description.") % "~/.kde/share/apps/lilykde/rumor/") layout.addMultiCellWidget(self.scripts, 7, 7, 0, 1) # Ok, Cancel hb = QHBoxLayout() layout.addLayout(hb, 8,1) ok = KPushButton(KStdGuiItem.ok(), self) can = KPushButton(KStdGuiItem.cancel(), self) QObject.connect(ok, SIGNAL("clicked()"), self.accept) QObject.connect(can, SIGNAL("clicked()"), self.reject) hb.addWidget(ok) hb.addWidget(can) self.loadSettings() self.exec_loop()
def __init__(self, *args): QFrame.__init__(self, *args) # Accept keyboard focus self.setFocusPolicy(QWidget.ClickFocus) layout = QGridLayout(self, 4, 5, 4) layout.setColStretch(4, 1) # Big Start/stop toggle button self.r = RumorButton(self) layout.addMultiCellWidget(self.r, 0, 3, 0, 0) # labels for other controls: layout.addWidget(QLabel(_("Tempo:"), self), 0, 1) layout.addWidget(QLabel(_("Meter:"), self), 1, 1) layout.addWidget(QLabel(_("Key:"), self), 2, 1) # Status line self.status = QStatusBar(self) self.status.setSizeGripEnabled(False) layout.addMultiCellWidget(self.status, 3, 3, 1, 4) # Tempo adjustment (spinbox + long slider) self.tempo = TempoControl(self) layout.addWidget(self.tempo.spinbox, 0, 2) hb = QHBoxLayout() layout.addLayout(hb, 0, 3) hb.addWidget(self.tempo.tapButton) hb.addWidget(self.tempo.slider) # Meter select (editable qcombobox defaulting to document) self.meter = QComboBox(self) self.meter.setEditable(True) self.meter.insertStringList(py2qstringlist([ AUTO, '1/4', '2/4', '3/4', '4/4', '5/4', '6/4', '2/2', '3/2', '3/8', '6/8', '9/8', '12/8', '3/16', ])) self.meter.setValidator(QRegExpValidator(QRegExp( re.escape(AUTO) + "|[1-9][0-9]*/(1|2|4|8|16|32|64|128)"), self.meter)) QToolTip.add(self.meter, _( "The meter to use. Leave 'Auto' to let LilyKDE determine " "the meter from the LilyPond document.")) layout.addWidget(self.meter, 1, 2) # Quantize (1,2,4,8,16,32,64 or 128, default to 16) hb = QHBoxLayout() layout.addLayout(hb, 1, 3) hb.addWidget(QLabel(_("Quantize:"), self)) self.quantize = QComboBox(self) self.quantize.insertStringList(py2qstringlist( str(2**i) for i in range(8))) QToolTip.add(self.quantize, _( "The shortest note duration to use.")) hb.addWidget(self.quantize) # Step recording: (checkbox, disables the three controls above) self.step = QCheckBox(_("Step"), self) QToolTip.add(self.step, _( "Record LilyPond input note by note, without durations.")) hb.addWidget(self.step) # Monophonic input (no chords) self.mono = QCheckBox(_("Mono"), self) QToolTip.add(self.mono, _( "Record monophonic input, without chords.")) hb.addWidget(self.mono) # Key signature select (any lilypond pitch, defaulting to document) self.keysig = QComboBox(self) self.keysig.insertItem(AUTO) self.keysig.insertStringList(py2qstringlist( "%d" % i for i in range(-7, 1))) self.keysig.insertStringList(py2qstringlist( "%+d" % i for i in range(1, 8))) QToolTip.add(self.keysig, _( "The number of accidentals. A negative number designates flats. " "Leave 'Auto' to let LilyKDE determine the key signature from " "the LilyPond document.")) layout.addWidget(self.keysig, 2, 2) hb = QHBoxLayout() layout.addLayout(hb, 2, 3) # Timidity button self.timidity = TimidityButton(self) hb.addWidget(self.timidity) # Button 'More Settings' sb = QPushButton(_("Configure..."), self) QToolTip.add(sb, _("Adjust more settings, like MIDI input and output.")) QObject.connect(sb, SIGNAL("clicked()"), lambda: RumorSettings(self)) hb.addWidget(sb) # Save Button sb = QPushButton(_("Save"), self) QToolTip.add(sb, _("Set these settings as default.")) QObject.connect(sb, SIGNAL("clicked()"), self.saveSettings) hb.addWidget(sb) self.loadSettings() # display Rumor version on first start. cmd = config("commands").get("rumor", "rumor") try: v = Popen([cmd, '--version'], stdout=PIPE).communicate()[0].strip() self.status.message(_("Found rumor version $version.").args( version = v), 5000) except OSError, e: self.status.message(_("Could not find Rumor: %s") % e, 10000)
def __init__(self, parent): self.p = parent.addPage(_("Score settings")) score = QVGroupBox(_("Score settings"), self.p) lily = QVGroupBox(_("LilyPond"), self.p) prefs = QVGroupBox(_("General preferences"), self.p) instr = QVGroupBox(_("Instrument names"), self.p) h = QHBoxLayout(self.p) # first column of group boxes: v = QVBoxLayout() h.addLayout(v) v.addWidget(score) v.addSpacing(4) v.addWidget(lily) h.addSpacing(8) # second column of group boxes: v = QVBoxLayout() h.addLayout(v) v.addWidget(prefs) v.addSpacing(2) v.addWidget(instr) conf = config("scorewiz") # Score settings h = QHBox(score) h.setSpacing(2) l = QLabel(_("Key signature:"), h) self.key = QComboBox(False, h) # the key names are filled in later self.mode = QComboBox(False, h) self.mode.insertStringList(py2qstringlist(t for n, t in modes)) l.setBuddy(self.key) h = QHBox(score) h.setSpacing(2) l = QLabel(_("Time signature:"), h) self.time = QComboBox(True, h) self.time.insertItem(QPixmap.fromMimeSource('c44.png'), '(4/4)') self.time.insertItem(QPixmap.fromMimeSource('c22.png'), '(2/2)') self.time.insertStringList(py2qstringlist(( '2/4', '3/4', '4/4', '5/4', '6/4', '7/4', '2/2', '3/2', '4/2', '3/8', '5/8', '6/8', '7/8', '8/8', '9/8', '12/8', '3/16', '6/16', '12/16'))) l.setBuddy(self.time) h = QHBox(score) h.setSpacing(2) l = QLabel(_("Pickup measure:"), h) self.pickup = QComboBox(False, h) self.pickup.setMinimumHeight(24) self.pickup.insertItem(_("None")) pix = [QPixmap.fromMimeSource('note_%s.png' % d.replace('.', 'd')) for d in durations] for p in pix: self.pickup.insertItem(p) l.setBuddy(self.pickup) h = QHBox(score) h.setSpacing(2) l = QLabel(_("Metronome mark:"), h) self.metroDur = QComboBox(False, h) self.metroDur.setMinimumHeight(24) l.setBuddy(self.metroDur) for d in pix: self.metroDur.insertItem(d) self.metroDur.setCurrentItem(durations.index('4')) l = QLabel('=', h) l.setMaximumWidth(12) self.metroVal = QComboBox(True, h) metroValues, start = [], 40 for end, step in (60, 2), (72, 3), (120, 4), (144, 6), (210, 8): metroValues.extend(range(start, end, step)) start = end # reverse so mousewheeling is more intuitive self.metroValues = metroValues[::-1] self.metroVal.insertStringList(py2qstringlist(map(str, self.metroValues))) self.metroVal.setCurrentText('100') tap = TapButton(h, self.tap) h = QHBox(score) h.setSpacing(2) l = QLabel(_("Tempo indication:"), h) self.tempoInd = KLineEdit(h, "tempo") parent.complete(self.tempoInd) l.setBuddy(self.tempoInd) QToolTip.add(h, _("A tempo indication, e.g. \"Allegro.\"")) # LilyPond settings h = QHBox(lily) h.setSpacing(2) l = QLabel(_("Language:"), h) self.lylang = QComboBox(False, h) l.setBuddy(self.lylang) self.lylang.insertItem(_("Default")) self.lylang.insertStringList(py2qstringlist( l.title() for l in sorted(keyNames))) QToolTip.add(h, _( "The LilyPond language you want to use for the pitch names.")) QObject.connect(self.lylang, SIGNAL("activated(const QString&)"), self.setLanguage) lang = conf.get('language') if lang in keyNames: self.lylang.setCurrentText(lang.title()) self.setLanguage(lang) h = QHBox(lily) h.setSpacing(2) l = QLabel(_("Version:"), h) self.lyversion = QComboBox(True, h) l.setBuddy(self.lyversion) from lilykde.version import version try: self.lyversion.insertItem("%d.%d.%d" % version) except: pass self.lyversion.insertStringList(py2qstringlist(('2.10.0', '2.11.0'))) QToolTip.add(h, _( "The LilyPond version you will be using for this document.")) # General preferences self.typq = QCheckBox(_("Use typographical quotes"), prefs) QToolTip.add(self.typq, _( "Replace normal quotes in titles with nice typographical quotes.")) self.typq.setChecked(conf['typographical'] == '1') self.tagl = QCheckBox(_("Remove default tagline"), prefs) QToolTip.add(self.tagl, _( "Suppress the default tagline output by LilyPond.")) self.tagl.setChecked(conf['remove tagline'] == '1') self.barnum = QCheckBox(_("Remove bar numbers"), prefs) QToolTip.add(self.barnum, _( "Suppress the display of measure numbers at the beginning of " "every system.")) self.barnum.setChecked(conf['remove barnumbers'] == '1') self.midi = QCheckBox(_("Create MIDI output"), prefs) QToolTip.add(self.midi, _( "Create a MIDI file in addition to the PDF file.")) self.midi.setChecked(conf['midi'] == '1') self.metro = QCheckBox(_("Show metronome mark"), prefs) QToolTip.add(self.metro, _( "If checked, show the metronome mark at the beginning of the " "score. The MIDI output also uses the metronome setting.")) self.metro.setChecked(conf['metronome mark'] == '1') # paper size: paperSizes = ('a3', 'a4', 'a5', 'a6', 'a7', 'legal', 'letter', '11x17') h = QHBox(prefs) h.setSpacing(2) l = QLabel(_("Paper size:"), h) self.paper = QComboBox(False, h) l.setBuddy(self.paper) self.paperLandscape = QCheckBox(_("Landscape"), h) self.paper.insertItem(_("Default")) for i in paperSizes: self.paper.insertItem(i) t = conf['paper size'] if t in paperSizes: self.paper.setCurrentText(t) self.paperLandscape.setChecked(conf['paper landscape'] == '1') self.paperLandscape.setEnabled(t in paperSizes) QObject.connect(self.paper, SIGNAL("activated(int)"), lambda i: self.paperLandscape.setEnabled(bool(i))) # Instrument names instr.setCheckable(True) self.instr = instr h = QHBox(instr) h.setSpacing(2) l = QLabel(_("First system:"), h) self.instrFirst = QComboBox(False, h) l.setBuddy(self.instrFirst) for i in _("Short"), _("Long"): self.instrFirst.insertItem(i) QToolTip.add(h, _( "Use long or short instrument names before the first system.")) h = QHBox(instr) h.setSpacing(2) l = QLabel(_("Other systems:"), h) self.instrOther = QComboBox(False, h) l.setBuddy(self.instrOther) for i in _("None"), _("Short"), _("Long"): self.instrOther.insertItem(i) QToolTip.add(h, _( "Use no, short or long instrument names before the next systems.")) self.instrIt = QCheckBox(_("Italian names"), instr) QToolTip.add(self.instrIt, _( "Choose standard Italian instrument names, like '%s' " "instead of 'Organ.'") % 'Organo') try: self.instrFirst.setCurrentItem( ['short', 'long'].index(conf.get( 'instrument names first system', 'short'))) except: pass try: self.instrOther.setCurrentItem( ['none', 'short', 'long'].index(conf.get( 'instrument names other systems', 'none'))) except: pass self.instrIt.setChecked(conf['instrument names italian'] == '1') self.instr.setChecked(conf['instrument names'] == '1')