~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmidi/configdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 *
 
4
 *    kmidi
 
5
 *
 
6
 * $Id: configdlg.cpp,v 1.20 2001/05/31 03:58:54 jsinger Exp $
 
7
 *
 
8
 * Copyright (C) 1997 Bernd Johannes Wuebben
 
9
 * wuebben@math.cornell.edu
 
10
 *
 
11
 *
 
12
 * This library is free software; you can redistribute it and/or
 
13
 * modify it under the terms of the GNU Library General Public
 
14
 * License as published by the Free Software Foundation; either
 
15
 * version 2 of the License, or (at your option) any later version.
 
16
 *
 
17
 * This library is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
20
 * Library General Public License for more details.
 
21
 *
 
22
 * You should have received a copy of the GNU Library General Public
 
23
 * License along with this program; if not, write to the Free
 
24
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
25
 *
 
26
 */
 
27
 
 
28
#include <kapp.h>
 
29
#include <qpushbutton.h>
 
30
#include <qlabel.h>
 
31
#include <qgroupbox.h>
 
32
#include <qcheckbox.h>
 
33
 
 
34
#include <stdio.h>
 
35
#include <stdlib.h>
 
36
#include <string.h>
 
37
#include <unistd.h>
 
38
 
 
39
#include <klocale.h>
 
40
#include <ktabctl.h>
 
41
#include <kiconloader.h>
 
42
#include <kstddirs.h>
 
43
#include <kglobal.h>
 
44
//#include <kcolorbtn.h>
 
45
 
 
46
#include "configdlg.h"
 
47
#include "kmidi.h"
 
48
#include "version.h"
 
49
#include "midiapplication.h"
 
50
 
 
51
//QFont default_font("Helvetica", 12);
 
52
 
 
53
extern const char * whatsthis_image[];
 
54
 
 
55
ConfigDlg::ConfigDlg(QWidget *parent, struct configstruct *data, const char *name)
 
56
    : QDialog(parent, name, TRUE)
 
57
{
 
58
    setCaption("kmidi configuration");
 
59
    setMinimumSize(300, 200);
 
60
 
 
61
  configdata.background_color = black;
 
62
  configdata.led_color = green;
 
63
  configdata.tooltips = true;
 
64
  configdata.max_patch_megs = 60;
 
65
 
 
66
  if(data){
 
67
    configdata.background_color = data->background_color;
 
68
    configdata.led_color = data->led_color;
 
69
    configdata.tooltips = data->tooltips;
 
70
    configdata.max_patch_megs = data->max_patch_megs;
 
71
  }
 
72
 
 
73
 
 
74
    /*
 
75
     * add a tabctrl widget
 
76
     */
 
77
 
 
78
    test = new KTabCtl(this, "test");
 
79
    connect(test, SIGNAL(tabSelected(int)), this, SLOT(tabChanged(int)));
 
80
 
 
81
 
 
82
    tl = new QVBoxLayout(this, 5);
 
83
    bbox = new KButtonBox(this);
 
84
    ok = bbox->addButton("OK");
 
85
    ok->setDefault(TRUE);
 
86
    cancel = bbox->addButton("Cancel");
 
87
    cancel->setDefault(TRUE);
 
88
 
 
89
    connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
 
90
    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
 
91
    bbox->addStretch(1);
 
92
    helpbutton = bbox->addButton("Help");
 
93
    connect(helpbutton, SIGNAL(clicked()), this, SLOT(help()));
 
94
    QPixmap p( whatsthis_image );
 
95
    helpbutton->setPixmap( p );
 
96
 
 
97
    //helpmenu = new KHelpMenu(this, "kmidi plays midi files");
 
98
    what = new QWhatsThis(this);
 
99
 
 
100
// Page 1
 
101
    QWidget *w = new QWidget(test, "_page1");
 
102
 
 
103
    //box = new QGroupBox(w, "box");
 
104
    //box->setGeometry(10,10,320,260);
 
105
    configsize = QSize( 320+20, 260+80 );
 
106
 
 
107
    QString str = i18n("The led color is used in<br>\nthe panel and meter.");
 
108
    label1 = new QLabel(w);
 
109
    label1->setGeometry(60,25,135,25);
 
110
    label1->setText(i18n("LED Color:"));
 
111
    what->add(label1, str);
 
112
 
 
113
    button1 = new KColorButton(configdata.led_color, w);
 
114
    button1->setGeometry(205,25,100,45);
 
115
    connect(button1,SIGNAL(changed( const QColor & )),this,SLOT(set_led_color( const QColor & )));
 
116
    what->add(button1, str);
 
117
 
 
118
    str = i18n("This color is for<br>\nthe panel and meter backgrounds.");
 
119
    label2 = new QLabel(w);
 
120
    label2->setGeometry(60,85,135,25);
 
121
    label2->setText(i18n("Background Color:"));
 
122
    what->add(label2, str);
 
123
 
 
124
    button2 = new KColorButton(configdata.background_color, w);
 
125
    button2->setGeometry(205,85,100,45);
 
126
    connect(button2,SIGNAL(changed( const QColor & )),this,SLOT(set_background_color( const QColor & )));
 
127
    what->add(button2, str);
 
128
 
 
129
    ttcheckbox = new QCheckBox(i18n("Show Tool Tips"), w, "tooltipscheckbox");
 
130
    ttcheckbox->setGeometry(30,150,135,25);
 
131
    ttcheckbox->setFixedSize( ttcheckbox->sizeHint() );
 
132
    ttcheckbox->setChecked(configdata.tooltips);
 
133
    connect(ttcheckbox,SIGNAL(clicked()),this,SLOT(ttclicked()));
 
134
    what->add(ttcheckbox, i18n("Provide brief descriptions<br>\n"
 
135
                               "when cursor is left over a<br>\n"
 
136
                               "object on the screen"));
 
137
 
 
138
    str = i18n("Try to stop KMidi from<br>\nusing up too much of your RAM.");
 
139
    label3 = new QLabel(w);
 
140
    label3->setGeometry(60,200,135,25);
 
141
    label3->setText("Patch Mem Max:");
 
142
    what->add(label3, str);
 
143
    meg = new KIntNumInput(configdata.max_patch_megs, w, 10, "hex_with_slider" );
 
144
    meg->setRange(0, 255);
 
145
    meg->setSpecialValueText("no limit");
 
146
    meg->move(205, 200);
 
147
    connect(meg,SIGNAL(valueChanged(int)),this,SLOT(megChanged(int)));
 
148
    what->add(meg, str);
 
149
 
 
150
    w->resize(320, 260);
 
151
    test->addTab(w, "Configure");
 
152
    pages[0] = w;
 
153
 
 
154
// Page 2
 
155
    w = new QWidget(test, "_page2");
 
156
    about = new KAboutWidget(w, "_about");
 
157
    QPixmap pm = UserIcon("kmidilogo");
 
158
    about->setLogo(pm);
 
159
    about->setCaption(i18n("About KMidi"));
 
160
    about->setVersion(i18n(KMIDIVERSION));
 
161
    about->setAuthor
 
162
    ("Bernd Johannes Wuebben", "wuebben@kde.org", QString::null, i18n("Initial developer."));
 
163
    // ----- set the application maintainer:
 
164
    about->setMaintainer("Greg Lee", // name
 
165
                      "lee@hawaii.edu", // email address
 
166
                      QString::null, // URL
 
167
                      i18n("lyrics, IW patches, current maintainer.")); // description
 
168
    // ----- add some contributors:
 
169
    about->addContributor("Tuukka Toivonen",
 
170
                       "toivonen@clinet.fi",
 
171
                       "http://www.cgs.fi/~tt/discontinued.html",
 
172
                       i18n("TiMidity sound, patch loader, interface design, ..."));
 
173
    about->addContributor("Takashi Iwai", "iwai@dragon.mm.t.u-tokyo.ac.jp",
 
174
                        "http://bahamut.mm.t.u-tokyo.ac.jp/~iwai/midi.html",
 
175
                       i18n("soundfonts, window communication"));
 
176
    about->addContributor("Nicolas Witczak", "witczak@geocities.fr",
 
177
                        "http://www.geocities.com/SiliconValley/Lab/6307/",
 
178
                       i18n("effects: reverb, chorus, phaser, celeste"));
 
179
    about->addContributor("Masanao Izumo", "mo@goice.co.jp",
 
180
                        "http://www.goice.co.jp/member/mo/timidity/",
 
181
                       i18n("mod wheel, portamento ..."));
 
182
    about->addContributor("see the timidity.1 man page", "for authors of",
 
183
                        "", 
 
184
                       i18n("drivers, interfaces, configure scripts"));
 
185
 
 
186
    connect(about, SIGNAL( sendEmail(const QString& , const QString& ) ),
 
187
        this, SLOT ( sendEmailSlot(const QString& , const QString& ) ) );
 
188
    connect(about, SIGNAL( openURL(const QString& ) ),
 
189
        this, SLOT ( openURLSlot(const QString& ) ) );
 
190
 
 
191
    // ----- contents of the dialog have changed, adapt sizes:
 
192
    about->adjust();
 
193
    aboutsize = QSize( about->width() + 30, about->height() + 80 );
 
194
    w->resize(width(), height());
 
195
    test->addTab(w, "About");
 
196
    pages[1] = w;
 
197
 
 
198
 
 
199
// Page 3
 
200
    w = new QWidget(test, "_page3");
 
201
    patches = new KAboutWidget(w, "_patches");
 
202
    QPixmap km = BarIcon("kmidi");
 
203
    patches->setLogo(km);
 
204
    //patches->setCaption(i18n("Patchsets"));
 
205
    patches->setVersion(i18n("Where to get sets of patches."));
 
206
    patches->setAuthor("Thomas Hammer", QString::null,
 
207
        "http://metalab.unc.edu/thammer/HammerSound/",
 
208
        i18n("links to many sf2 soundfonts"));
 
209
    patches->setMaintainer("Eric A. Welsh",
 
210
        "mailto:ewelsh@gpc.ibc.wustl.edu",
 
211
        "http://www.stardate.bc.ca/gus_patches.htm",
 
212
        i18n("GUS patches -- unrar needed to decompress."));
 
213
    patches->addContributor("Chaos", "mailto:chaos@soback.kornet.nm.kr",
 
214
                "http://taeback.kornet.nm.kr/~chaos/soundfont/",
 
215
                "A very moderately sized soundfont (12 megs).");
 
216
    patches->addContributor("Personal Copy v4.0.0", QString::null,
 
217
                "http://www.personalcopy.com/sfarkfonts.htm",
 
218
                "A very good large soundfont (38 megs).");
 
219
    patches->addContributor("Msdos sfark decompressor.", QString::null,
 
220
                "http://www.melodymachine.com/",
 
221
                i18n("You may need this msdos-only tool."));
 
222
 
 
223
    connect(patches, SIGNAL( sendEmail(const QString& , const QString& ) ),
 
224
        this, SLOT ( sendEmailSlot(const QString& , const QString& ) ) );
 
225
    connect(patches, SIGNAL( openURL(const QString& ) ),
 
226
        this, SLOT ( openURLSlot(const QString& ) ) );
 
227
 
 
228
    patches->adjust();
 
229
    patchessize = QSize( patches->width() + 30, patches->height() + 80 );
 
230
    w->resize(width(), height());
 
231
    test->addTab(w, "Patchsets");
 
232
    pages[2] = w;
 
233
 
 
234
//------------------------
 
235
    test->resize(configsize);
 
236
    test->move(0, 0);
 
237
    tl->addWidget(test,1);
 
238
    bbox->layout();
 
239
    tl->addWidget(bbox,0);
 
240
    tl->activate();
 
241
 
 
242
    move(20, 20);
 
243
    resize(400, 500);
 
244
    adjustSize();
 
245
}
 
246
 
 
247
void ConfigDlg::sendEmailSlot(const QString& , const QString& email)
 
248
{
 
249
  thisapp->invokeMailer( email, QString::null );
 
250
}
 
251
 
 
252
void ConfigDlg::openURLSlot(const QString& url)
 
253
{
 
254
  thisapp->invokeBrowser( url );
 
255
}
 
256
 
 
257
void ConfigDlg::resizeEvent( QResizeEvent * )
 
258
{
 
259
    test->resize(width(), height());
 
260
    about->setGeometry(10, 10, pages[1]->width() - 20, pages[1]->height() - 20);
 
261
}
 
262
 
 
263
void ConfigDlg::tabChanged(int newpage)
 
264
{
 
265
    //printf("tab number %d selected\n", newpage);
 
266
    //if(newpage == 1)
 
267
    //    e->setFocus();
 
268
    if (newpage == 1) resize(aboutsize);
 
269
    else if (newpage == 2) resize(patchessize);
 
270
    else resize(configsize);
 
271
}
 
272
 
 
273
 
 
274
void ConfigDlg::okbutton() {
 
275
//    hide();
 
276
}
 
277
 
 
278
void ConfigDlg::ttclicked(){
 
279
 
 
280
  if(ttcheckbox->isChecked())
 
281
    configdata.tooltips = TRUE;
 
282
  else
 
283
    configdata.tooltips = FALSE;
 
284
 
 
285
}
 
286
void ConfigDlg::help(){
 
287
 
 
288
//  if(thisapp)
 
289
//    thisapp->invokeHTMLHelp("","");
 
290
 
 
291
//the damn thing won't go away
 
292
//   (helpmenu->menu())->move( QCursor::pos() );
 
293
//   (helpmenu->menu())->show();
 
294
//    helpmenu->aboutApp();
 
295
    QWhatsThis::enterWhatsThisMode();
 
296
}
 
297
 
 
298
void ConfigDlg::cancelbutton() {
 
299
//  reject();
 
300
}
 
301
 
 
302
void ConfigDlg::set_led_color( const QColor &newColor ) {
 
303
 
 
304
  //KColorDialog::getColor(configdata.led_color);
 
305
  configdata.led_color = newColor;
 
306
  //qframe1->setBackgroundColor(configdata.led_color);
 
307
 
 
308
 
 
309
}
 
310
 
 
311
void ConfigDlg::set_background_color( const QColor &newColor ) {
 
312
 
 
313
  //KColorDialog::getColor(configdata.background_color);
 
314
  configdata.background_color = newColor;
 
315
  //qframe2->setBackgroundColor(configdata.background_color);
 
316
 
 
317
}
 
318
 
 
319
void ConfigDlg::megChanged( int newMegs ) {
 
320
  configdata.max_patch_megs = newMegs;
 
321
}
 
322
 
 
323
struct configstruct * ConfigDlg::getData(){
 
324
 
 
325
  return &configdata;
 
326
 
 
327
}
 
328
 
 
329
#include "configdlg.moc"
 
330