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
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: crescendo.cpp,v 1.1.1.1 2011/05/05 18:51:04 flo93 Exp $
// (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
//=========================================================
#include <QButtonGroup>
#include "crescendo.h"
#include "xml.h"
Crescendo::Crescendo(QWidget* parent)
: QDialog(parent)
{
setupUi(this);
range_group = new QButtonGroup;
range_group->addButton(looped_events_button,2);
range_group->addButton(selected_looped_button,3);
connect(absolute_button, SIGNAL(toggled(bool)), SLOT(absolute_changed(bool)));
pull_values();
}
void Crescendo::pull_values()
{
range = range_group->checkedId();
start_val = start_spinbox->value();
end_val = end_spinbox->value();
absolute = absolute_button->isChecked();
}
void Crescendo::accept()
{
pull_values();
QDialog::accept();
}
int Crescendo::exec()
{
if ((range < 2) || (range > 3)) range=3;
range_group->button(range)->setChecked(true);
start_spinbox->setValue(start_val);
end_spinbox->setValue(end_val);
absolute_button->setChecked(absolute);
absolute_changed(absolute);
return QDialog::exec();
}
void Crescendo::read_configuration(Xml& xml)
{
for (;;)
{
Xml::Token token = xml.parse();
if (token == Xml::Error || token == Xml::End)
break;
const QString& tag = xml.s1();
switch (token)
{
case Xml::TagStart:
if (tag == "range")
range=xml.parseInt();
else if (tag == "start")
start_val=xml.parseInt();
else if (tag == "end")
end_val=xml.parseInt();
else if (tag == "absolute")
absolute=xml.parseInt();
else
xml.unknown("Crescendo");
break;
case Xml::TagEnd:
if (tag == "crescendo")
return;
default:
break;
}
}
}
void Crescendo::write_configuration(int level, Xml& xml)
{
xml.tag(level++, "crescendo");
xml.intTag(level, "range", range);
xml.intTag(level, "start", start_val);
xml.intTag(level, "end", end_val);
xml.intTag(level, "absolute", absolute);
xml.tag(level, "/crescendo");
}
void Crescendo::absolute_changed(bool val)
{
if (val)
{
start_spinbox->setMaximum(127);
start_spinbox->setSuffix("");
end_spinbox->setMaximum(127);
end_spinbox->setSuffix("");
}
else
{
start_spinbox->setMaximum(12700);
start_spinbox->setSuffix(" %");
end_spinbox->setMaximum(12700);
end_spinbox->setSuffix(" %");
}
}
|