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

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
  • ui
avatardialog.cpp
Go to the documentation of this file.
1 /*
2  avatardialog.cpp - Dialog to manage and select user avatar
3 
4  Copyright (c) 2007 by Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
5  Copyright (c) 2007 by MichaĆ«l Larouche <larouche@kde.org>
6 
7  Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
8 
9  *************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2 of the License, or (at your option) any later version. *
15  * *
16  *************************************************************************
17 */
18 #include "avatardialog.h"
19 
20 // Qt includes
21 #include <QPointer>
22 
23 // KDE includes
24 #include <kdebug.h>
25 #include <klocale.h>
26 
27 // Kopete includes
28 #include "avatarselectorwidget.h"
29 #include "kopeteavatarmanager.h"
30 
31 namespace Kopete
32 {
33 
34 namespace UI
35 {
36 
37 class AvatarDialog::Private
38 {
39 public:
40  Private()
41  : mainWidget(0)
42  {}
43 
44  AvatarSelectorWidget *mainWidget;
45  QString selectedPath;
46  QString currentPath;
47 };
48 
49 AvatarDialog::AvatarDialog(QWidget *parent)
50  : KDialog(parent), d(new Private)
51 {
52  showButtonSeparator(true);
53  setCaption( i18n("Select Avatar") );
54  setButtons( KDialog::Ok | KDialog::Cancel );
55 
56  d->mainWidget = new Kopete::UI::AvatarSelectorWidget(this);
57  setMainWidget(d->mainWidget);
58 }
59 
60 AvatarDialog::~AvatarDialog()
61 {
62  delete d;
63 }
64 
65 QString AvatarDialog::selectedAvatarPath() const
66 {
67  return d->selectedPath;
68 }
69 
70 QString AvatarDialog::getAvatar(QWidget *parent, const QString &currentAvatar, bool * ok )
71 {
72  QPointer <AvatarDialog> dialog = new AvatarDialog(parent);
73  dialog->d->mainWidget->setCurrentAvatar(currentAvatar);
74  dialog->d->currentPath = currentAvatar;
75  if ( dialog->exec() == QDialog::Accepted )
76  {
77  if ( ok ) {
78  *ok = true;
79  }
80  }
81  else
82  {
83  if ( ok ) {
84  *ok = false;
85  }
86  }
87  QString ret;
88  if ( dialog )
89  ret = dialog->selectedAvatarPath();
90  delete dialog;
91  return ret;
92 }
93 
94 void AvatarDialog::slotButtonClicked(int button)
95 {
96  if (button == KDialog::Ok)
97  {
98  Kopete::AvatarManager::AvatarEntry selectedEntry = d->mainWidget->selectedEntry();
99 
100  d->selectedPath = selectedEntry.path;
101  emit result();
102  }
103 
104  KDialog::slotButtonClicked(button);
105 }
106 
107 } // namespace UI
108 
109 } // namespace Kopete
110 #include "avatardialog.moc"
QWidget
avatardialog.h
avatarselectorwidget.h
Kopete::UI::AvatarDialog::~AvatarDialog
virtual ~AvatarDialog()
Clean-up resource of AvatarDialog.
Definition: avatardialog.cpp:60
QPointer
KDialog
Kopete::UI::AvatarDialog::AvatarDialog
AvatarDialog(QWidget *parent=0)
Create a new AvatarDialog.
Definition: avatardialog.cpp:49
kopeteavatarmanager.h
QString
Kopete::UI::AvatarDialog::getAvatar
static QString getAvatar(QWidget *parent=0, const QString &currentAvatar=QString(), bool *ok=0)
Gets an avatar from the AvatarManager.
Definition: avatardialog.cpp:70
Kopete::UI::AvatarDialog::slotButtonClicked
virtual void slotButtonClicked(int button)
Definition: avatardialog.cpp:94
Kopete::UI::Global::setMainWidget
KOPETE_EXPORT void setMainWidget(QWidget *widget)
Set the main widget to widget.
Definition: kopeteuiglobal.cpp:32
Kopete::UI::Global::mainWidget
KOPETE_EXPORT QWidget * mainWidget()
Returns the main widget - this is the widget that message boxes and KNotify stuff should use as a par...
Definition: kopeteuiglobal.cpp:37
Kopete::AvatarManager::AvatarEntry
A single entry in AvatarManager.
Definition: kopeteavatarmanager.h:127
Kopete::UI::AvatarDialog::result
void result()
This signal is emitted when Ok has been clicked before the dialog is closed.
Kopete::AvatarManager::AvatarEntry::path
QString path
path is the full path to the image on disk
Definition: kopeteavatarmanager.h:130
Kopete::UI::AvatarSelectorWidget
Widget to select and manager user avatar.
Definition: avatarselectorwidget.h:44
Kopete::UI::AvatarDialog::selectedAvatarPath
QString selectedAvatarPath() const
Get the selected avatar in dialog.
Definition: avatardialog.cpp:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • 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