9 #include "kmfawidgets.h"
11 #include <tdeabc/addresseedialog.h>
12 #include <kiconloader.h>
13 #include <tdelocale.h>
14 #include <kaudioplayer.h>
15 #include <kurlrequester.h>
16 #include <tdefiledialog.h>
17 #include <kstandarddirs.h>
20 #include <tqtooltip.h>
28 KMFilterActionWithAddressWidget::KMFilterActionWithAddressWidget( TQWidget* parent,
const char* name )
29 : TQWidget( parent, name )
31 TQHBoxLayout *hbl =
new TQHBoxLayout(
this);
33 mLineEdit =
new KLineEdit(
this);
34 mLineEdit->setName(
"addressEdit" );
35 hbl->addWidget( mLineEdit, 1 );
36 mBtn =
new TQPushButton( TQString() ,
this );
37 mBtn->setPixmap( BarIcon(
"contents", TDEIcon::SizeSmall ) );
38 mBtn->setFixedHeight( mLineEdit->sizeHint().height() );
39 TQToolTip::add( mBtn, i18n(
"Open Address Book" ) );
40 hbl->addWidget( mBtn );
42 connect( mBtn, TQ_SIGNAL(clicked()),
43 this, TQ_SLOT(slotAddrBook()) );
44 connect( mLineEdit, TQ_SIGNAL( textChanged(
const TQString&) ),
45 this, TQ_SIGNAL( textChanged(
const TQString&) ) );
48 void KMFilterActionWithAddressWidget::slotAddrBook()
50 TDEABC::Addressee::List lst = TDEABC::AddresseeDialog::getAddressees(
this );
55 TQStringList addrList;
57 for( TDEABC::Addressee::List::const_iterator it = lst.begin(); it != lst.end(); ++it )
58 addrList << (*it).fullEmail();
60 TQString txt = mLineEdit->text().stripWhiteSpace();
62 if ( !txt.isEmpty() ) {
63 if ( !txt.endsWith(
"," ) )
69 mLineEdit->setText( txt + addrList.join(
",") );
72 KMSoundTestWidget::KMSoundTestWidget(TQWidget *parent,
const char *name)
73 : TQWidget( parent, name)
75 TQHBoxLayout *lay1 =
new TQHBoxLayout(
this );
76 m_playButton =
new TQPushButton(
this,
"m_playButton" );
77 m_playButton->setPixmap( SmallIcon(
"1rightarrow" ) );
78 connect( m_playButton, TQ_SIGNAL( clicked() ), TQ_SLOT( playSound() ));
79 lay1->addWidget( m_playButton );
81 m_urlRequester =
new KURLRequester(
this );
82 lay1->addWidget( m_urlRequester );
83 connect( m_urlRequester, TQ_SIGNAL( openFileDialog( KURLRequester * )),
84 TQ_SLOT( openSoundDialog( KURLRequester * )));
85 connect( m_urlRequester->lineEdit(), TQ_SIGNAL( textChanged (
const TQString & )), TQ_SLOT( slotUrlChanged(
const TQString & )));
86 slotUrlChanged(m_urlRequester->lineEdit()->text() );
89 KMSoundTestWidget::~KMSoundTestWidget()
93 void KMSoundTestWidget::slotUrlChanged(
const TQString &_text )
95 m_playButton->setEnabled( !_text.isEmpty());
98 void KMSoundTestWidget::openSoundDialog( KURLRequester * )
100 static bool init =
true;
106 KFileDialog *fileDialog = m_urlRequester->fileDialog();
107 fileDialog->setCaption( i18n(
"Select Sound File") );
108 TQStringList filters;
109 filters <<
"audio/x-wav" <<
"audio/x-mp3" <<
"application/x-ogg"
111 fileDialog->setMimeFilter( filters );
113 TQStringList soundDirs = TDEGlobal::dirs()->resourceDirs(
"sound" );
115 if ( !soundDirs.isEmpty() ) {
118 dir.setFilter( TQDir::Files | TQDir::Readable );
119 TQStringList::ConstIterator it = soundDirs.begin();
120 while ( it != soundDirs.end() ) {
122 if ( dir.isReadable() && dir.count() > 2 ) {
123 soundURL.setPath( *it );
124 fileDialog->setURL( soundURL );
133 void KMSoundTestWidget::playSound()
135 TQString parameter= m_urlRequester->lineEdit()->text();
136 if ( parameter.isEmpty() )
138 TQString play = parameter;
139 TQString file = TQString::fromLatin1(
"file:");
140 if (parameter.startsWith(file))
141 play = parameter.mid(file.length());
142 KAudioPlayer::play(TQFile::encodeName(play));
146 TQString KMSoundTestWidget::url()
const
148 return m_urlRequester->lineEdit()->text();
151 void KMSoundTestWidget::setUrl(
const TQString & url)
153 m_urlRequester->lineEdit()->setText(url);
156 void KMSoundTestWidget::clear()
158 m_urlRequester->lineEdit()->clear();
162 #include "kmfawidgets.moc"