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
|
/*
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]>
This file is Copyright 2006
D. Michael McIntyre <[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 "PresetHandlerDialog.h"
#include <tqlayout.h>
#include <tdeapplication.h>
#include <tdelocale.h>
#include "misc/Debug.h"
#include "document/ConfigGroups.h"
#include "CategoryElement.h"
#include "PresetElement.h"
#include "PresetGroup.h"
#include <kcombobox.h>
#include <tdeconfig.h>
#include <kdialogbase.h>
#include <tqbuttongroup.h>
#include <tqdialog.h>
#include <tqframe.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqstring.h>
#include <tqvbox.h>
#include <tqwidget.h>
namespace Rosegarden
{
PresetHandlerDialog::PresetHandlerDialog(TQWidget *parent, bool fromNotation)
: KDialogBase(parent, "presethandlerdialog", true, i18n("Load track parameters preset"), Ok | Cancel, Ok),
m_config(kapp->config()),
m_fromNotation(fromNotation)
{
m_presets = new PresetGroup();
m_categories = m_presets->getCategories();
if (m_fromNotation) setCaption(i18n("Convert notation for..."));
initDialog();
}
PresetHandlerDialog::~PresetHandlerDialog()
{
// delete m_presets
if (m_presets != NULL) {
delete m_presets;
}
}
void
PresetHandlerDialog::initDialog()
{
RG_DEBUG << "PresetHandlerDialog::initDialog()" << endl;
TQVBox *vBox = makeVBoxMainWidget();
TQFrame *frame = new TQFrame(vBox);
TQGridLayout *layout = new TQGridLayout(frame, 6, 5, 10, 5);
TQLabel *title = new TQLabel(i18n("Select preset track parameters for:"), frame);
if (m_fromNotation) title->setText(i18n("Create appropriate notation for:"));
TQLabel *catlabel = new TQLabel(i18n("Category"), frame);
m_categoryCombo = new KComboBox(frame);
TQLabel *inslabel = new TQLabel(i18n("Instrument"), frame);
m_instrumentCombo = new KComboBox(frame);
TQLabel *plylabel = new TQLabel(i18n("Player Ability"), frame);
m_playerCombo = new KComboBox(frame);
m_playerCombo->insertItem(i18n("Amateur"));
m_playerCombo->insertItem(i18n("Professional"));
TQGroupBox *scopeBox = new TQButtonGroup
(1, Qt::Horizontal, i18n("Scope"), frame);
if (m_fromNotation) {
TQRadioButton *onlySelectedSegments = new
TQRadioButton(i18n("Only selected segments"), scopeBox);
m_convertAllSegments = new
TQRadioButton(i18n("All segments in this track"), scopeBox);
onlySelectedSegments->setChecked(true);
}
else {
TQRadioButton *onlyNewSegments = new
TQRadioButton(i18n("Only for new segments"), scopeBox);
m_convertSegments = new
TQRadioButton(i18n("Convert existing segments"), scopeBox);
onlyNewSegments->setChecked(true);
}
layout->addMultiCellWidget(title, 0, 0, 0, 1, AlignLeft);
layout->addWidget(catlabel, 1, 0, AlignRight);
layout->addWidget(m_categoryCombo, 1, 1);
layout->addWidget(inslabel, 2, 0, AlignRight);
layout->addWidget(m_instrumentCombo, 2, 1);
layout->addWidget(plylabel, 3, 0, AlignRight);
layout->addWidget(m_playerCombo, 3, 1);
layout->addMultiCellWidget(scopeBox, 4, 4, 0, 1, AlignLeft);
populateCategoryCombo();
// try to set to same category used previously
m_config->setGroup(GeneralOptionsConfigGroup);
m_categoryCombo->setCurrentItem(m_config->readNumEntry("category_combo_index", 0));
// populate the instrument combo
slotCategoryIndexChanged(m_categoryCombo->currentItem());
// try to set to same instrument used previously
m_config->setGroup(GeneralOptionsConfigGroup);
m_instrumentCombo->setCurrentItem(m_config->readNumEntry("instrument_combo_index", 0));
// set to same player used previously (this one can't fail, unlike the
// others, because the contents of this combo are static)
m_playerCombo->setCurrentItem(m_config->readNumEntry("player_combo_index", 0));
if (m_fromNotation){
m_convertAllSegments->setChecked(m_config->readBoolEntry("convert_all_segments", 0));
}
else {
m_convertSegments->setChecked(m_config->readBoolEntry("convert_segments", 0));
}
connect(m_categoryCombo, TQT_SIGNAL(activated(int)),
TQT_SLOT(slotCategoryIndexChanged(int)));
}
TQString
PresetHandlerDialog::getName()
{
return m_instrumentCombo->currentText();
}
int
PresetHandlerDialog::getClef()
{
PresetElement p = m_categories[m_categoryCombo->currentItem()].
getPresetByIndex(m_instrumentCombo->currentItem());
return p.getClef();
}
int
PresetHandlerDialog::getTranspose()
{
PresetElement p = m_categories[m_categoryCombo->currentItem()].
getPresetByIndex(m_instrumentCombo->currentItem());
return p.getTranspose();
}
int
PresetHandlerDialog::getLowRange()
{
PresetElement p = m_categories[m_categoryCombo->currentItem()].
getPresetByIndex(m_instrumentCombo->currentItem());
// 0 == amateur
// 1 == pro
if (m_playerCombo->currentItem() == 0) {
return p.getLowAm();
} else {
return p.getLowPro();
}
}
int
PresetHandlerDialog::getHighRange()
{
PresetElement p = m_categories[m_categoryCombo->currentItem()].
getPresetByIndex(m_instrumentCombo->currentItem());
// 0 == amateur
// 1 == pro
if (m_playerCombo->currentItem() == 0) {
return p.getHighAm();
} else {
return p.getHighPro();
}
}
bool
PresetHandlerDialog::getConvertAllSegments()
{
if (m_fromNotation) {
return m_convertAllSegments && m_convertAllSegments->isChecked();
}
else {
return m_convertSegments && m_convertSegments->isChecked();
}
}
bool
PresetHandlerDialog::getConvertOnlySelectedSegments()
{
if (m_fromNotation) {
return m_convertAllSegments && !m_convertAllSegments->isChecked();
}
else {
return false;
}
}
void
PresetHandlerDialog::populateCategoryCombo()
{
RG_DEBUG << "PresetHandlerDialog::populateCategoryCombo()" << endl;
for (CategoriesContainer::iterator i = m_categories.begin();
i != m_categories.end(); ++i) {
RG_DEBUG << " adding category: " << (*i).getName() << endl;
m_categoryCombo->insertItem((*i).getName());
}
}
void
PresetHandlerDialog::slotCategoryIndexChanged(int index)
{
RG_DEBUG << "PresetHandlerDialog::slotCategoryIndexChanged(" << index << ")" << endl;
CategoryElement e = m_categories[index];
ElementContainer c = e.getPresets();
m_instrumentCombo->clear();
for (ElementContainer::iterator i = c.begin();
i != c.end(); ++i) {
RG_DEBUG << " adding instrument: " << (*i).getName() << endl;
m_instrumentCombo->insertItem((*i).getName());
}
}
void
PresetHandlerDialog::slotOk()
{
m_config->setGroup(GeneralOptionsConfigGroup);
m_config->writeEntry("category_combo_index", m_categoryCombo->currentItem());
m_config->writeEntry("instrument_combo_index", m_instrumentCombo->currentItem());
m_config->writeEntry("player_combo_index", m_playerCombo->currentItem());
if (m_fromNotation) {
m_config->writeEntry("convert_all_segments", m_convertAllSegments->isChecked());
}
else {
m_config->writeEntry("convert_segments", m_convertSegments->isChecked());
}
TQDialog::accept();
}
}
#include "PresetHandlerDialog.moc"
|