• 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
  • identity
identitydialog.cpp
Go to the documentation of this file.
1 /*
2  identitydialog.cpp - Kopete identity configuration dialog
3 
4  Copyright (c) 2007 by Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
5  Copyright (c) 2007 Will Stephenson <wstephenson@kde.org>
6 
7  Kopete (c) 2003-2007 by the Kopete developers <kopete-devel@kde.org>
8 
9  *************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  *************************************************************************
17 */
18 
19 
20 #include "identitydialog.h"
21 #include "ui_identitygeneral.h"
22 #include "ui_identitydetailed.h"
23 
24 #include <KIcon>
25 #include <kopeteidentity.h>
26 #include <avatardialog.h>
27 
28 class IdentityDialog::Private
29 {
30 public:
31  Kopete::Identity *identity;
32  Kopete::Global::Properties *props;
33  Ui::IdentityGeneral general;
34  Ui::IdentityDetailed detailed;
35  QString photoPath;
36 };
37 
38 IdentityDialog::IdentityDialog(Kopete::Identity *identity, QWidget *parent)
39 : Kopete::UI::InfoDialog(parent, i18n("Identity Information"), "identity"), d(new Private())
40 {
41  Q_ASSERT(identity);
42 
43  setTitle(identity->label());
44  setWindowTitle(i18n("Identity Information"));
45 
46  d->identity = identity;
47  d->props = Kopete::Global::Properties::self();
48 
49  // add the general page
50  QWidget *w = new QWidget(this);
51  d->general.setupUi(w);
52  d->general.selectPhoto->setIcon(KIcon("view-preview"));
53  d->general.clearPhoto->setIcon(KIcon("edit-clear-locationbar-rtl"));
54  d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
55  "<p align=\"center\">%1</p>"
56  "</a></qt>").arg( i18n("No Photo") ));
57 
58  connect(d->general.selectPhoto, SIGNAL(clicked(bool)),
59  this, SLOT(slotSelectPhoto()));
60  connect(d->general.photo, SIGNAL(linkActivated(QString)),
61  this, SLOT(slotSelectPhoto()));
62  connect(d->general.clearPhoto, SIGNAL(clicked(bool)),
63  this, SLOT(slotClearPhoto()));
64  addWidget(w, i18n("General Information"));
65 
66  // add the detailed page
67  w = new QWidget(this);
68  d->detailed.setupUi(w);
69  addWidget(w, i18n("Detailed Information"));
70 
71  setIcon(KIcon(d->identity->customIcon()));
72 
73  load();
74 }
75 
76 IdentityDialog::~IdentityDialog()
77 {
78  delete d;
79 }
80 
81 void IdentityDialog::load()
82 {
83  //-------------- General Info ---------------------
84  // Photo
85  if (d->identity->hasProperty( d->props->photo().key() ))
86  setPhoto( d->identity->property(d->props->photo()).value().toString() );
87 
88 
89  // Label
90  d->general.label->setText( d->identity->label() );
91 
92  // NickName
93  if (d->identity->hasProperty( d->props->nickName().key() ))
94  d->general.nickName->setText( d->identity->property(d->props->nickName()).value().toString() );
95 
96  // FirstName
97  if (d->identity->hasProperty( d->props->firstName().key() ))
98  d->general.firstName->setText( d->identity->property(d->props->firstName()).value().toString() );
99 
100  // LastName
101  if (d->identity->hasProperty( d->props->lastName().key() ))
102  d->general.lastName->setText( d->identity->property(d->props->lastName()).value().toString() );
103 
104  //-------------- Detailed Info --------------------
105  // Email
106  if (d->identity->hasProperty( d->props->emailAddress().key() ))
107  d->detailed.email->setText( d->identity->property(d->props->emailAddress()).value().toString() );
108 
109  // PrivatePhone
110  if (d->identity->hasProperty( d->props->privatePhone().key() ))
111  d->detailed.privatePhone->setText(
112  d->identity->property(d->props->privatePhone()).value().toString() );
113 
114  // MobilePhone
115  if (d->identity->hasProperty( d->props->privateMobilePhone().key() ))
116  d->detailed.mobilePhone->setText(
117  d->identity->property(d->props->privateMobilePhone()).value().toString() );
118 
119 }
120 
121 void IdentityDialog::slotSave()
122 {
123  //-------------- General Info ---------------------
124  d->identity->setLabel( d->general.label->text() );
125  if ( d->photoPath.isEmpty() )
126  d->identity->removeProperty( d->props->photo() );
127  else
128  d->identity->setProperty( d->props->photo(), d->photoPath );
129  d->identity->setProperty( d->props->nickName(), d->general.nickName->text() );
130  d->identity->setProperty( d->props->firstName(), d->general.firstName->text() );
131  d->identity->setProperty( d->props->lastName(), d->general.lastName->text() );
132 
133  //-------------- Detailed Info --------------------
134  d->identity->setProperty( d->props->emailAddress(), d->detailed.email->text() );
135  d->identity->setProperty( d->props->privatePhone(), d->detailed.privatePhone->text() );
136  d->identity->setProperty( d->props->privateMobilePhone(), d->detailed.mobilePhone->text() );
137 }
138 
139 void IdentityDialog::setPhoto(QString path)
140 {
141  d->photoPath = path;
142  if (!path.isEmpty())
143  {
144  d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
145  "<p align=\"center\"><img src=\"%1\"></p>"
146  "</a>").arg( d->photoPath ) );
147  }
148  else
149  {
150  d->general.photo->setText( QString("<qt><a href=\"selectPhoto\">"
151  "<p align=\"center\">No Photo</p>"
152  "</a>").arg( i18n("No Photo") ));
153  }
154 }
155 
156 void IdentityDialog::slotSelectPhoto()
157 {
158  bool ok;
159  QString photo = Kopete::UI::AvatarDialog::getAvatar(this, d->photoPath, &ok);
160  if ( ok )
161  setPhoto( photo );
162 }
163 
164 void IdentityDialog::slotClearPhoto()
165 {
166  setPhoto( QString::null ); //krazy:exclude=nullstrassign for old broken gcc
167 }
168 
169 #include "identitydialog.moc"
170 // vim: set noet ts=4 sts=4 sw=4:
QWidget
IdentityDialog::setPhoto
void setPhoto(QString path)
Definition: identitydialog.cpp:139
IdentityDialog::slotSave
virtual void slotSave()
Definition: identitydialog.cpp:121
IdentityDialog::load
void load()
Definition: identitydialog.cpp:81
IdentityDialog::IdentityDialog
IdentityDialog(Kopete::Identity *identity, QWidget *parent=0)
Definition: identitydialog.cpp:38
IdentityDialog::~IdentityDialog
~IdentityDialog()
Definition: identitydialog.cpp:76
identitydialog.h
InfoDialog
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:40 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