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
|
/**************************************************************************
midicfgdlg.cpp - The midi config dialog
Copyright (C) 1997,98 Antonio Larrosa Jimenez
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.
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.
Send comments and bug fixes to larrosa@kde.org
or to Antonio Larrosa, Rio Arnoya, 10 5B, 29006 Malaga, Spain
***************************************************************************/
#include <tqpushbutton.h>
#include <tqlistbox.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <kapplication.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
#include <klocale.h>
#include <libkmid/deviceman.h>
#include "midicfgdlg.h"
#include "version.h"
#include <kglobal.h>
#include <kstandarddirs.h>
MidiConfigDialog::MidiConfigDialog(DeviceManager *dm,
TQWidget *tqparent,const char *name) : KDialogBase(tqparent,name,TRUE,
i18n("Configure MIDI Devices"), KDialogBase::Ok|KDialogBase::Cancel)
{
setMinimumSize(360,240);
TQWidget *page = new TQWidget( this );
setMainWidget(page);
TQVBoxLayout *topLayout=new TQVBoxLayout(page, 0, spacingHint());
TQLabel *label=new TQLabel(i18n("Select the MIDI device you want to use:"),page);
topLayout->addWidget(label);
mididevices=new TQListBox(page,"midideviceslist");
topLayout->addWidget(mididevices,3);
connect(mididevices,TQT_SIGNAL(highlighted(int)),TQT_SLOT(deviceselected(int)));
devman=dm;
TQString temp;
for (int i=0;i<devman->midiPorts()+devman->synthDevices();i++)
{
if (strcmp(devman->type(i),"")!=0)
temp = TQString("%1 - %2").tqarg(devman->name(i)).tqarg(devman->type(i));
else
temp = devman->name(i);
mididevices->insertItem(temp,i);
};
selecteddevice=devman->defaultDevice();
mididevices->setCurrentItem(selecteddevice);
TQLabel *label2=new TQLabel(i18n("Use the MIDI map:"),page);
topLayout->addWidget(label2);
if (selectedmap!=NULL) delete selectedmap;
if (strcmp(devman->midiMapFilename(),"")==0)
selectedmap=NULL;
else
{
selectedmap=new char[strlen(devman->midiMapFilename())+1];
strcpy(selectedmap,devman->midiMapFilename());
}
if (selectedmap!=NULL) maplabel=new TQLabel(selectedmap,page);
else maplabel=new TQLabel(i18n("None"),page);
topLayout->addWidget(maplabel);
TQHBoxLayout *hbox=new TQHBoxLayout(topLayout);
hbox->addStretch(1);
mapbrowse=new TQPushButton(i18n("Browse..."),page);
hbox->addWidget(mapbrowse);
connect(mapbrowse,TQT_SIGNAL(clicked()),TQT_SLOT(browseMap()) );
mapnone=new TQPushButton(i18n("None"),page);
hbox->addWidget(mapnone);
connect(mapnone,TQT_SIGNAL(clicked()),TQT_SLOT(noMap()) );
topLayout->addStretch(1);
}
void MidiConfigDialog::deviceselected(int idx)
{
selecteddevice=idx;
}
void MidiConfigDialog::browseMap()
{
TQString path = KGlobal::dirs()->findAllResources("appdata", "maps/*.map").last();
path.truncate(path.tqfindRev('/'));
KURL url = KFileDialog::getOpenURL(path,"*.map",this);
if( url.isEmpty() )
return;
if( !url.isLocalFile() )
{
KMessageBox::sorry( 0L, i18n( "Only local files are currently supported." ) );
return;
}
TQString filename = url.path();
delete selectedmap;
selectedmap=new char[filename.length()+1];
strcpy(selectedmap,TQFile::encodeName(filename));
maplabel->setText(selectedmap);
}
void MidiConfigDialog::noMap()
{
if (selectedmap!=NULL) {delete selectedmap;selectedmap=NULL;};
maplabel->setText(i18n("None"));
}
int MidiConfigDialog::selecteddevice=0;
char *MidiConfigDialog::selectedmap=NULL;
#include "midicfgdlg.moc"
|