• Skip to content
  • Skip to link menu
KDE 4.0 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 
00056     connect(d->general.selectPhoto, SIGNAL(clicked(bool)),
00057             this, SLOT(slotSelectPhoto()));
00058     connect(d->general.photo, SIGNAL(linkActivated(const QString&)),
00059             this, SLOT(slotSelectPhoto()));
00060     connect(d->general.clearPhoto, SIGNAL(clicked(bool)),
00061             this, SLOT(slotClearPhoto()));
00062     addWidget(w, i18n("General Information"));
00063 
00064     // add the detailed page
00065     w = new QWidget(this);
00066     d->detailed.setupUi(w);
00067     addWidget(w, i18n("Detailed Information"));
00068 
00069     setIcon(KIcon(d->identity->customIcon()));
00070 
00071     load();
00072 }
00073 
00074 IdentityDialog::~IdentityDialog()
00075 {
00076     delete d;
00077 }
00078 
00079 void IdentityDialog::load()
00080 {
00081     //-------------- General Info ---------------------
00082     // Photo
00083     if (d->identity->hasProperty( d->props->photo().key() ))
00084         setPhoto( d->identity->property(d->props->photo()).value().toString() );
00085 
00086 
00087     // Label
00088     d->general.label->setText( d->identity->label() );
00089 
00090     // NickName
00091     if (d->identity->hasProperty( d->props->nickName().key() ))
00092         d->general.nickName->setText( d->identity->property(d->props->nickName()).value().toString() );
00093 
00094     // FirstName
00095     if (d->identity->hasProperty( d->props->firstName().key() ))
00096         d->general.firstName->setText( d->identity->property(d->props->firstName()).value().toString() );
00097 
00098     // LastName
00099     if (d->identity->hasProperty( d->props->lastName().key() ))
00100         d->general.lastName->setText( d->identity->property(d->props->lastName()).value().toString() );
00101     
00102     //-------------- Detailed Info --------------------
00103     // Email
00104     if (d->identity->hasProperty( d->props->emailAddress().key() ))
00105         d->detailed.email->setText( d->identity->property(d->props->emailAddress()).value().toString() );
00106 
00107     // PrivatePhone
00108     if (d->identity->hasProperty( d->props->privatePhone().key() ))
00109         d->detailed.privatePhone->setText( 
00110                 d->identity->property(d->props->privatePhone()).value().toString() );
00111 
00112     // MobilePhone
00113     if (d->identity->hasProperty( d->props->privateMobilePhone().key() ))
00114         d->detailed.mobilePhone->setText( 
00115                 d->identity->property(d->props->privateMobilePhone()).value().toString() );
00116 
00117 }
00118 
00119 void IdentityDialog::slotSave()
00120 {
00121     //-------------- General Info ---------------------
00122     d->identity->setLabel( d->general.label->text() );
00123     if ( d->photoPath.isEmpty() )
00124         d->identity->removeProperty( d->props->photo() );
00125     else
00126         d->identity->setProperty( d->props->photo(), d->photoPath );
00127     d->identity->setProperty( d->props->nickName(), d->general.nickName->text() );
00128     d->identity->setProperty( d->props->firstName(), d->general.firstName->text() );
00129     d->identity->setProperty( d->props->lastName(), d->general.lastName->text() );
00130 
00131     //-------------- Detailed Info --------------------
00132     d->identity->setProperty( d->props->emailAddress(), d->detailed.email->text() );
00133     d->identity->setProperty( d->props->privatePhone(), d->detailed.privatePhone->text() );
00134     d->identity->setProperty( d->props->privateMobilePhone(), d->detailed.mobilePhone->text() );
00135 }
00136 
00137 void IdentityDialog::setPhoto(QString path)
00138 {
00139     d->photoPath = path;
00140     if (!path.isEmpty())
00141     {
00142         d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
00143                                             "<p align=\"center\"><img src=\"%1\"></p>"
00144                                         "</a>").arg( d->photoPath ) );
00145     }
00146     else
00147     {
00148         d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
00149                                             "<p align=\"center\">No Photo</p>"
00150                                         "</a>").arg( i18n("No Photo") ));
00151     }
00152 }
00153 
00154 void IdentityDialog::slotSelectPhoto()
00155 {
00156     bool ok;
00157     QString photo = Kopete::UI::AvatarDialog::getAvatar(this, d->photoPath, &ok);
00158     if ( ok )
00159         setPhoto( photo );
00160 }
00161 
00162 void IdentityDialog::slotClearPhoto()
00163 {
00164     setPhoto( QString::null );  //krazy:exclude=nullstrassign for old broken gcc
00165 }
00166 
00167 #include "identitydialog.moc"
00168 // 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