1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
/* -*- 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-2008
Guillaume Laurent <[email protected]>,
Chris Cannam <[email protected]>,
Richard Bown <[email protected]>
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 "LilyPondOptionsDialog.h"
#include "document/io/LilyPondExporter.h"
#include "gui/configuration/HeadersConfigurationPage.h"
#include <tqlayout.h>
#include <kapplication.h>
#include "document/ConfigGroups.h"
#include "document/RosegardenGUIDoc.h"
#include "misc/Strings.h"
#include <kcombobox.h>
#include <klineedit.h>
#include <kconfig.h>
#include <kdialogbase.h>
#include <kglobal.h>
#include <klocale.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqframe.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqstring.h>
#include <tqtabwidget.h>
#include <tqtooltip.h>
#include <tqvbox.h>
#include <tqwidget.h>
#include <iostream>
namespace Rosegarden
{
LilyPondOptionsDialog::LilyPondOptionsDialog(TQWidget *parent,
RosegardenGUIDoc *doc,
TQString windowCaption,
TQString heading) :
KDialogBase(parent, 0, true,
(windowCaption = "" ? i18n("LilyPond Export/Preview") : windowCaption),
Apply | Ok | Cancel),
m_doc(doc)
{
setHelp("file-printing");
KConfig *config = kapp->config();
config->setGroup(NotationViewConfigGroup);
TQVBox * mainbox = makeVBoxMainWidget();
//
// Arrange options in "General" and "Advanced" tabs.
//
TQTabWidget * tabWidget = new TQTabWidget(mainbox);
TQFrame *generalFrame;
TQFrame *advancedFrame;
TQGridLayout *generalGrid;
TQGridLayout *advancedGrid;
generalFrame = new TQFrame();
tabWidget->addTab(generalFrame, i18n("General options"));
generalGrid = new TQGridLayout(generalFrame, 1, 1, 5, 5);
advancedFrame = new TQFrame();
tabWidget->addTab(advancedFrame, i18n("Advanced options"));
advancedGrid = new TQGridLayout(advancedFrame, 1, 1, 5, 5);
m_headersPage = new HeadersConfigurationPage(this, m_doc);
tabWidget->addTab(m_headersPage, i18n("Headers"));
m_headersPage->setSpacing(5);
m_headersPage->setMargin(5);
//
// LilyPond export: Basic options
//
TQGroupBox *basicOptionsBox = new TQGroupBox
(1, Qt::Horizontal,
i18n("Basic options"), generalFrame);
generalGrid->addWidget(basicOptionsBox, 0, 0);
TQFrame *frameBasic = new TQFrame(basicOptionsBox);
TQGridLayout *layoutBasic = new TQGridLayout(frameBasic, 3, 2, 10, 5);
layoutBasic->addWidget(new TQLabel(
i18n("Compatibility level"), frameBasic), 0, 0);
m_lilyLanguage = new KComboBox(frameBasic);
// See also setDefaultLilyPondVersion below
m_lilyLanguage->insertItem(i18n("LilyPond %1").tqarg("2.6"));
m_lilyLanguage->insertItem(i18n("LilyPond %1").tqarg("2.8"));
m_lilyLanguage->insertItem(i18n("LilyPond %1").tqarg("2.10"));
m_lilyLanguage->insertItem(i18n("LilyPond %1").tqarg("2.12"));
m_lilyLanguage->setCurrentItem(config->readUnsignedNumEntry("lilylanguage", 0));
layoutBasic->addWidget(m_lilyLanguage, 0, 1);
layoutBasic->addWidget(new TQLabel(
i18n("Paper size"), frameBasic), 1, 0);
TQHBoxLayout *hboxPaper = new TQHBoxLayout( frameBasic );
m_lilyPaperSize = new KComboBox(frameBasic);
m_lilyPaperSize->insertItem(i18n("A3"));
m_lilyPaperSize->insertItem(i18n("A4"));
m_lilyPaperSize->insertItem(i18n("A5"));
m_lilyPaperSize->insertItem(i18n("A6"));
m_lilyPaperSize->insertItem(i18n("Legal"));
m_lilyPaperSize->insertItem(i18n("US Letter"));
m_lilyPaperSize->insertItem(i18n("Tabloid"));
m_lilyPaperSize->insertItem(i18n("do not specify"));
int defaultPaperSize = 1; // A4
if (KGlobal::locale()->country() == "us" ||
KGlobal::locale()->country() == "US") defaultPaperSize = 5; // Letter
m_lilyPaperSize->setCurrentItem(config->readUnsignedNumEntry
("lilypapersize", defaultPaperSize));
m_lilyPaperLandscape = new TQCheckBox(i18n("Landscape"), frameBasic);
m_lilyPaperLandscape->setChecked(config->readBoolEntry("lilypaperlandscape", false));
hboxPaper->addWidget( m_lilyPaperSize );
hboxPaper->addWidget( new TQLabel( " ", frameBasic ) ); // fixed-size spacer
hboxPaper->addWidget( m_lilyPaperLandscape );
layoutBasic->addLayout(hboxPaper, 1, 1);
layoutBasic->addWidget(new TQLabel(
i18n("Font size"), frameBasic), 2, 0);
m_lilyFontSize = new KComboBox(frameBasic);
int sizes[] = { 11, 13, 16, 19, 20, 23, 26 };
for (int i = 0; i < sizeof(sizes)/sizeof(sizes[0]); ++i) {
m_lilyFontSize->insertItem(i18n("%1 pt").tqarg(sizes[i]));
}
m_lilyFontSize->setCurrentItem(config->readUnsignedNumEntry
("lilyfontsize", 4));
layoutBasic->addWidget(m_lilyFontSize, 2, 1);
//
// LilyPond export: Staff level options
//
TQGroupBox *staffOptionsBox = new TQGroupBox
(1, Qt::Horizontal,
i18n("Staff level options"), generalFrame);
generalGrid->addWidget(staffOptionsBox, 1, 0);
TQFrame *frameStaff = new TQFrame(staffOptionsBox);
TQGridLayout *layoutStaff = new TQGridLayout(frameStaff, 2, 2, 10, 5);
layoutStaff->addWidget(new TQLabel(
i18n("Export content"), frameStaff), 0, 0);
m_lilyExportSelection = new KComboBox(frameStaff);
m_lilyExportSelection->insertItem(i18n("All tracks"));
m_lilyExportSelection->insertItem(i18n("Non-muted tracks"));
m_lilyExportSelection->insertItem(i18n("Selected track"));
m_lilyExportSelection->insertItem(i18n("Selected segments"));
m_lilyExportSelection->setCurrentItem(config->readUnsignedNumEntry("lilyexportselection", 1));
layoutStaff->addWidget(m_lilyExportSelection, 0, 1);
m_lilyExportStaffMerge = new TQCheckBox(
i18n("Merge tracks that have the same name"), frameStaff);
m_lilyExportStaffMerge->setChecked(config->readBoolEntry("lilyexportstaffmerge", false));
layoutStaff->addMultiCellWidget(m_lilyExportStaffMerge, 1, 1, 0, 1);
//
// LilyPond export: Notation options
//
TQGroupBox *notationOptionsBox = new TQGroupBox
(1, Qt::Horizontal,
i18n("Notation options"), generalFrame);
generalGrid->addWidget(notationOptionsBox, 2, 0);
TQFrame *frameNotation = new TQFrame(notationOptionsBox);
TQGridLayout *layoutNotation = new TQGridLayout(frameNotation, 4, 2, 10, 5);
m_lilyTempoMarks = new KComboBox( frameNotation );
m_lilyTempoMarks->insertItem(i18n("None"));
m_lilyTempoMarks->insertItem(i18n("First"));
m_lilyTempoMarks->insertItem(i18n("All"));
m_lilyTempoMarks->setCurrentItem(config->readUnsignedNumEntry("lilyexporttempomarks", 0));
layoutNotation->addWidget( new TQLabel(
i18n("Export tempo marks "), frameNotation), 0, 0 );
layoutNotation->addWidget(m_lilyTempoMarks, 0, 1);
m_lilyExportLyrics = new TQCheckBox(
i18n("Export lyrics"), frameNotation);
// default to lyric export == false because if you export the default
// empty "- - -" lyrics, crap results ensue, and people will know if they
// do need to export the lyrics - DMM
// fixed, no "- - -" lyrics are generated for an empty lyrics
// default again into lyrics - HJJ
m_lilyExportLyrics->setChecked(config->readBoolEntry("lilyexportlyrics", true));
layoutNotation->addMultiCellWidget(m_lilyExportLyrics, 1, 1, 0, 1);
m_lilyExportBeams = new TQCheckBox(
i18n("Export beamings"), frameNotation);
m_lilyExportBeams->setChecked(config->readBoolEntry("lilyexportbeamings", false));
layoutNotation->addMultiCellWidget(m_lilyExportBeams, 2, 2, 0, 1);
// recycle this for a new option to ignore the track brackets (so it is less
// obnoxious to print single parts where brackets are in place)
m_lilyExportStaffGroup = new TQCheckBox(
i18n("Export track staff brackets"), frameNotation);
m_lilyExportStaffGroup->setChecked(config->readBoolEntry("lilyexportstaffbrackets", true));
layoutNotation->addMultiCellWidget(m_lilyExportStaffGroup, 3, 3, 0, 1);
generalGrid->setRowStretch(4, 10);
//
// LilyPond export: Advanced options
//
TQGroupBox *advancedLayoutOptionsBox = new TQGroupBox
(1, Qt::Horizontal,
i18n("Layout options"), advancedFrame);
advancedGrid->addWidget(advancedLayoutOptionsBox, 0, 0);
TQFrame *frameAdvancedLayout = new TQFrame(advancedLayoutOptionsBox);
TQGridLayout *layoutAdvancedLayout = new TQGridLayout(frameAdvancedLayout, 2, 2, 10, 5);
m_lilyLyricsHAlignment = new KComboBox( frameAdvancedLayout );
m_lilyLyricsHAlignment->insertItem(i18n("Left"));
m_lilyLyricsHAlignment->insertItem(i18n("Center"));
m_lilyLyricsHAlignment->insertItem(i18n("Right"));
m_lilyLyricsHAlignment->setCurrentItem(config->readUnsignedNumEntry("lilylyricshtqalignment", 0));
layoutAdvancedLayout->addWidget(new TQLabel(
i18n("Lyrics tqalignment"), frameAdvancedLayout), 0, 0);
layoutAdvancedLayout->addWidget(m_lilyLyricsHAlignment, 0, 1);
m_lilyRaggedBottom = new TQCheckBox(
i18n("Ragged bottom (systems will not be spread vertically across the page)"), frameAdvancedLayout);
m_lilyRaggedBottom->setChecked(config->readBoolEntry("lilyraggedbottom", false));
layoutAdvancedLayout->addMultiCellWidget(m_lilyRaggedBottom, 1, 2, 0, 1);
TQGroupBox *miscOptionsBox = new TQGroupBox
(1, Qt::Horizontal,
i18n("Miscellaneous options"), advancedFrame);
advancedGrid->addWidget(miscOptionsBox, 1, 0);
TQFrame *frameMisc = new TQFrame(miscOptionsBox);
TQGridLayout *layoutMisc = new TQGridLayout(frameMisc, 2, 2, 10, 5);
m_lilyExportPointAndClick = new TQCheckBox(
i18n("Enable \"point and click\" debugging"), frameMisc);
m_lilyExportPointAndClick->setChecked(config->readBoolEntry("lilyexportpointandclick", false));
layoutMisc->addMultiCellWidget(m_lilyExportPointAndClick, 0, 0, 0, 1);
m_lilyExportMidi = new TQCheckBox(
i18n("Export \\midi block"), frameMisc);
m_lilyExportMidi->setChecked(config->readBoolEntry("lilyexportmidi", false));
layoutMisc->addMultiCellWidget(m_lilyExportMidi, 1, 1, 0, 1);
m_lilyMarkerMode = new KComboBox(frameMisc);
m_lilyMarkerMode->insertItem(i18n("No markers"));
m_lilyMarkerMode->insertItem(i18n("Rehearsal marks"));
m_lilyMarkerMode->insertItem(i18n("Marker text"));
m_lilyMarkerMode->setCurrentItem(config->readUnsignedNumEntry("lilyexportmarkermode", 0));
layoutMisc->addWidget( new TQLabel(
i18n("Export markers"), frameMisc),2, 0 );
layoutMisc->addWidget(m_lilyMarkerMode, 2, 1);
advancedGrid->setRowStretch(2, 10);
resize(tqminimumSize());
}
void
LilyPondOptionsDialog::slotApply()
{
KConfig *config = kapp->config();
config->setGroup(NotationViewConfigGroup);
config->writeEntry("lilylanguage", m_lilyLanguage->currentItem());
config->writeEntry("lilypapersize", m_lilyPaperSize->currentItem());
config->writeEntry("lilypaperlandscape", m_lilyPaperLandscape->isChecked());
config->writeEntry("lilyfontsize", m_lilyFontSize->currentItem());
config->writeEntry("lilyraggedbottom", m_lilyRaggedBottom->isChecked());
config->writeEntry("lilyexportlyrics", m_lilyExportLyrics->isChecked());
config->writeEntry("lilyexportmidi", m_lilyExportMidi->isChecked());
config->writeEntry("lilyexporttempomarks", m_lilyTempoMarks->currentItem());
config->writeEntry("lilyexportselection", m_lilyExportSelection->currentItem());
config->writeEntry("lilyexportpointandclick", m_lilyExportPointAndClick->isChecked());
config->writeEntry("lilyexportbeamings", m_lilyExportBeams->isChecked());
config->writeEntry("lilyexportstaffmerge", m_lilyExportStaffMerge->isChecked());
config->writeEntry("lilyexportstaffbrackets", m_lilyExportStaffGroup->isChecked());
config->writeEntry("lilylyricshtqalignment", m_lilyLyricsHAlignment->currentItem());
config->writeEntry("lilyexportmarkermode", m_lilyMarkerMode->currentItem());
m_headersPage->apply();
}
void
LilyPondOptionsDialog::slotOk()
{
slotApply();
accept();
}
void
LilyPondOptionsDialog::setDefaultLilyPondVersion(TQString version)
{
KConfig *config = kapp->config();
config->setGroup(NotationViewConfigGroup);
int index = -1;
bool unstable = false;
if (version == "2.6" || version.startsWith("2.6.")) {
index = 0;
} else if (version == "2.7" || version.startsWith("2.7.")) {
unstable = true;
index = 1;
} else if (version == "2.8" || version.startsWith("2.8.")) {
index = 1;
} else if (version == "2.9" || version.startsWith("2.9.")) {
unstable = true;
index = 2;
} else if (version == "2.10" || version.startsWith("2.10.")) {
index = 2;
} else if (version == "2.11" || version.startsWith("2.11.")) {
unstable = true;
index = 3;
} else if (version == "2.12" || version.startsWith("2.12.")) {
index = 3;
}
if (unstable) {
std::cerr << "\nWARNING: Unstable LilyPond version detected, selecting next language version up\n" << std::endl;
}
if (index >= 0) {
config->writeEntry("lilylanguage", index);
}
}
}
#include "LilyPondOptionsDialog.moc"
|