Source Code (Use browser search to find items of interest.)
Class Index
ktalkd'KSoundPageConfig (./kdenetwork/ktalkd/kcmktalkd/soundpage.h:47)
class KSoundPageConfig : public KCModule
{
Q_OBJECT
public:
KSoundPageConfig( QWidget *parent=0, const char* name=0,
KSimpleConfig *config=0, KSimpleConfig *announceconfig=0);
~KSoundPageConfig( );
void load();
void save();
void defaults();
bool eventFilter(QObject* o, QEvent* e);
private slots:
void soundOnOff();
void playCurrentSound();
void slotChanged();
// Sound DnD
void sound_listDragEnterEvent(QDragEnterEvent* e);
void sound_listDropEvent(QDropEvent* e);
private:
KSimpleConfig *config;
KSimpleConfig *announceconfig;
bool delete_config;
QLabel *extprg_label;
QLineEdit *extprg_edit;
QLabel *client_label;
QLineEdit *client_edit;
QCheckBox *sound_cb;
QLabel *sound_label;
QListBox *sound_list;
QLabel *sound_tip;
QPushButton *btn_test;
KStandardDirs stddirs;
int findInSound_List(QString sound);
bool addToSound_List(QString sound);
};
ktalkd'KSoundPageConfig::KSoundPageConfig() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:44)
KSoundPageConfig::KSoundPageConfig( QWidget *parent, const char* name,
KSimpleConfig *_config, KSimpleConfig *_announceconfig)
: KCModule (parent, name)
{
if (!_config) {
delete_config = true;
config = new KSimpleConfig("ktalkdrc");
announceconfig = new KSimpleConfig("");
}
else {
delete_config = false;
config = _config;
announceconfig = _announceconfig;
}
QBoxLayout* toplay = new QVBoxLayout(this, 10, 10);
QGroupBox* extprg_box = new QGroupBox(this);
toplay->addWidget(extprg_box);
QGridLayout* l = new QGridLayout(extprg_box, 6, 6);
l->addColSpacing(1, 10); l->addRowSpacing(1, 10);
l->addColSpacing(3, 10); l->addRowSpacing(3, 10);
l->addColSpacing(5, 10); l->addRowSpacing(5, 10);
extprg_edit = new QLineEdit(extprg_box);
l->addWidget(extprg_edit, 2, 4);
extprg_label = new QLabel(extprg_edit,i18n("&Announcement program"), extprg_box);
l->addWidget(extprg_label, 2, 2);
client_edit = new QLineEdit(extprg_box);
l->addWidget(client_edit, 4, 4);
client_label = new QLabel(client_edit,i18n("&Talk client"), extprg_box);
l->addWidget(client_label, 4, 2);
toplay->addSpacing(30);
sound_cb = new QCheckBox(i18n("&Play sound"), this);
toplay->addWidget(sound_cb);
QGroupBox* sound_box = new QGroupBox(this);
toplay->addWidget(sound_box);
QBoxLayout* lay = new QVBoxLayout(sound_box, 10, 10);
int edit_h = client_edit->height(); // The height of a QLineEdit
sound_list = new QListBox(sound_box);
sound_list->setMinimumHeight( 3 * edit_h );
sound_list->setAcceptDrops(true);
sound_list->installEventFilter(this);
sound_label = new QLabel(sound_list,i18n("&Sound File"), sound_box);
lay->addWidget(sound_label);
QBoxLayout* l2 = new QHBoxLayout(lay, 10);
l2->addWidget(sound_list);
btn_test = new QPushButton(i18n("&Test"), sound_box);
l2->addWidget(btn_test);
sound_tip = new QLabel(
i18n("Additional WAV files can be dropped onto the sound list."),
sound_box);
lay->addWidget(sound_tip);
QStringList strlist( KGlobal::dirs()->findAllResources( "sound" ) );
sound_list->insertStringList( strlist );
load();
connect(sound_cb, SIGNAL(clicked()), this, SLOT(soundOnOff()));
connect(btn_test, SIGNAL(clicked()), this, SLOT(playCurrentSound()));
// emit changed(true) on changes
connect(extprg_edit, SIGNAL(textChanged(const QString&)), this, SLOT(slotChanged()));
connect(client_edit, SIGNAL(textChanged(const QString&)), this, SLOT(slotChanged()));
}
ktalkd'KSoundPageConfig::~KSoundPageConfig() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:126)
KSoundPageConfig::~KSoundPageConfig( ) {
if (delete_config) {
delete config;
delete announceconfig;
}
delete extprg_label;
delete extprg_edit;
delete client_label;
delete client_edit;
delete sound_cb;
delete sound_label;
delete sound_list;
delete sound_tip;
delete btn_test;
}
ktalkd'KSoundPageConfig::slotChanged() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:143)
void KSoundPageConfig::slotChanged() {
emit changed(true);
}
ktalkd'KSoundPageConfig::eventFilter() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:147)
bool KSoundPageConfig::eventFilter(QObject* /*o*/, QEvent* e)
{
if (e->type() == QEvent::DragEnter) {
sound_listDragEnterEvent((QDragEnterEvent *) e);
return true;
}
if (e->type() == QEvent::Drop) {
sound_listDropEvent((QDropEvent *) e);
return true;
}
return false;
}
ktalkd'KSoundPageConfig::sound_listDragEnterEvent() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:163)
void KSoundPageConfig::sound_listDragEnterEvent(QDragEnterEvent* e)
{
e->accept(QUriDrag::canDecode(e));
}
ktalkd'KSoundPageConfig::sound_listDropEvent() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:168)
void KSoundPageConfig::sound_listDropEvent(QDropEvent* e){
QStrList list;
// This should never happen, but anyway...
if(!QUriDrag::decode(e, list))
return;
QString msg;
int i, len;
// For now, we do only accept FILES ending with .wav...
len = list.count();
for ( i = 0; i < len; i++) {
QString url = list.at(i);
if ("file:" != url.left(5)) { // for now, only file URLs are supported
QMessageBox::warning(this, i18n("Unsupported URL"),
i18n("Sorry, this type of URL is currently unsupported"\
"by the KDE System Sound Module"),
i18n("OK"));
} else { // Now check for the ending ".wav"
if (stricmp(".WAV",url.right(4))) {
msg = i18n("Sorry, but \n%1\ndoes not seem "\
"to be a WAV--file.").arg(url);
QMessageBox::warning(this, i18n("Improper File Extension"), msg, i18n("OK"));
} else { // Hurra! Finally we've got a WAV file to add to the list
url = url.right(url.length()-5); // strip the leading "file:"
if (!addToSound_List(url)) {
// did not add file because it is already in the list
msg = i18n("The file\n"
"%1\n"
"is already in the list")
.arg(url);
QMessageBox::warning(this, i18n("File Already in List"), msg, i18n("OK"));
}
}
}
}
}
ktalkd'KSoundPageConfig::findInSound_List() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:221)
int KSoundPageConfig::findInSound_List(QString sound) {
// Searches for <sound> in sound_list. Returns position or -1 if not found
bool found = false;
int i = 0;
int len = sound_list->count();
while ((!found) && (i < len)) {
found = sound == sound_list->text(i);
i++;
}
return (found ? i-1 : -1);
}
ktalkd'KSoundPageConfig::addToSound_List() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:237)
bool KSoundPageConfig::addToSound_List(QString sound){
// Add "sound" to the sound list, but only if it is not already there
bool found = (findInSound_List(sound) != -1);
if (!found) { // Fine, the sound is not already in the sound list!
QString *tmp = new QString(sound); // take a copy...
sound_list->insertItem(*tmp);
sound_list->setTopItem(sound_list->count()-1);
slotChanged();
}
return !found;
}
ktalkd'KSoundPageConfig::playCurrentSound() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:253)
void KSoundPageConfig::playCurrentSound()
{
QString hlp, sname;
int soundno;
soundno = sound_list->currentItem();
if (soundno != -1) {
sname = sound_list->text(soundno);
if (sname[0] != '/')
KAudioPlayer::play(locate("sound", sname));
else
KAudioPlayer::play((char*)sname.data());
}
}
ktalkd'KSoundPageConfig::soundOnOff() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:268)
void KSoundPageConfig::soundOnOff()
{
bool b = sound_cb->isChecked();
sound_label->setEnabled(b);
sound_list->setEnabled(b);
btn_test->setEnabled(b);
sound_tip->setEnabled(b);
slotChanged();
}
ktalkd'KSoundPageConfig::defaults() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:279)
void KSoundPageConfig::defaults() {
extprg_edit->setText(stddirs.findResource("exe","ktalkdlg"));
client_edit->setText(stddirs.findResource("exe","kvt")+" -e talk");
// will be ktalk when ktalk is in CVS.
sound_cb->setChecked(true);
// Activate things according to configuration
soundOnOff();
}
ktalkd'KSoundPageConfig::load() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:290)
void KSoundPageConfig::load() {
config->setGroup("ktalkd");
announceconfig->setGroup("ktalkannounce");
setenv("KDEBINDIR",stddirs.kde_default("exe"),false/*don't overwrite*/);
// for the first reading of the config file
extprg_edit->setText(config->readEntry("ExtPrg",stddirs.findResource("exe","ktalkdlg")));
client_edit->setText(announceconfig->readEntry("talkprg",stddirs.findResource("exe","kvt")+" -e talk")); // will be ktalk when ktalk is in CVS
bool b = announceconfig->readBoolEntry("Sound",true/*default value*/);
sound_cb->setChecked(b);
const QString soundFile = announceconfig->readEntry("SoundFile","");
if (!soundFile.isEmpty())
{
int pos = findInSound_List(soundFile);
if (pos != -1) sound_list->setSelected(pos,true);
else {
addToSound_List(soundFile);
sound_list->setSelected(sound_list->count()-1,true);
}
} else { sound_list->setSelected(0,true); }
// Activate things according to configuration
soundOnOff();
emit changed(false);
}
ktalkd'KSoundPageConfig::save() (./kdenetwork/ktalkd/kcmktalkd/soundpage.cpp:321)
void KSoundPageConfig::save() {
config->setGroup("ktalkd");
config->writeEntry("ExtPrg", extprg_edit->text());
config->sync();
announceconfig->setGroup("ktalkannounce");
announceconfig->writeEntry("talkprg", client_edit->text());
announceconfig->writeEntry("Sound", sound_cb->isChecked());
announceconfig->writeEntry("SoundFile",sound_list->text(sound_list->currentItem()));
announceconfig->sync();
}