when getting the user info for the dialog, make sure that we update the
[kdenetwork.git] / kget / dlgSystem.cpp
blob8d9d0c02d4b3cc8c5d10cc189dcabc2279520318
1 /***************************************************************************
2 * dlgSystem.cpp
3 * -------------------
5 * Revision : $Id$
6 * begin : Tue Jan 29 2002
7 * copyright : (C) 2002 by Patrick Charbonnier
8 * : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss
9 * email : pch@freeshell.org
11 ****************************************************************************/
13 /***************************************************************************
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 ***************************************************************************/
28 #include <qcheckbox.h>
29 #include <qradiobutton.h>
30 #include <qpushbutton.h>
32 #ifdef index
33 #undef index
34 #endif
36 #include <kcombobox.h>
37 #include <kaudioplayer.h>
38 #include <kurlrequesterdlg.h>
39 #include <kfontrequester.h>
40 #include <klocale.h>
41 #include <kdialog.h>
42 #include <kio/netaccess.h>
43 #include <kfiledialog.h>
44 #include "settings.h"
45 #include "kmainwidget.h"
46 #include "dlgSystem.h"
48 #include <qbuttongroup.h>
49 #include <qlabel.h>
52 DlgSystem::DlgSystem(QWidget * parent)
53 : DlgSystemBase(parent)
55 bg_window->hide();
56 textLabel4->hide();
60 void DlgSystem::setupSound()
62 sDebugIn << endl;
63 QString s, t;
65 int id = cmb_sounds->currentItem();
67 switch (id)
69 case 0:
70 s = i18n("Sound file name for action 'added':");
71 t = soundAdded;
72 break;
73 case 1:
74 s = i18n("Sound file name for action 'started':");
75 t = soundStarted;
76 break;
77 case 2:
78 s = i18n("Sound file name for action 'finished':");
79 t = soundFinished;
80 break;
81 case 3:
82 s = i18n("Sound file name for action 'finished-all':");
83 t = soundFinishedAll;
84 break;
86 KURLRequesterDlg *box = new KURLRequesterDlg(t, s, this, "kurl_sound");
87 KFileDialog *pDlg = box->fileDialog();
88 pDlg->setFilter(i18n("*.wav|WAV Files\n*|All Files"));
89 int result = box->exec();
90 sDebug << "Result= " << result << endl;
92 if (result == QDialog::Rejected)
93 { /* cancelled */
94 sDebug << "Cancelled" << endl;
95 delete box;
96 return;
99 s = box->selectedURL().url(); // text();
100 delete box;
102 sDebug << "Selected audio files: " << s << endl;
103 if (s.isEmpty())
104 { /* answer is "" */
105 sDebugOut << "empty selection" << endl;
106 return;
109 switch (id)
111 case 0:
112 soundAdded = s;
113 break;
115 case 1:
116 soundStarted = s;
117 break;
119 case 2:
120 soundFinished = s;
121 break;
123 case 3:
124 soundFinishedAll = s;
125 break;
127 sDebugOut << endl;
128 slotChanged();
132 void DlgSystem::testSound()
134 sDebug << ">>>>Entering" << endl;
136 QString soundFile;
138 switch (cmb_sounds->currentItem())
140 case 0:
141 soundFile = soundAdded;
142 break;
143 case 1:
144 soundFile = soundStarted;
145 break;
146 case 2:
147 soundFile = soundFinished;
148 break;
149 case 3:
150 soundFile = soundFinishedAll;
151 break;
153 QString tmpFile;
154 sDebug << "File to play " << soundFile << endl;
155 // KAudioPlayer::play(soundFile);
156 // KAudioPlayer::play( "/home/pch/pop.wav");
158 if (KIO::NetAccess::download(KURL( soundFile ), tmpFile))
160 sDebug << "Temp file to play is " << tmpFile << endl;
161 KAudioPlayer::play(tmpFile);
162 KIO::NetAccess::removeTempFile(tmpFile);
166 sDebug << "<<<<Leaving" << endl;
170 void DlgSystem::setData()
172 cb_useSound->setChecked(ksettings.b_useSound);
173 cmb_sounds->setEnabled(ksettings.b_useSound);
174 pb_changesound->setEnabled(ksettings.b_useSound);
175 pb_testsound->setEnabled(ksettings.b_useSound);
177 soundAdded = ksettings.audioAdded;
178 soundStarted = ksettings.audioStarted;
179 soundFinished = ksettings.audioFinished;
180 soundFinishedAll = ksettings.audioFinishedAll;
182 cb_useAnimation->setChecked(ksettings.b_useAnimation);
184 le_font->setFont(ksettings.listViewFont);
188 void DlgSystem::applyData()
190 if (cb_useSound->isChecked() != ksettings.b_useSound)
192 kmain->slotToggleSound();
195 QString tmpFile;
197 if (KIO::NetAccess::download(KURL( soundAdded ), tmpFile ))
198 ksettings.audioAdded = tmpFile;
199 if (KIO::NetAccess::download(KURL( soundStarted ), tmpFile))
200 ksettings.audioStarted = tmpFile;
201 if (KIO::NetAccess::download(KURL( soundFinished ), tmpFile))
202 ksettings.audioFinished = tmpFile;
203 if (KIO::NetAccess::download(KURL( soundFinishedAll ), tmpFile))
204 ksettings.audioFinishedAll = tmpFile;
206 if (cb_useAnimation->isChecked() != ksettings.b_useAnimation)
208 kmain->slotToggleAnimation();
211 ksettings.listViewFont = le_font->font();
212 kmain->setListFont();
215 void DlgSystem::slotChanged()
217 emit configChanged();
220 #include "dlgSystem.moc"