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

kopete/kopete

identitydialog.cpp

Go to the documentation of this file.
00001 /*
00002     identitydialog.cpp  -  Kopete identity configuration dialog
00003 
00004     Copyright (c) 2007      by Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
00005     Copyright (c) 2007         Will Stephenson        <wstephenson@kde.org>
00006 
00007     Kopete    (c) 2003-2007 by the Kopete developers  <kopete-devel@kde.org>
00008 
00009     *************************************************************************
00010     *                                                                       *
00011     * This program is free software; you can redistribute it and/or modify  *
00012     * it under the terms of the GNU General Public License as published by  *
00013     * the Free Software Foundation; either version 2 of the License, or     *
00014     * (at your option) any later version.                                   *
00015     *                                                                       *
00016     *************************************************************************
00017 */
00018 
00019 
00020 #include "identitydialog.h"
00021 #include "ui_identitygeneral.h"
00022 #include "ui_identitydetailed.h"
00023 
00024 #include <KIcon>
00025 #include <kopeteidentity.h>
00026 #include <avatardialog.h>
00027 
00028 class IdentityDialog::Private
00029 {
00030 public:
00031     Kopete::Identity *identity;
00032     Kopete::Global::Properties *props;
00033     Ui::IdentityGeneral general;
00034     Ui::IdentityDetailed detailed;
00035     QString photoPath;
00036 };
00037 
00038 IdentityDialog::IdentityDialog(Kopete::Identity *identity, QWidget *parent)
00039 : Kopete::UI::InfoDialog(parent, i18n("Identity Information"), "identity")
00040 {
00041     Q_ASSERT(identity);
00042 
00043     setTitle(identity->label());
00044     setWindowTitle(i18n("Identity Information"));
00045 
00046     d = new Private();
00047     d->identity = identity;
00048     d->props = Kopete::Global::Properties::self();
00049     
00050     // add the general page
00051     QWidget *w = new QWidget(this);
00052     d->general.setupUi(w);
00053     d->general.selectPhoto->setIcon(KIcon("view-preview"));
00054     d->general.clearPhoto->setIcon(KIcon("edit-clear-locationbar-rtl"));
00055     d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
00056                                             "<p align=\"center\">No Photo</p>"
00057                                         "</a>").arg( i18n("No Photo") ));
00058 
00059     connect(d->general.selectPhoto, SIGNAL(clicked(bool)),
00060             this, SLOT(slotSelectPhoto()));
00061     connect(d->general.photo, SIGNAL(linkActivated(const QString&)),
00062             this, SLOT(slotSelectPhoto()));
00063     connect(d->general.clearPhoto, SIGNAL(clicked(bool)),
00064             this, SLOT(slotClearPhoto()));
00065     addWidget(w, i18n("General Information"));
00066 
00067     // add the detailed page
00068     w = new QWidget(this);
00069     d->detailed.setupUi(w);
00070     addWidget(w, i18n("Detailed Information"));
00071 
00072     setIcon(KIcon(d->identity->customIcon()));
00073 
00074     load();
00075 }
00076 
00077 IdentityDialog::~IdentityDialog()
00078 {
00079     delete d;
00080 }
00081 
00082 void IdentityDialog::load()
00083 {
00084     //-------------- General Info ---------------------
00085     // Photo
00086     if (d->identity->hasProperty( d->props->photo().key() ))
00087         setPhoto( d->identity->property(d->props->photo()).value().toString() );
00088 
00089 
00090     // Label
00091     d->general.label->setText( d->identity->label() );
00092 
00093     // NickName
00094     if (d->identity->hasProperty( d->props->nickName().key() ))
00095         d->general.nickName->setText( d->identity->property(d->props->nickName()).value().toString() );
00096 
00097     // FirstName
00098     if (d->identity->hasProperty( d->props->firstName().key() ))
00099         d->general.firstName->setText( d->identity->property(d->props->firstName()).value().toString() );
00100 
00101     // LastName
00102     if (d->identity->hasProperty( d->props->lastName().key() ))
00103         d->general.lastName->setText( d->identity->property(d->props->lastName()).value().toString() );
00104     
00105     //-------------- Detailed Info --------------------
00106     // Email
00107     if (d->identity->hasProperty( d->props->emailAddress().key() ))
00108         d->detailed.email->setText( d->identity->property(d->props->emailAddress()).value().toString() );
00109 
00110     // PrivatePhone
00111     if (d->identity->hasProperty( d->props->privatePhone().key() ))
00112         d->detailed.privatePhone->setText( 
00113                 d->identity->property(d->props->privatePhone()).value().toString() );
00114 
00115     // MobilePhone
00116     if (d->identity->hasProperty( d->props->privateMobilePhone().key() ))
00117         d->detailed.mobilePhone->setText( 
00118                 d->identity->property(d->props->privateMobilePhone()).value().toString() );
00119 
00120 }
00121 
00122 void IdentityDialog::slotSave()
00123 {
00124     //-------------- General Info ---------------------
00125     d->identity->setLabel( d->general.label->text() );
00126     if ( d->photoPath.isEmpty() )
00127         d->identity->removeProperty( d->props->photo() );
00128     else
00129         d->identity->setProperty( d->props->photo(), d->photoPath );
00130     d->identity->setProperty( d->props->nickName(), d->general.nickName->text() );
00131     d->identity->setProperty( d->props->firstName(), d->general.firstName->text() );
00132     d->identity->setProperty( d->props->lastName(), d->general.lastName->text() );
00133 
00134     //-------------- Detailed Info --------------------
00135     d->identity->setProperty( d->props->emailAddress(), d->detailed.email->text() );
00136     d->identity->setProperty( d->props->privatePhone(), d->detailed.privatePhone->text() );
00137     d->identity->setProperty( d->props->privateMobilePhone(), d->detailed.mobilePhone->text() );
00138 }
00139 
00140 void IdentityDialog::setPhoto(QString path)
00141 {
00142     d->photoPath = path;
00143     if (!path.isEmpty())
00144     {
00145         d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
00146                                             "<p align=\"center\"><img src=\"%1\"></p>"
00147                                         "</a>").arg( d->photoPath ) );
00148     }
00149     else
00150     {
00151         d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
00152                                             "<p align=\"center\">No Photo</p>"
00153                                         "</a>").arg( i18n("No Photo") ));
00154     }
00155 }
00156 
00157 void IdentityDialog::slotSelectPhoto()
00158 {
00159     bool ok;
00160     QString photo = Kopete::UI::AvatarDialog::getAvatar(this, d->photoPath, &ok);
00161     if ( ok )
00162         setPhoto( photo );
00163 }
00164 
00165 void IdentityDialog::slotClearPhoto()
00166 {
00167     setPhoto( QString::null );  //krazy:exclude=nullstrassign for old broken gcc
00168 }
00169 
00170 #include "identitydialog.moc"
00171 // vim: set noet ts=4 sts=4 sw=4:

kopete/kopete

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

kdenetwork

Skip menu "kdenetwork"
  • kget
  • kopete
  •   kopete
  •   libkopete
  •       libpapillon
  • krfb
Generated for kdenetwork by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal