• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/kopete

  • sources
  • kde-4.12
  • kdenetwork
  • kopete
  • kopete
  • contactlist
kopetelviprops.cpp
Go to the documentation of this file.
1 /*
2  kopetelviprops.cpp
3 
4  Kopete Contactlist Properties GUI for Groups and MetaContacts
5 
6  Copyright (c) 2002-2003 by Stefan Gehn <metz@gehn.net>
7  Copyright (c) 2004 by Will Stephenson <wstephenson@kde.org>
8  Copyright (c) 2004-2005 by Duncan Mac-Vicar P. <duncan@kde.org>
9 
10  Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
11 
12  *************************************************************************
13  * *
14  * This program is free software; you can redistribute it and/or modify *
15  * it under the terms of the GNU General Public License as published by *
16  * the Free Software Foundation; either version 2 of the License, or *
17  * (at your option) any later version. *
18  * *
19  *************************************************************************
20 */
21 
22 #include "kopetelviprops.h"
23 
24 #include <kdebug.h>
25 
26 #include <qapplication.h>
27 #include <qcheckbox.h>
28 #include <qlabel.h>
29 #include <qlayout.h>
30 #include <qpushbutton.h>
31 #include <qradiobutton.h>
32 #include <qtabwidget.h>
33 #include <qcombobox.h>
34 #include <QPixmap>
35 #include <QVBoxLayout>
36 #include <QHBoxLayout>
37 #include <QBoxLayout>
38 #include <QSize>
39 
40 #include <kfiledialog.h>
41 #include <kicondialog.h>
42 #include <kiconloader.h>
43 #include <klocale.h>
44 #include <kmessagebox.h>
45 #include <kurlrequester.h>
46 #include <kabc/addresseedialog.h>
47 #include <kabc/stdaddressbook.h>
48 #include <kabc/addressee.h>
49 #include <kstandarddirs.h>
50 
51 #include "kabcpersistence.h"
52 #include "kopeteaddrbookexport.h"
53 #include "kopetecontact.h"
54 #include "kopetegroup.h"
55 #include "kopeteaccount.h"
56 #include "kopeteprotocol.h"
57 #include "addressbooklinkwidget.h"
58 #include "avatardialog.h"
59 
60 #include "customnotificationprops.h"
61 
62 const QLatin1String MC_OFF( "user-offline" );
63 const QLatin1String MC_ON( "user-online" );
64 const QLatin1String MC_AW( "user-away" );
65 const QLatin1String MC_UNK( "metacontact_unknown" );
66 
67 // KDE4 port notes:
68 // setIcon has changed, so it has been commented out.
69 // also cmbPhotoUrl is gone completely. Let's pray for it
70 
71 KopeteGVIProps::KopeteGVIProps(Kopete::Group *group, QWidget *parent)
72 : KDialog(parent), mGroup( group )
73 {
74  setCaption( i18n("Properties of Group %1", mGroup->displayName()) );
75  setButtons( Ok | Cancel );
76 
77  mainWidget = new QWidget( this );
78  mainWidget->setObjectName( "mainWidget" );
79  ui_mainWidget = new Ui::KopeteGVIPropsWidget;
80  ui_mainWidget->setupUi( mainWidget );
81 
82  ui_mainWidget->icnbOpen->setIconSize(QSize(KIconLoader::SizeSmall,KIconLoader::SizeSmall));
83  ui_mainWidget->icnbClosed->setIconSize(QSize(KIconLoader::SizeSmall,KIconLoader::SizeSmall));
84  QPair<QString,QString> context=qMakePair( QString::fromLatin1("group") , QString::number(mGroup->groupId() ) );
85  mNotificationProps = new CustomNotificationProps( this, context );
86 
87  QWidget* npMainWidget = new QWidget();
88  QVBoxLayout* vbLayout = new QVBoxLayout( npMainWidget );
89  vbLayout->addWidget( mNotificationProps->widget() );
90  ui_mainWidget->tabWidget->addTab( npMainWidget, i18n( "Custom &Notifications" ) );
91 
92  setMainWidget(mainWidget);
93  m_dirty = false;
94 
95  ui_mainWidget->edtDisplayName->setText( mGroup->displayName() );
96 
97  ui_mainWidget->chkUseCustomIcons->setChecked( mGroup->useCustomIcon() );
98 
99 // QString openName = mGroup->icon( Kopete::ContactListElement::Open );
100 // if(openName.isEmpty())
101 // openName = KOPETE_GROUP_DEFAULT_OPEN_ICON;
102 // QString closeName = mGroup->icon( Kopete::ContactListElement::Closed );
103 // if(closeName.isEmpty())
104 // closeName = KOPETE_GROUP_DEFAULT_CLOSED_ICON;
105 // ui_mainWidget->icnbOpen->setIcon( openName );
106 // ui_mainWidget->icnbClosed->setIcon( closeName );
107 
108  connect( this, SIGNAL(okClicked()), this, SLOT(slotOkClicked()) );
109  connect( ui_mainWidget->chkUseCustomIcons, SIGNAL(toggled(bool)),
110  this, SLOT(slotUseCustomIconsToggled(bool)) );
111  connect( ui_mainWidget->icnbOpen, SIGNAL(iconChanged(QString)),
112  SLOT(slotIconChanged()) );
113  connect( ui_mainWidget->icnbClosed, SIGNAL(iconChanged(QString)),
114  SLOT(slotIconChanged()) );
115  slotUseCustomIconsToggled( ui_mainWidget->chkUseCustomIcons->isChecked() );
116 }
117 
118 KopeteGVIProps::~KopeteGVIProps()
119 {
120  delete ui_mainWidget;
121 }
122 
123 void KopeteGVIProps::slotOkClicked()
124 {
125  if( ui_mainWidget->edtDisplayName->text() != mGroup->displayName() )
126  {
127  mGroup->setDisplayName( ui_mainWidget->edtDisplayName->text() );
128  }
129 
130  mGroup->setUseCustomIcon( ui_mainWidget->chkUseCustomIcons->isChecked() );
131 
132  // only call setIcon if the icon was changed
133  if( m_dirty )
134  {
135 /* mGroup->setIcon( ui_mainWidget->icnbOpen->icon(),
136  Kopete::ContactListElement::Open );
137 
138  mGroup->setIcon( ui_mainWidget->icnbClosed->icon(),
139  Kopete::ContactListElement::Closed );
140 */ }
141 
142  mNotificationProps->storeCurrentCustoms();
143 }
144 
145 void KopeteGVIProps::slotUseCustomIconsToggled(bool on)
146 {
147  ui_mainWidget->lblOpen->setEnabled( on );
148  ui_mainWidget->icnbOpen->setEnabled( on );
149  ui_mainWidget->lblClosed->setEnabled( on );
150  ui_mainWidget->icnbClosed->setEnabled( on );
151 }
152 
153 void KopeteGVIProps::slotIconChanged()
154 {
155  m_dirty = true;
156 }
157 
158 // =============================================================================
159 
160 
161 KopeteMetaLVIProps::KopeteMetaLVIProps(Kopete::MetaContact *metaContact, QWidget *parent)
162 : KDialog(parent), mMetaContact( metaContact )
163 {
164  setCaption( i18n("Properties of Meta Contact %1", mMetaContact->displayName()) );
165  setButtons( Ok | Cancel );
166  m_countPhotoCapable = 0;
167 
168  mainWidget = new QWidget( this );
169  mainWidget->setObjectName( "mainWidget" );
170  ui_mainWidget = new Ui::KopeteMetaLVIPropsWidget;
171  ui_mainWidget->setupUi( mainWidget );
172 
173  ui_mainWidget->icnbOffline->setIconSize( QSize(KIconLoader::SizeSmall,KIconLoader::SizeSmall) );
174  ui_mainWidget->icnbOnline->setIconSize( QSize(KIconLoader::SizeSmall,KIconLoader::SizeSmall) );
175  ui_mainWidget->icnbAway->setIconSize( QSize(KIconLoader::SizeSmall,KIconLoader::SizeSmall) );
176  ui_mainWidget->icnbUnknown->setIconSize( QSize(KIconLoader::SizeSmall,KIconLoader::SizeSmall) );
177 
178  QPair<QString,QString> context=qMakePair( QString::fromLatin1("contact"), mMetaContact->metaContactId().toString() );
179  mNotificationProps = new CustomNotificationProps( this, context );
180  // add a button to the notification props to get the sound from KABC
181  // the widget's vert box layout, horiz box layout containing button, spacer, followed by a spacer
182  QBoxLayout * vb = static_cast<QVBoxLayout*>( mNotificationProps->widget()->layout() );
183 
184  QHBoxLayout* hb = new QHBoxLayout();
185  vb->addItem( hb );
186  hb->setMargin( -1 );
187  hb->setObjectName( "soundFromKABClayout" );
188 
189  mFromKABC = new QPushButton( i18n( "Sync KABC..." ), mNotificationProps->widget() );
190  mFromKABC->setObjectName( QLatin1String("getSoundFromKABC") );
191  hb->addWidget( mFromKABC ); // [ [Button] <-xxxxx-> ]
192  hb->addStretch();
193  vb->addStretch(); // vert spacer keeps the rest snug
194 
195  QWidget* npMainWidget = new QWidget();
196  QVBoxLayout* vbLayout = new QVBoxLayout( npMainWidget );
197  vbLayout->addWidget( mNotificationProps->widget() );
198 
199  ui_mainWidget->tabWidget->addTab( npMainWidget, i18n( "Custom &Notifications" ) );
200  setMainWidget( mainWidget );
201 
202  connect( ui_mainWidget->radioNameKABC, SIGNAL(toggled(bool)), SLOT(slotEnableAndDisableWidgets()));
203  connect( ui_mainWidget->radioNameContact, SIGNAL(toggled(bool)), SLOT(slotEnableAndDisableWidgets()));
204  connect( ui_mainWidget->radioNameCustom, SIGNAL(toggled(bool)), SLOT(slotEnableAndDisableWidgets()));
205  connect( ui_mainWidget->radioPhotoKABC, SIGNAL(toggled(bool)), SLOT(slotEnableAndDisableWidgets()));
206  connect( ui_mainWidget->radioPhotoContact, SIGNAL(toggled(bool)), SLOT(slotEnableAndDisableWidgets()));
207  connect( ui_mainWidget->radioPhotoCustom, SIGNAL(toggled(bool)), SLOT(slotEnableAndDisableWidgets()));
208  connect( ui_mainWidget->cmbAccountPhoto, SIGNAL(activated(int)), SLOT(slotEnableAndDisableWidgets()));
209 
210 
211  ui_mainWidget->btnClearPhoto->setIcon( KIcon( (QApplication::layoutDirection() == Qt::RightToLeft) ? "edit-clear-locationbar-ltr" : "edit-clear-locationbar-rtl" ) );
212  connect( ui_mainWidget->btnClearPhoto, SIGNAL(clicked()), this, SLOT(slotClearPhotoClicked()) );
213  connect( ui_mainWidget->widAddresseeLink, SIGNAL(addresseeChanged(KABC::Addressee)), SLOT(slotAddresseeChanged(KABC::Addressee)) );
214  connect( ui_mainWidget->btnChoosePhoto, SIGNAL(clicked()), this, SLOT(slotSelectPhoto()));
215  ui_mainWidget->chkUseCustomIcons->setChecked( mMetaContact->useCustomIcon() );
216 
217  QString offlineName = mMetaContact->icon( Kopete::ContactListElement::Offline );
218  if(offlineName.isEmpty())
219  offlineName = MC_OFF; // Default
220 
221  QString onlineName = mMetaContact->icon( Kopete::ContactListElement::Online );
222  if(onlineName.isEmpty())
223  onlineName = MC_ON; // Default
224 
225  QString awayName = mMetaContact->icon( Kopete::ContactListElement::Away );
226  if(awayName.isEmpty())
227  awayName = MC_AW; // Default
228 
229  QString unknownName = mMetaContact->icon( Kopete::ContactListElement::Unknown );
230  if(unknownName.isEmpty())
231  unknownName = MC_UNK; // Default
232 
233 // ui_mainWidget->icnbOffline->setIcon( offlineName );
234 // ui_mainWidget->icnbOnline->setIcon( onlineName );
235 // ui_mainWidget->icnbAway->setIcon( awayName );
236 // ui_mainWidget->icnbUnknown->setIcon( unknownName );
237 
238  ui_mainWidget->widAddresseeLink->setMetaContact( mMetaContact );
239 
240  mAddressBookUid = mMetaContact->kabcId();
241 
242  mExport = 0L;
243 
244  if ( !mAddressBookUid.isEmpty() )
245  {
246  KABC::AddressBook *ab = Kopete::KABCPersistence::self()->addressBook();
247  KABC::Addressee a = ab->findByUid( mAddressBookUid );
248  ui_mainWidget->widAddresseeLink->setAddressee( a );
249 
250  if ( !a.isEmpty() )
251  {
252  ui_mainWidget->btnImportKABC->setEnabled( true );
253  ui_mainWidget->btnExportKABC->setEnabled( true );
254  mExport = new KopeteAddressBookExport( this, mMetaContact );
255 
256  mSound = a.sound();
257  mFromKABC->setEnabled( !( mSound.isIntern() || mSound.url().isEmpty() ) );
258  }
259  }
260 
261  slotLoadNameSources();
262  slotLoadPhotoSources();
263 
264  connect( this, SIGNAL(okClicked()), this, SLOT(slotOkClicked()) );
265  connect( ui_mainWidget->chkUseCustomIcons, SIGNAL(toggled(bool)),
266  this, SLOT(slotUseCustomIconsToggled(bool)) );
267  connect( ui_mainWidget->btnImportKABC, SIGNAL(clicked()),
268  this, SLOT(slotImportClicked()) );
269  connect( ui_mainWidget->btnExportKABC, SIGNAL(clicked()),
270  this, SLOT(slotExportClicked()) );
271  connect( mFromKABC, SIGNAL(clicked()),
272  this, SLOT(slotFromKABCClicked()) );
273 
274  slotUseCustomIconsToggled( ui_mainWidget->chkUseCustomIcons->isChecked() );
275  slotEnableAndDisableWidgets();
276 }
277 
278 KopeteMetaLVIProps::~KopeteMetaLVIProps()
279 {
280  delete ui_mainWidget;
281 }
282 
283 
284 void KopeteMetaLVIProps::slotLoadNameSources()
285 {
286  Kopete::Contact* trackingName = mMetaContact->displayNameSourceContact();
287  QList<Kopete::Contact*> cList = mMetaContact->contacts();
288  QList<Kopete::Contact*>::iterator it = cList.begin();
289  ui_mainWidget->cmbAccountName->clear();
290  for( ; it != cList.end(); ++it )
291  {
292  QString acct = (*it)->property( Kopete::Global::Properties::self()->nickName() ).value().toString() + " <" + (*it)->contactId() + '>';
293  QPixmap acctIcon = (*it)->account()->accountIcon();
294  ui_mainWidget->cmbAccountName->addItem( QIcon(acctIcon), acct );
295 
296  // Select this item if it's the one we're tracking.
297  if( (*it) == trackingName )
298  {
299  ui_mainWidget->cmbAccountName->setCurrentIndex( ui_mainWidget->cmbAccountName->count() - 1 );
300  }
301  }
302 
303  ui_mainWidget->edtDisplayName->setText( mMetaContact->customDisplayName() );
304 
305  Kopete::MetaContact::PropertySource nameSource = mMetaContact->displayNameSource();
306 
307  ui_mainWidget->radioNameContact->setChecked(nameSource == Kopete::MetaContact::SourceContact);
308  ui_mainWidget->radioNameKABC->setChecked(nameSource == Kopete::MetaContact::SourceKABC);
309  ui_mainWidget->radioNameCustom->setChecked(nameSource == Kopete::MetaContact::SourceCustom);
310 
311 }
312 
313 void KopeteMetaLVIProps::slotLoadPhotoSources()
314 {
315  // fill photo contact sources
316  QList<Kopete::Contact*> cList = mMetaContact->contacts();
317  m_withPhotoContacts.clear();
318  Kopete::Contact* trackingPhoto = mMetaContact->photoSourceContact();
319  ui_mainWidget->cmbAccountPhoto->clear();
320  QList<Kopete::Contact*>::iterator itp = cList.begin();
321  for( ; itp != cList.end(); ++itp )
322  {
323  Kopete::Contact *citem = (*itp);
324  if ( citem->hasProperty( Kopete::Global::Properties::self()->photo().key() ) )
325  {
326  QString acct = citem->property( Kopete::Global::Properties::self()->nickName() ).value().toString() + " <" + citem->contactId() + '>';
327  QPixmap acctIcon = citem->account()->accountIcon();
328  ui_mainWidget->cmbAccountPhoto->addItem( QIcon(acctIcon), acct );
329 
330  // Select this item if it's the one we're tracking.
331  if( citem == trackingPhoto )
332  {
333  ui_mainWidget->cmbAccountPhoto->setCurrentIndex( ui_mainWidget->cmbAccountPhoto->count() - 1 );
334  }
335  m_withPhotoContacts.insert(ui_mainWidget->cmbAccountPhoto->count() - 1 , citem );
336  }
337  }
338 
339  m_photoPath = mMetaContact->customPhoto().path();
340 
341  Kopete::MetaContact::PropertySource photoSource = mMetaContact->photoSource();
342 
343  ui_mainWidget->radioPhotoContact->setChecked(photoSource == Kopete::MetaContact::SourceContact);
344  ui_mainWidget->radioPhotoKABC->setChecked(photoSource == Kopete::MetaContact::SourceKABC);
345  ui_mainWidget->radioPhotoCustom->setChecked(photoSource == Kopete::MetaContact::SourceCustom);
346 
347  ui_mainWidget->chkSyncPhoto->setChecked(mMetaContact->isPhotoSyncedWithKABC());
348 }
349 
350 void KopeteMetaLVIProps::slotSelectPhoto()
351 {
352  const QString path = Kopete::UI::AvatarDialog::getAvatar(this, m_photoPath);
353  if (path.isNull())
354  return;
355 
356  m_photoPath = path;
357  slotEnableAndDisableWidgets();
358 }
359 
360 void KopeteMetaLVIProps::slotEnableAndDisableWidgets()
361 {
362  KABC::AddressBook *ab = Kopete::KABCPersistence::self()->addressBook();
363  KABC::Addressee a = ab->findByUid( mAddressBookUid );
364  bool validLink = ! a.isEmpty();
365  // kabc source requires a kabc link
366  ui_mainWidget->radioNameKABC->setEnabled(validLink);
367  // kabc source requires a kabc link
368  ui_mainWidget->radioPhotoKABC->setEnabled(validLink);
369  // sync with kabc has no sense if we use kabc as source (sync kabc with kabc? uh?)
370  // it has also no sense if they are no kabc link
371  if( selectedPhotoSource() == Kopete::MetaContact::SourceKABC || !validLink )
372  {
373  ui_mainWidget->chkSyncPhoto->setEnabled(false);
374  }
375  else
376  {
377  ui_mainWidget->chkSyncPhoto->setEnabled(true);
378  }
379 
380  ui_mainWidget->radioNameContact->setEnabled(mMetaContact->contacts().count());
381  ui_mainWidget->radioPhotoContact->setEnabled(!m_withPhotoContacts.isEmpty());
382 
383  ui_mainWidget->cmbAccountName->setEnabled(selectedNameSource() == Kopete::MetaContact::SourceContact);
384  ui_mainWidget->edtDisplayName->setEnabled(selectedNameSource() == Kopete::MetaContact::SourceCustom);
385 
386  ui_mainWidget->cmbAccountPhoto->setEnabled(selectedPhotoSource() == Kopete::MetaContact::SourceContact);
387  ui_mainWidget->btnChoosePhoto->setEnabled(selectedPhotoSource() == Kopete::MetaContact::SourceCustom);
388 
389  if ( m_withPhotoContacts.isEmpty() )
390  {
391  ui_mainWidget->cmbAccountPhoto->clear();
392  ui_mainWidget->cmbAccountPhoto->addItem(i18n("No Contacts with Photo Support"));
393  ui_mainWidget->cmbAccountPhoto->setEnabled(false);
394  }
395 
396  QImage photo;
397  switch ( selectedPhotoSource() )
398  {
399  case Kopete::MetaContact::SourceKABC:
400  photo = Kopete::photoFromKABC(mAddressBookUid);
401  break;
402  case Kopete::MetaContact::SourceContact:
403  photo = Kopete::photoFromContact(selectedPhotoSourceContact());
404  break;
405  case Kopete::MetaContact::SourceCustom:
406  photo = QImage(m_photoPath);
407  break;
408  }
409  if( !photo.isNull() )
410  ui_mainWidget->photoLabel->setPixmap(QPixmap::fromImage(photo.scaled(96, 96)));
411  else
412  ui_mainWidget->photoLabel->setPixmap( QPixmap() );
413 }
414 
415 Kopete::MetaContact::PropertySource KopeteMetaLVIProps::selectedNameSource() const
416 {
417  if ( ui_mainWidget->radioNameKABC->isChecked() )
418  return Kopete::MetaContact::SourceKABC;
419  if ( ui_mainWidget->radioNameContact->isChecked() )
420  return Kopete::MetaContact::SourceContact;
421  if ( ui_mainWidget->radioNameCustom->isChecked() )
422  return Kopete::MetaContact::SourceCustom;
423  else
424  return Kopete::MetaContact::SourceCustom;
425 }
426 
427 Kopete::MetaContact::PropertySource KopeteMetaLVIProps::selectedPhotoSource() const
428 {
429  if ( ui_mainWidget->radioPhotoKABC->isChecked() )
430  return Kopete::MetaContact::SourceKABC;
431  if ( ui_mainWidget->radioPhotoContact->isChecked() )
432  return Kopete::MetaContact::SourceContact;
433  if ( ui_mainWidget->radioPhotoCustom->isChecked() )
434  return Kopete::MetaContact::SourceCustom;
435  else
436  return Kopete::MetaContact::SourceCustom;
437 }
438 
439 Kopete::Contact* KopeteMetaLVIProps::selectedNameSourceContact() const
440 {
441  return mMetaContact->contacts().value( ui_mainWidget->cmbAccountName->currentIndex(), 0 );
442 }
443 
444 Kopete::Contact* KopeteMetaLVIProps::selectedPhotoSourceContact() const
445 {
446  return m_withPhotoContacts.value( ui_mainWidget->cmbAccountPhoto->currentIndex(), 0 );
447 }
448 
449 void KopeteMetaLVIProps::slotOkClicked()
450 {
451  // update meta contact's UID
452  mMetaContact->setKabcId( mAddressBookUid );
453  //this has to be done first, in the case something is synced with KABC (see bug 109494)
454 
455  // set custom display name
456  if( ui_mainWidget->edtDisplayName->text() != mMetaContact->customDisplayName() )
457  mMetaContact->setDisplayName( ui_mainWidget->edtDisplayName->text() );
458 
459  mMetaContact->setDisplayNameSource(selectedNameSource());
460  mMetaContact->setDisplayNameSourceContact( selectedNameSourceContact() );
461 
462  // set photo source
463  mMetaContact->setPhotoSource(selectedPhotoSource());
464  mMetaContact->setPhotoSourceContact( selectedPhotoSourceContact() );
465  if ( !m_photoPath.isEmpty())
466  mMetaContact->setPhoto(KUrl(m_photoPath));
467  mMetaContact->setPhotoSyncedWithKABC( ui_mainWidget->chkSyncPhoto->isChecked() );
468 
469  mMetaContact->setUseCustomIcon(
470  ui_mainWidget->chkUseCustomIcons->isChecked() );
471 
472  // only call setIcon if any of the icons is not set to default icon
473 /*
474  if(
475  ui_mainWidget->icnbOffline->icon() != MC_OFF ||
476  ui_mainWidget->icnbOnline->icon() != MC_ON ||
477  ui_mainWidget->icnbAway->icon() != MC_AW ||
478  ui_mainWidget->icnbUnknown->icon() != MC_UNK )
479  {
480  mMetaContact->setIcon( ui_mainWidget->icnbOffline->icon(),
481  Kopete::ContactListElement::Offline );
482 
483  mMetaContact->setIcon( ui_mainWidget->icnbOnline->icon(),
484  Kopete::ContactListElement::Online );
485 
486  mMetaContact->setIcon( ui_mainWidget->icnbAway->icon(),
487  Kopete::ContactListElement::Away );
488 
489  mMetaContact->setIcon( ui_mainWidget->icnbUnknown->icon(),
490  Kopete::ContactListElement::Unknown );
491  }
492 */
493  mNotificationProps->storeCurrentCustoms();
494 }
495 
496 void KopeteMetaLVIProps::slotUseCustomIconsToggled(bool on)
497 {
498  ui_mainWidget->lblOffline->setEnabled( on );
499  ui_mainWidget->lblOnline->setEnabled( on );
500  ui_mainWidget->lblAway->setEnabled( on );
501  ui_mainWidget->lblUnknown->setEnabled( on );
502 
503  ui_mainWidget->icnbOffline->setEnabled( on );
504  ui_mainWidget->icnbOnline->setEnabled( on );
505  ui_mainWidget->icnbAway->setEnabled( on );
506  ui_mainWidget->icnbUnknown->setEnabled( on );
507 }
508 
509 void KopeteMetaLVIProps::slotAddresseeChanged( const KABC::Addressee & a )
510 {
511  if ( !a.isEmpty() )
512  {
513  mSound = a.sound();
514  mFromKABC->setEnabled( !( mSound.isIntern() || mSound.url().isEmpty() ) );
515  ui_mainWidget->btnExportKABC->setEnabled( true );
516  ui_mainWidget->btnImportKABC->setEnabled( true );
517  // set/update the MC's addressee uin field
518  mAddressBookUid = a.uid();
519  }
520  else
521  {
522  ui_mainWidget->btnExportKABC->setEnabled( false );
523  ui_mainWidget->btnImportKABC->setEnabled( false );
524  mAddressBookUid.clear();
525  ui_mainWidget->radioNameContact->setChecked( true );
526  ui_mainWidget->radioPhotoContact->setChecked( true );
527  }
528  slotEnableAndDisableWidgets();
529 }
530 
531 void KopeteMetaLVIProps::slotExportClicked()
532 {
533  mMetaContact->setKabcId( mAddressBookUid );
534  delete mExport;
535  mExport = new KopeteAddressBookExport( this, mMetaContact );
536  if ( mExport->showDialog() == QDialog::Accepted )
537  mExport->exportData();
538 }
539 
540 void KopeteMetaLVIProps::slotImportClicked()
541 {
542  mMetaContact->setKabcId( mAddressBookUid );
543  if ( Kopete::KABCPersistence::self()->syncWithKABC( mMetaContact ) )
544  KMessageBox::queuedMessageBox( this, KMessageBox::Information,
545  i18n( "No contacts were imported from the address book." ),
546  i18n( "No Change" ) );
547 }
548 
549 void KopeteMetaLVIProps::slotFromKABCClicked()
550 {
551 #if 0
552  mNotificationProps->widget()->customSound->setUrl( mSound.url() );
553 #endif
554 }
555 
556 void KopeteMetaLVIProps::slotOpenSoundDialog( KUrlRequester *requester )
557 {
558  // taken from kdelibs/kio/kfile/knotifydialog.cpp
559  // only need to init this once
560  requester->disconnect( SIGNAL(openFileDialog(KUrlRequester*)),
561  this, SLOT(slotOpenSoundDialog(KUrlRequester*)));
562 
563  KFileDialog *fileDialog = requester->fileDialog();
564  //fileDialog->setCaption( i18n("Select Sound File") );
565  QStringList filters;
566  filters << "audio/x-wav" << "audio/mpeg" << "application/ogg"
567  << "audio/x-adpcm";
568  fileDialog->setMimeFilter( filters );
569 
570  // find the first "sound"-resource that contains files
571  QStringList soundDirs =
572  KGlobal::dirs()->findDirs("data", "kopete/sounds");
573  soundDirs += KGlobal::dirs()->resourceDirs( "sound" );
574 
575  if ( !soundDirs.isEmpty() ) {
576  KUrl soundURL;
577  QDir dir;
578  dir.setFilter( QDir::Files | QDir::Readable );
579  QStringList::ConstIterator it = soundDirs.constBegin();
580  while ( it != soundDirs.constEnd() ) {
581  dir = *it;
582  if ( dir.isReadable() && dir.count() > 2 ) {
583  soundURL.setPath( *it );
584  fileDialog->setUrl( soundURL );
585  break;
586  }
587  ++it;
588  }
589  }
590 }
591 
592 void KopeteMetaLVIProps::slotClearPhotoClicked()
593 {
594  m_photoPath.clear();
595  mMetaContact->setPhoto( KUrl() );
596 
597  slotEnableAndDisableWidgets();
598 }
599 
600 #include "kopetelviprops.moc"
MC_AW
const QLatin1String MC_AW("user-away")
KopeteAddressBookExport
Definition: kopeteaddrbookexport.h:40
KopeteAddressBookExport::exportData
void exportData()
Export the data to KABC if changed, omitting any duplicates.
Definition: kopeteaddrbookexport.cpp:199
CustomNotificationProps::storeCurrentCustoms
void storeCurrentCustoms()
Definition: customnotificationprops.cpp:55
QWidget
KDialog
KopeteAddressBookExport::showDialog
int showDialog()
Display the dialog.
Definition: kopeteaddrbookexport.cpp:168
kopetelviprops.h
CustomNotificationProps::widget
QWidget * widget()
Definition: customnotificationprops.cpp:61
KopeteGVIProps::KopeteGVIProps
KopeteGVIProps(Kopete::Group *group, QWidget *parent)
Definition: kopetelviprops.cpp:71
kopeteaddrbookexport.h
Kopete::Items::MetaContact
Definition: kopeteitembase.h:57
Kopete::Items::Group
Definition: kopeteitembase.h:57
KopeteMetaLVIProps::KopeteMetaLVIProps
KopeteMetaLVIProps(Kopete::MetaContact *metaContact, QWidget *parent)
Definition: kopetelviprops.cpp:161
CustomNotificationProps
Definition: customnotificationprops.h:27
customnotificationprops.h
MC_ON
const QLatin1String MC_ON("user-online")
MC_OFF
const QLatin1String MC_OFF("user-offline")
MC_UNK
const QLatin1String MC_UNK("metacontact_unknown")
KopeteGVIProps::~KopeteGVIProps
~KopeteGVIProps()
Definition: kopetelviprops.cpp:118
KopeteMetaLVIProps::~KopeteMetaLVIProps
~KopeteMetaLVIProps()
Definition: kopetelviprops.cpp:278
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/kopete

Skip menu "kopete/kopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal