📄 texteventdialog.cpp
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//* Rosegarden A MIDI and audio sequencer and musical notation editor. This program is Copyright 2000-2007 Guillaume Laurent <glaurent@telegraph-road.org>, Chris Cannam <cannam@all-day-breakfast.com>, Richard Bown <richard.bown@ferventsoftware.com> The moral rights of Guillaume Laurent, Chris Cannam, and Richard Bown to claim authorship of this work have been asserted. Other copyrights also apply to some parts of this work. Please see the AUTHORS file and individual file headers for details. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information.*/#include "TextEventDialog.h"#include <kapplication.h>#include <klocale.h>#include "misc/Strings.h"#include "document/ConfigGroups.h"#include "base/NotationTypes.h"#include "gui/editors/notation/NotePixmapFactory.h"#include <kcombobox.h>#include <kconfig.h>#include <kdialogbase.h>#include <qbitmap.h>#include <qgrid.h>#include <qgroupbox.h>#include <qlabel.h>#include <qlineedit.h>#include <qobject.h>#include <qpainter.h>#include <qpixmap.h>#include <qstring.h>#include <qvbox.h>#include <qwidget.h>#include <qspinbox.h>namespace Rosegarden{TextEventDialog::TextEventDialog(QWidget *parent, NotePixmapFactory *npf, Text defaultText, int maxLength) : KDialogBase(parent, 0, true, i18n("Text"), Ok | Cancel | Help), m_notePixmapFactory(npf), m_styles(Text::getUserStyles()) /*, //m_directives(Text::getLilypondDirectives()) */{ setHelp("nv-text"); QVBox *vbox = makeVBoxMainWidget(); QGroupBox *entryBox = new QGroupBox (1, Horizontal, i18n("Specification"), vbox); QGroupBox *exampleBox = new QGroupBox (1, Horizontal, i18n("Preview"), vbox); QGrid *entryGrid = new QGrid(2, QGrid::Horizontal, entryBox); new QLabel(i18n("Text: "), entryGrid); m_text = new QLineEdit(entryGrid); m_text->setText(strtoqstr(defaultText.getText())); if (maxLength > 0) m_text->setMaxLength(maxLength); // style combo new QLabel(i18n("Style: "), entryGrid); m_typeCombo = new KComboBox(entryGrid); for (unsigned int i = 0; i < m_styles.size(); ++i) { std::string style = m_styles[i]; // if the style is in this list, we can i18n it (kludgy): if (style == Text::Dynamic) { // index // m_typeCombo->insertItem(i18n("Dynamic")); // 0 } else if (style == Text::Direction) { m_typeCombo->insertItem(i18n("Direction")); // 1 } else if (style == Text::LocalDirection) { m_typeCombo->insertItem(i18n("Local Direction")); // 2 } else if (style == Text::Tempo) { m_typeCombo->insertItem(i18n("Tempo")); // 3 } else if (style == Text::LocalTempo) { m_typeCombo->insertItem(i18n("Local Tempo")); // 4 } else if (style == Text::Lyric) { m_typeCombo->insertItem(i18n("Lyric")); // 5 } else if (style == Text::Chord) { m_typeCombo->insertItem(i18n("Chord")); // 6 } else if (style == Text::Annotation) { m_typeCombo->insertItem(i18n("Annotation")); // 7 } else if (style == Text::LilypondDirective) { m_typeCombo->insertItem(i18n("LilyPond Directive")); // 8 } else { // not i18n()-able std::string styleName; styleName += (char)toupper(style[0]); styleName += style.substr(1); int uindex = styleName.find('_'); if (uindex > 0) { styleName = styleName.substr(0, uindex) + " " + styleName.substr(uindex + 1); } m_typeCombo->insertItem(strtoqstr(styleName)); } if (style == defaultText.getTextType()) { m_typeCombo->setCurrentItem(m_typeCombo->count() - 1); } } m_verseLabel = new QLabel(i18n("Verse: "), entryGrid); m_verseLabel->hide(); m_verseSpin = new QSpinBox(entryGrid); m_verseSpin->setMinValue(1); m_verseSpin->setMaxValue(12); m_verseSpin->setLineStep(1); m_verseSpin->setValue(defaultText.getVerse() + 1); m_verseSpin->hide(); // dynamic shortcuts combo m_dynamicShortcutLabel = new QLabel(i18n("Dynamic: "), entryGrid); m_dynamicShortcutLabel->hide(); m_dynamicShortcutCombo = new KComboBox(entryGrid); m_dynamicShortcutCombo->insertItem(i18n("ppp")); m_dynamicShortcutCombo->insertItem(i18n("pp")); m_dynamicShortcutCombo->insertItem(i18n("p")); m_dynamicShortcutCombo->insertItem(i18n("mp")); m_dynamicShortcutCombo->insertItem(i18n("mf")); m_dynamicShortcutCombo->insertItem(i18n("f")); m_dynamicShortcutCombo->insertItem(i18n("ff")); m_dynamicShortcutCombo->insertItem(i18n("fff")); m_dynamicShortcutCombo->insertItem(i18n("rfz")); m_dynamicShortcutCombo->insertItem(i18n("sf")); m_dynamicShortcutCombo->hide(); // direction shortcuts combo m_directionShortcutLabel = new QLabel(i18n("Direction: "), entryGrid); m_directionShortcutLabel->hide(); m_directionShortcutCombo = new KComboBox(entryGrid); // note, the " ," is a breath mark; the extra spaces are a cheap hack to // try to improve the probability of Rosegarden drawing the blasted thing // where it's supposed to go, without the need to micro-diddle each and // every bliffin' one. (Micro-diddling is not exportable to LilyPond // either, is it? I rather doubt it.) m_directionShortcutCombo->insertItem(i18n(" ,")); m_directionShortcutCombo->insertItem(i18n("D.C. al Fine")); m_directionShortcutCombo->insertItem(i18n("D.S. al Fine")); m_directionShortcutCombo->insertItem(i18n("Fine")); m_directionShortcutCombo->insertItem(i18n("D.S. al Coda")); m_directionShortcutCombo->insertItem(i18n("to Coda")); m_directionShortcutCombo->insertItem(i18n("Coda")); m_directionShortcutCombo->hide(); // local direction shortcuts combo m_localDirectionShortcutLabel = new QLabel(i18n("Local Direction: "), entryGrid); m_localDirectionShortcutLabel->hide(); m_localDirectionShortcutCombo = new KComboBox(entryGrid); m_localDirectionShortcutCombo->insertItem(i18n("accel.")); m_localDirectionShortcutCombo->insertItem(i18n("ritard.")); m_localDirectionShortcutCombo->insertItem(i18n("ralletando")); m_localDirectionShortcutCombo->insertItem(i18n("a tempo")); m_localDirectionShortcutCombo->insertItem(i18n("legato")); m_localDirectionShortcutCombo->insertItem(i18n("simile")); m_localDirectionShortcutCombo->insertItem(i18n("pizz.")); m_localDirectionShortcutCombo->insertItem(i18n("arco")); m_localDirectionShortcutCombo->insertItem(i18n("non vib.")); m_localDirectionShortcutCombo->insertItem(i18n("sul pont.")); m_localDirectionShortcutCombo->insertItem(i18n("sul tasto")); m_localDirectionShortcutCombo->insertItem(i18n("con legno")); m_localDirectionShortcutCombo->insertItem(i18n("sul tasto")); m_localDirectionShortcutCombo->insertItem(i18n("sul G")); m_localDirectionShortcutCombo->insertItem(i18n("ordinario")); m_localDirectionShortcutCombo->insertItem(i18n("Muta in ")); m_localDirectionShortcutCombo->insertItem(i18n("volti subito ")); m_localDirectionShortcutCombo->insertItem(i18n("soli")); m_localDirectionShortcutCombo->insertItem(i18n("div.")); m_localDirectionShortcutCombo->hide(); // tempo shortcuts combo m_tempoShortcutLabel = new QLabel(i18n("Tempo: "), entryGrid); m_tempoShortcutLabel->hide(); m_tempoShortcutCombo = new KComboBox(entryGrid); m_tempoShortcutCombo->insertItem(i18n("Grave")); m_tempoShortcutCombo->insertItem(i18n("Adagio")); m_tempoShortcutCombo->insertItem(i18n("Largo")); m_tempoShortcutCombo->insertItem(i18n("Lento")); m_tempoShortcutCombo->insertItem(i18n("Andante")); m_tempoShortcutCombo->insertItem(i18n("Moderato")); m_tempoShortcutCombo->insertItem(i18n("Allegretto")); m_tempoShortcutCombo->insertItem(i18n("Allegro")); m_tempoShortcutCombo->insertItem(i18n("Vivace")); m_tempoShortcutCombo->insertItem(i18n("Presto")); m_tempoShortcutCombo->insertItem(i18n("Prestissimo")); m_tempoShortcutCombo->insertItem(i18n("Maestoso")); m_tempoShortcutCombo->insertItem(i18n("Sostenuto")); m_tempoShortcutCombo->insertItem(i18n("Tempo Primo")); m_tempoShortcutCombo->hide(); // local tempo shortcuts combo (duplicates the non-local version, because // nobody is actually sure what is supposed to distinguish Tempo from // Local Tempo, or what this text style is supposed to be good for in the // way of standard notation) m_localTempoShortcutLabel = new QLabel(i18n("Local Tempo: "), entryGrid); m_localTempoShortcutLabel->hide(); m_localTempoShortcutCombo = new KComboBox(entryGrid); m_localTempoShortcutCombo->insertItem(i18n("Grave")); m_localTempoShortcutCombo->insertItem(i18n("Adagio")); m_localTempoShortcutCombo->insertItem(i18n("Largo")); m_localTempoShortcutCombo->insertItem(i18n("Lento")); m_localTempoShortcutCombo->insertItem(i18n("Andante")); m_localTempoShortcutCombo->insertItem(i18n("Moderato")); m_localTempoShortcutCombo->insertItem(i18n("Allegretto")); m_localTempoShortcutCombo->insertItem(i18n("Allegro")); m_localTempoShortcutCombo->insertItem(i18n("Vivace")); m_localTempoShortcutCombo->insertItem(i18n("Presto")); m_localTempoShortcutCombo->insertItem(i18n("Prestissimo")); m_localTempoShortcutCombo->insertItem(i18n("Maestoso")); m_localTempoShortcutCombo->insertItem(i18n("Sostenuto")); m_localTempoShortcutCombo->insertItem(i18n("Tempo Primo")); m_localTempoShortcutCombo->hide(); // Lilypond directive combo m_directiveLabel = new QLabel(i18n("Directive: "), entryGrid); m_directiveLabel->hide(); m_lilypondDirectiveCombo = new KComboBox(entryGrid); m_lilypondDirectiveCombo->hide(); // not i18nable, because the directive exporter currently depends on the // textual contents of these strings, not some more abstract associated // type label m_lilypondDirectiveCombo->insertItem(Text::Segno); m_lilypondDirectiveCombo->insertItem(Text::Coda); m_lilypondDirectiveCombo->insertItem(Text::Alternate1); m_lilypondDirectiveCombo->insertItem(Text::Alternate2); m_lilypondDirectiveCombo->insertItem(Text::BarDouble); m_lilypondDirectiveCombo->insertItem(Text::BarEnd); m_lilypondDirectiveCombo->insertItem(Text::BarDot); m_lilypondDirectiveCombo->insertItem(Text::Gliss); m_lilypondDirectiveCombo->insertItem(Text::Arpeggio); // m_lilypondDirectiveCombo->insertItem(Text::ArpeggioUp); // m_lilypondDirectiveCombo->insertItem(Text::ArpeggioDn); m_lilypondDirectiveCombo->insertItem(Text::Tiny); m_lilypondDirectiveCombo->insertItem(Text::Small); m_lilypondDirectiveCombo->insertItem(Text::NormalSize); QVBox *exampleVBox = new QVBox(exampleBox); int ls = m_notePixmapFactory->getLineSpacing(); int mapWidth = 200; QPixmap map(mapWidth, ls * 5 + 1); QBitmap mask(mapWidth, ls * 5 + 1); map.fill(); mask.fill(Qt::color0); QPainter p, pm; p.begin(&map); pm.begin(&mask); p.setPen(Qt::black); pm.setPen(Qt::white);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -