summaryrefslogtreecommitdiff
path: root/muse2/muse/dialogs.cpp
blob: 6bdddcdd4d751c362e23df98c29c7cb167927abb (plain)
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
//=========================================================
//  MusE
//  Linux Music Editor
//    $Id: functions.cpp,v 1.20.2.19 2011/05/05 20:10 flo93 Exp $
//  (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
//
//  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; version 2 of
//  the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
//=========================================================

#include "dialogs.h"
#include "widgets/function_dialogs/velocity.h"
#include "widgets/function_dialogs/quantize.h"
#include "widgets/function_dialogs/crescendo.h"
#include "widgets/function_dialogs/gatetime.h"
#include "widgets/function_dialogs/remove.h"
#include "widgets/function_dialogs/transpose.h"
#include "widgets/function_dialogs/setlen.h"
#include "widgets/function_dialogs/move.h"
#include "widgets/function_dialogs/deloverlaps.h"
#include "widgets/function_dialogs/legato.h"
#include "widgets/pastedialog.h"
#include "widgets/pasteeventsdialog.h"

#include "xml.h"

#include <iostream>

using namespace std;

namespace MusEGui {

GateTime* gatetime_dialog=NULL;
Velocity* velocity_dialog=NULL;
Quantize* quantize_dialog=NULL;
Remove* erase_dialog=NULL;
DelOverlaps* del_overlaps_dialog=NULL;
Setlen* set_notelen_dialog=NULL;
Move* move_notes_dialog=NULL;
Transpose* transpose_dialog=NULL;
Crescendo* crescendo_dialog=NULL;
Legato* legato_dialog=NULL;
PasteDialog* paste_dialog=NULL;
PasteEventsDialog* paste_events_dialog=NULL;

void init_function_dialogs()
{
        // NOTE: For deleting parentless dialogs and widgets, please add them to MusE::deleteParentlessDialogs().
        gatetime_dialog = new GateTime();
        velocity_dialog = new Velocity();
        quantize_dialog = new Quantize();
        erase_dialog = new Remove();
        del_overlaps_dialog = new DelOverlaps();
        set_notelen_dialog = new Setlen();
        move_notes_dialog = new Move();
        transpose_dialog = new Transpose();
        crescendo_dialog = new Crescendo();
        legato_dialog = new Legato();
        paste_dialog = new PasteDialog();
        paste_events_dialog = new PasteEventsDialog();
}

//
// NOTE: This is called by MusE::deleteParentlessDialogs()
//
void destroy_function_dialogs()
{
        if(gatetime_dialog) delete gatetime_dialog;
        if(velocity_dialog) delete velocity_dialog;
        if(quantize_dialog) delete quantize_dialog;
        if(erase_dialog) delete erase_dialog;
        if(del_overlaps_dialog) delete del_overlaps_dialog;
        if(set_notelen_dialog) delete set_notelen_dialog;
        if(move_notes_dialog) delete move_notes_dialog;
        if(transpose_dialog) delete transpose_dialog;
        if(crescendo_dialog) delete crescendo_dialog;
        if(legato_dialog) delete legato_dialog;
        if(paste_dialog) delete paste_dialog;
        if(paste_events_dialog) delete paste_events_dialog;
}

void retranslate_function_dialogs()
{
	gatetime_dialog->retranslateUi(gatetime_dialog);
	velocity_dialog->retranslateUi(velocity_dialog);
	quantize_dialog->retranslateUi(quantize_dialog);
	erase_dialog->retranslateUi(erase_dialog);
	del_overlaps_dialog->retranslateUi(del_overlaps_dialog);
	set_notelen_dialog->retranslateUi(set_notelen_dialog);
	move_notes_dialog->retranslateUi(move_notes_dialog);
	transpose_dialog->retranslateUi(transpose_dialog);
	crescendo_dialog->retranslateUi(crescendo_dialog);
	legato_dialog->retranslateUi(legato_dialog);
	paste_dialog->retranslateUi(paste_dialog);
	paste_events_dialog->retranslateUi(paste_events_dialog);
}

void read_function_dialog_config(MusECore::Xml& xml)
{
	for (;;)
	{
		MusECore::Xml::Token token = xml.parse();
		if (token == MusECore::Xml::Error || token == MusECore::Xml::End)
			break;
			
		const QString& tag = xml.s1();
		switch (token)
		{
			case MusECore::Xml::TagStart:
				if (tag == "mod_len")
					gatetime_dialog->read_configuration(xml);
				else if (tag == "mod_velo")
					velocity_dialog->read_configuration(xml);
				else if (tag == "quantize")
					quantize_dialog->read_configuration(xml);
				else if (tag == "erase")
					erase_dialog->read_configuration(xml);
				else if (tag == "del_overlaps")
					del_overlaps_dialog->read_configuration(xml);
				else if (tag == "setlen")
					set_notelen_dialog->read_configuration(xml);
				else if (tag == "move")
					move_notes_dialog->read_configuration(xml);
				else if (tag == "transpose")
					transpose_dialog->read_configuration(xml);
				else if (tag == "crescendo")
					crescendo_dialog->read_configuration(xml);
				else if (tag == "legato")
					legato_dialog->read_configuration(xml);
				else if (tag == "pastedialog")
					paste_dialog->read_configuration(xml);
				else if (tag == "pasteeventsdialog")
					paste_events_dialog->read_configuration(xml);
				else
					xml.unknown("dialogs");
				break;
				
			case MusECore::Xml::TagEnd:
				if (tag == "dialogs")
					return;
				
			default:
				break;
		}
	}
}

void write_function_dialog_config(int level, MusECore::Xml& xml)
{
	xml.tag(level++, "dialogs");

	gatetime_dialog->write_configuration(level, xml);
	velocity_dialog->write_configuration(level, xml);
	quantize_dialog->write_configuration(level, xml);
	erase_dialog->write_configuration(level, xml);
	del_overlaps_dialog->write_configuration(level, xml);
	set_notelen_dialog->write_configuration(level, xml);
	move_notes_dialog->write_configuration(level, xml);
	transpose_dialog->write_configuration(level, xml);
	crescendo_dialog->write_configuration(level, xml);
	legato_dialog->write_configuration(level, xml);
	paste_dialog->write_configuration(level, xml);
	paste_events_dialog->write_configuration(level, xml);

	xml.tag(level, "/dialogs");
}

}