Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / libkopete / ui / avatardialog.cpp
blob010bd0936f0694224f801d566ebd35807f1c34b6
1 /*
2 avatardialog.cpp - Dialog to manage and select user avatar
4 Copyright (c) 2007 by Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
5 Copyright (c) 2007 by Michaƫl Larouche <larouche@kde.org>
7 Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
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 *************************************************************************
18 #include "avatardialog.h"
20 // KDE includes
21 #include <kdebug.h>
22 #include <klocale.h>
24 // Kopete includes
25 #include "avatarselectorwidget.h"
26 #include "kopeteavatarmanager.h"
28 namespace Kopete
31 namespace UI
34 class AvatarDialog::Private
36 public:
37 Private()
38 : mainWidget(0)
41 AvatarSelectorWidget *mainWidget;
42 QString selectedPath;
43 QString currentPath;
46 AvatarDialog::AvatarDialog(QWidget *parent)
47 : KDialog(parent), d(new Private)
49 showButtonSeparator(true);
50 setCaption( i18n("Select an avatar") );
51 setButtons( KDialog::Ok | KDialog::Cancel );
53 d->mainWidget = new Kopete::UI::AvatarSelectorWidget(this);
54 setMainWidget(d->mainWidget);
57 AvatarDialog::~AvatarDialog()
59 delete d;
62 QString AvatarDialog::selectedAvatarPath() const
64 return d->selectedPath;
67 QString AvatarDialog::getAvatar(QWidget *parent, const QString &currentAvatar, bool * ok )
69 AvatarDialog dialog(parent);
70 dialog.d->mainWidget->setCurrentAvatar(currentAvatar);
71 dialog.d->currentPath = currentAvatar;
72 if ( dialog.exec() == QDialog::Accepted )
74 if ( ok ) {
75 *ok = true;
78 else
80 if ( ok ) {
81 *ok = false;
84 return dialog.selectedAvatarPath();
87 void AvatarDialog::slotButtonClicked(int button)
89 if (button == KDialog::Ok)
91 Kopete::AvatarManager::AvatarEntry selectedEntry = d->mainWidget->selectedEntry();
93 d->selectedPath = selectedEntry.path;
94 emit result();
97 KDialog::slotButtonClicked(button);
100 } // namespace UI
102 } // namespace Kopete
103 #include "avatardialog.moc"