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

« back to all changes in this revision

Viewing changes to kscd/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
 * kscd -- A simple CD player for the KDE project
 
5
 *
 
6
 * $Id: configdlg.cpp,v 1.35 2001/07/27 12:12:09 mlaurent Exp $
 
7
 *
 
8
 * Copyright (C) 1997 Bernd Johannes Wuebben
 
9
 * wuebben@math.cornell.edu
 
10
 *
 
11
 *
 
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.
 
16
 *
 
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.
 
21
 *
 
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.
 
25
 *
 
26
 */
 
27
 
 
28
 
 
29
 
 
30
#include "configdlg.h"
 
31
#include <klocale.h>
 
32
 
 
33
#include <qlayout.h>
 
34
#include <qfontmetrics.h>
 
35
 
 
36
ConfigDlg::ConfigDlg(QWidget *parent, struct configstruct *data,const char *name)
 
37
  : QDialog(parent, name)
 
38
{
 
39
 
 
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;
 
48
 
 
49
  if(data)
 
50
    {
 
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;
 
62
    }
 
63
 
 
64
  colors_changed = false;
 
65
 
 
66
  configdata.randomonce = data->randomonce;
 
67
  setCaption(i18n("Configure kscd"));
 
68
 
 
69
  QVBoxLayout * lay1 = new QVBoxLayout ( this, 10 );
 
70
  box = new QGroupBox(this, "box");
 
71
  lay1->addWidget ( box );
 
72
 
 
73
  QFontMetrics fm ( font() );
 
74
 
 
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() );
 
81
 
 
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()));
 
92
 
 
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()));
 
103
 
 
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 &)));
 
111
 
 
112
#if defined(sun) || defined(__sun__) || defined(__osf__) || defined(ultrix) || defined(__ultrix)
 
113
 
 
114
  label5->hide();
 
115
  cd_device_edit->hide();
 
116
 
 
117
#endif
 
118
 
 
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() );
 
123
 
 
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()));
 
129
 
 
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()));
 
135
 
 
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 );
 
142
 
 
143
  QBoxLayout * lay6 = new QVBoxLayout ( lay2 );
 
144
  QGroupBox * miscbox = new QGroupBox ( 1, Horizontal, i18n("Misc"), box );
 
145
  lay6->addWidget ( miscbox );
 
146
 
 
147
  ttcheckbox = new QCheckBox(i18n("Show Tool Tips"),
 
148
                             miscbox, "tooltipscheckbox");
 
149
  ttcheckbox->setChecked(configdata.tooltips);
 
150
  connect(ttcheckbox,SIGNAL(clicked()),this,SLOT(ttclicked()));
 
151
 
 
152
  dockcheckbox = new QCheckBox(i18n("Enable KPanel Docking"),
 
153
                               miscbox, "dockcheckbox");
 
154
  dockcheckbox->setChecked(configdata.docking);
 
155
  connect(dockcheckbox,SIGNAL(clicked()),this,SLOT(dockclicked()));
 
156
 
 
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()));
 
161
 
 
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()));
 
166
 
 
167
  ejectOnFinishCB = new QCheckBox(i18n("Eject on Finish"),
 
168
                                  miscbox, "ejectOnFinishCB");
 
169
  ejectOnFinishCB->setChecked(configdata.ejectonfinish);
 
170
  connect(ejectOnFinishCB, SIGNAL(clicked()), this, SLOT(ejectOnFinishClicked()));
 
171
 
 
172
 
 
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()));
 
179
 
 
180
  button3 = new QPushButton(i18n("Help"),box);
 
181
  lay6->addWidget ( button3, 0, AlignRight );
 
182
  connect(button3,SIGNAL(clicked()),this,SLOT(help()));
 
183
 
 
184
  lay1->addStretch ( 1 );
 
185
}
 
186
 
 
187
 
 
188
void
 
189
ConfigDlg::custombutton_clicked()
 
190
{
 
191
    configdata.use_kfm = false;
 
192
    custom_edit->setEnabled(!configdata.use_kfm);
 
193
} // custombutton_clicked
 
194
 
 
195
 
 
196
void
 
197
ConfigDlg::kfmbutton_clicked()
 
198
{
 
199
    configdata.use_kfm = true;
 
200
    custom_edit->setEnabled(!configdata.use_kfm);
 
201
} // kfmbutton_clicked
 
202
 
 
203
 
 
204
void
 
205
ConfigDlg::okbutton()
 
206
{
 
207
} // okbutton
 
208
 
 
209
void
 
210
ConfigDlg::device_changed(const QString &dev) {
 
211
 
 
212
  configdata.cd_device = dev;
 
213
} // device_changed
 
214
 
 
215
void
 
216
ConfigDlg::ttclicked(){
 
217
 
 
218
  if(ttcheckbox->isChecked())
 
219
    configdata.tooltips = TRUE;
 
220
  else
 
221
    configdata.tooltips = FALSE;
 
222
} // ttclicked
 
223
 
 
224
void
 
225
ConfigDlg::dockclicked(){
 
226
 
 
227
    if(dockcheckbox->isChecked()){
 
228
        configdata.docking = TRUE;
 
229
    }else{
 
230
        configdata.docking = FALSE;
 
231
    }
 
232
} // dockclicked
 
233
 
 
234
void
 
235
ConfigDlg::autoPlayClicked(){
 
236
    if(cdAutoPlayCB->isChecked())
 
237
        configdata.autoplay = TRUE;
 
238
    else
 
239
        configdata.autoplay = FALSE;
 
240
} // autoPlayClicked
 
241
 
 
242
 
 
243
void
 
244
ConfigDlg::stopOnExitClicked()
 
245
{
 
246
    if(stopOnExitCB->isChecked())
 
247
        configdata.stopexit = TRUE;
 
248
    else
 
249
        configdata.stopexit = FALSE;
 
250
} // stopOnExitClicked
 
251
 
 
252
void
 
253
ConfigDlg::ejectOnFinishClicked()
 
254
{
 
255
    if(ejectOnFinishCB->isChecked())
 
256
        configdata.ejectonfinish = TRUE;
 
257
    else
 
258
        configdata.ejectonfinish = FALSE;
 
259
} // ejectOnFinishClicked
 
260
 
 
261
void
 
262
ConfigDlg::help()
 
263
{
 
264
    kapp->invokeHelp( QString::null,"kscd" );
 
265
} // help
 
266
 
 
267
void
 
268
ConfigDlg::cancelbutton()
 
269
{
 
270
  reject();
 
271
} // cancelbutton
 
272
 
 
273
void
 
274
ConfigDlg::set_led_color()
 
275
{
 
276
  KColorDialog::getColor(configdata.led_color);
 
277
  qframe1->setBackgroundColor(configdata.led_color);
 
278
} // set_led_color
 
279
 
 
280
void
 
281
ConfigDlg::set_background_color()
 
282
{
 
283
 
 
284
  KColorDialog::getColor(configdata.background_color);
 
285
  qframe2->setBackgroundColor(configdata.background_color);
 
286
} // set_background_color
 
287
 
 
288
void
 
289
ConfigDlg::randomOnceClicked()
 
290
{
 
291
  if(randomOnceCB->isChecked())
 
292
    configdata.randomonce = TRUE;
 
293
  else
 
294
    configdata.randomonce = FALSE;
 
295
} // randomOnceClicked
 
296
 
 
297
struct configstruct *
 
298
ConfigDlg::getData()
 
299
{
 
300
  configdata.browsercmd = custom_edit->text();
 
301
  return &configdata;
 
302
} // getData
 
303
 
 
304
#include "configdlg.moc"
 
305
 
 
306
 
 
307
 
 
308