4
* kscd -- A simple CD player for the KDE project
6
* $Id: configdlg.cpp,v 1.35 2001/07/27 12:12:09 mlaurent Exp $
8
* Copyright (C) 1997 Bernd Johannes Wuebben
9
* wuebben@math.cornell.edu
12
* This program is free software; you can redistribute it and/or
13
* modify it under the terms of the GNU 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.
17
* This program 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
* General Public License for more details.
22
* You should have received a copy of the GNU 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.
30
#include "configdlg.h"
34
#include <qfontmetrics.h>
36
ConfigDlg::ConfigDlg(QWidget *parent, struct configstruct *data,const char *name)
37
: QDialog(parent, name)
40
configdata.background_color = black;
41
configdata.led_color = green;
42
configdata.tooltips = true;
43
configdata.cd_device = QString::fromLatin1("/dev/cdrom");
44
configdata.docking = true;
45
configdata.autoplay = false;
46
configdata.stopexit = true;
47
configdata.ejectonfinish = false;
51
configdata.background_color = data->background_color;
52
configdata.randomonce = true;
53
configdata.led_color = data->led_color;
54
configdata.tooltips = data->tooltips;
55
configdata.cd_device = data->cd_device;
56
configdata.browsercmd = data->browsercmd;
57
configdata.use_kfm = data->use_kfm;
58
configdata.docking = data->docking;
59
configdata.autoplay = data->autoplay;
60
configdata.stopexit = data->stopexit;
61
configdata.ejectonfinish = data->ejectonfinish;
64
colors_changed = false;
66
configdata.randomonce = data->randomonce;
67
setCaption(i18n("Configure kscd"));
69
QVBoxLayout * lay1 = new QVBoxLayout ( this, 10 );
70
box = new QGroupBox(this, "box");
71
lay1->addWidget ( box );
73
QFontMetrics fm ( font() );
75
QHBoxLayout * lay2 = new QHBoxLayout ( box, 10 );
76
QVBoxLayout * lay3 = new QVBoxLayout ( lay2 );
77
QGroupBox * cpbox = new QGroupBox ( i18n("Colors and paths"), box );
78
lay3->addWidget ( cpbox );
79
QGridLayout * cplay = new QGridLayout ( cpbox, 5, 3, 10 );
80
cplay->addRowSpacing ( 0, fm.lineSpacing() );
82
label1 = new QLabel(i18n("LED Color:"), cpbox);
83
cplay->addWidget ( label1, 1, 0 );
84
qframe1 = new QFrame(cpbox);
85
qframe1->setFixedSize(30,25);
86
cplay->addWidget ( qframe1, 1, 1, AlignLeft );
87
qframe1->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
88
qframe1->setBackgroundColor(configdata.led_color);
89
button1 = new QPushButton(i18n("Change"),cpbox);
90
cplay->addWidget ( button1, 1, 2 );
91
connect(button1,SIGNAL(clicked()),this,SLOT(set_led_color()));
93
label2 = new QLabel(i18n("Background Color:"),cpbox);
94
cplay->addWidget ( label2, 2, 0 );
95
qframe2 = new QFrame(cpbox);
96
qframe2->setFixedSize(30,25);
97
cplay->addWidget ( qframe2, 2, 1, AlignLeft );
98
qframe2->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
99
qframe2->setBackgroundColor(configdata.background_color);
100
button2 = new QPushButton(i18n("Change"),cpbox);
101
cplay->addWidget ( button2, 2, 2 );
102
connect(button2,SIGNAL(clicked()),this,SLOT(set_background_color()));
104
label5 = new QLabel(i18n("CDROM Device:"), cpbox);
105
cplay->addWidget ( label5, 3, 0 );
106
cd_device_edit = new QLineEdit(cpbox);
107
cplay->addMultiCellWidget ( cd_device_edit, 3,3, 1,2 );
108
cd_device_edit->setText(configdata.cd_device);
109
connect(cd_device_edit,SIGNAL(textChanged(const QString &)),
110
this,SLOT(device_changed(const QString &)));
112
#if defined(sun) || defined(__sun__) || defined(__osf__) || defined(ultrix) || defined(__ultrix)
115
cd_device_edit->hide();
119
browserbox = new QButtonGroup(i18n("WWW Browser"),box,"wwwbox");
120
lay3->addWidget ( browserbox );
121
QVBoxLayout * lay4 = new QVBoxLayout ( browserbox, 10 );
122
lay4->addSpacing ( fm.lineSpacing() );
124
kfmbutton = new QRadioButton(i18n("Use Konqueror as Browser"),
125
browserbox,"kfmbutton");
126
lay4->addWidget ( kfmbutton );
127
kfmbutton->setChecked(configdata.use_kfm);
128
connect(kfmbutton,SIGNAL(clicked()),this,SLOT(kfmbutton_clicked()));
130
custombutton = new QRadioButton(i18n("Use Custom Browser:"),
131
browserbox,"custombutton");
132
lay4->addWidget ( custombutton );
133
custombutton->setChecked(!configdata.use_kfm);
134
connect(custombutton,SIGNAL(clicked()),this,SLOT(custombutton_clicked()));
136
QBoxLayout * lay5 = new QHBoxLayout ( lay4 );
137
lay5->addSpacing ( 20 );
138
custom_edit = new QLineEdit(browserbox,"customedit");
139
custom_edit->setText(data->browsercmd);
140
custom_edit->setEnabled(!configdata.use_kfm);
141
lay5->addWidget ( custom_edit, 1 );
143
QBoxLayout * lay6 = new QVBoxLayout ( lay2 );
144
QGroupBox * miscbox = new QGroupBox ( 1, Horizontal, i18n("Misc"), box );
145
lay6->addWidget ( miscbox );
147
ttcheckbox = new QCheckBox(i18n("Show Tool Tips"),
148
miscbox, "tooltipscheckbox");
149
ttcheckbox->setChecked(configdata.tooltips);
150
connect(ttcheckbox,SIGNAL(clicked()),this,SLOT(ttclicked()));
152
dockcheckbox = new QCheckBox(i18n("Enable KPanel Docking"),
153
miscbox, "dockcheckbox");
154
dockcheckbox->setChecked(configdata.docking);
155
connect(dockcheckbox,SIGNAL(clicked()),this,SLOT(dockclicked()));
157
cdAutoPlayCB = new QCheckBox(i18n("Play on Tray Close"),
158
miscbox, "cdAutoPlayCB");
159
cdAutoPlayCB->setChecked(configdata.autoplay);
160
connect(cdAutoPlayCB, SIGNAL(clicked()), this, SLOT(autoPlayClicked()));
162
stopOnExitCB = new QCheckBox(i18n("Stop Playing on Exit"),
163
miscbox, "stopOnExitCB");
164
stopOnExitCB->setChecked(configdata.stopexit);
165
connect(stopOnExitCB, SIGNAL(clicked()), this, SLOT(stopOnExitClicked()));
167
ejectOnFinishCB = new QCheckBox(i18n("Eject on Finish"),
168
miscbox, "ejectOnFinishCB");
169
ejectOnFinishCB->setChecked(configdata.ejectonfinish);
170
connect(ejectOnFinishCB, SIGNAL(clicked()), this, SLOT(ejectOnFinishClicked()));
173
/* koz: Added a configure option to select the unique random play mode, */
174
/* or the traditional random mode */
175
randomOnceCB = new QCheckBox(i18n("Random is Shuffle"),
176
miscbox, "randomOnceCB");
177
randomOnceCB->setChecked(configdata.randomonce);
178
connect(randomOnceCB,SIGNAL(clicked()),this,SLOT(randomOnceClicked()));
180
button3 = new QPushButton(i18n("Help"),box);
181
lay6->addWidget ( button3, 0, AlignRight );
182
connect(button3,SIGNAL(clicked()),this,SLOT(help()));
184
lay1->addStretch ( 1 );
189
ConfigDlg::custombutton_clicked()
191
configdata.use_kfm = false;
192
custom_edit->setEnabled(!configdata.use_kfm);
193
} // custombutton_clicked
197
ConfigDlg::kfmbutton_clicked()
199
configdata.use_kfm = true;
200
custom_edit->setEnabled(!configdata.use_kfm);
201
} // kfmbutton_clicked
205
ConfigDlg::okbutton()
210
ConfigDlg::device_changed(const QString &dev) {
212
configdata.cd_device = dev;
216
ConfigDlg::ttclicked(){
218
if(ttcheckbox->isChecked())
219
configdata.tooltips = TRUE;
221
configdata.tooltips = FALSE;
225
ConfigDlg::dockclicked(){
227
if(dockcheckbox->isChecked()){
228
configdata.docking = TRUE;
230
configdata.docking = FALSE;
235
ConfigDlg::autoPlayClicked(){
236
if(cdAutoPlayCB->isChecked())
237
configdata.autoplay = TRUE;
239
configdata.autoplay = FALSE;
244
ConfigDlg::stopOnExitClicked()
246
if(stopOnExitCB->isChecked())
247
configdata.stopexit = TRUE;
249
configdata.stopexit = FALSE;
250
} // stopOnExitClicked
253
ConfigDlg::ejectOnFinishClicked()
255
if(ejectOnFinishCB->isChecked())
256
configdata.ejectonfinish = TRUE;
258
configdata.ejectonfinish = FALSE;
259
} // ejectOnFinishClicked
264
kapp->invokeHelp( QString::null,"kscd" );
268
ConfigDlg::cancelbutton()
274
ConfigDlg::set_led_color()
276
KColorDialog::getColor(configdata.led_color);
277
qframe1->setBackgroundColor(configdata.led_color);
281
ConfigDlg::set_background_color()
284
KColorDialog::getColor(configdata.background_color);
285
qframe2->setBackgroundColor(configdata.background_color);
286
} // set_background_color
289
ConfigDlg::randomOnceClicked()
291
if(randomOnceCB->isChecked())
292
configdata.randomonce = TRUE;
294
configdata.randomonce = FALSE;
295
} // randomOnceClicked
297
struct configstruct *
300
configdata.browsercmd = custom_edit->text();
304
#include "configdlg.moc"