kopete/libkopete
avatardialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "avatardialog.h"
00019
00020
00021 #include <kdebug.h>
00022 #include <klocale.h>
00023
00024
00025 #include "avatarselectorwidget.h"
00026 #include "kopeteavatarmanager.h"
00027
00028 namespace Kopete
00029 {
00030
00031 namespace UI
00032 {
00033
00034 class AvatarDialog::Private
00035 {
00036 public:
00037 Private()
00038 : mainWidget(0)
00039 {}
00040
00041 AvatarSelectorWidget *mainWidget;
00042 QString selectedPath;
00043 QString currentPath;
00044 };
00045
00046 AvatarDialog::AvatarDialog(QWidget *parent)
00047 : KDialog(parent), d(new Private)
00048 {
00049 showButtonSeparator(true);
00050 setCaption( i18n("Select an avatar") );
00051 setButtons( KDialog::Ok | KDialog::Cancel );
00052
00053 d->mainWidget = new Kopete::UI::AvatarSelectorWidget(this);
00054 setMainWidget(d->mainWidget);
00055 }
00056
00057 AvatarDialog::~AvatarDialog()
00058 {
00059 delete d;
00060 }
00061
00062 QString AvatarDialog::selectedAvatarPath() const
00063 {
00064 return d->selectedPath;
00065 }
00066
00067 QString AvatarDialog::getAvatar(QWidget *parent, const QString ¤tAvatar, bool * ok )
00068 {
00069 AvatarDialog dialog(parent);
00070 dialog.d->mainWidget->setCurrentAvatar(currentAvatar);
00071 dialog.d->currentPath = currentAvatar;
00072 if ( dialog.exec() == QDialog::Accepted )
00073 {
00074 if ( ok ) {
00075 *ok = true;
00076 }
00077 }
00078 else
00079 {
00080 if ( ok ) {
00081 *ok = false;
00082 }
00083 }
00084 return dialog.selectedAvatarPath();
00085 }
00086
00087 void AvatarDialog::slotButtonClicked(int button)
00088 {
00089 if (button == KDialog::Ok)
00090 {
00091 Kopete::AvatarManager::AvatarEntry selectedEntry = d->mainWidget->selectedEntry();
00092
00093 d->selectedPath = selectedEntry.path;
00094 emit result();
00095 }
00096
00097 KDialog::slotButtonClicked(button);
00098 }
00099
00100 }
00101
00102 }
00103 #include "avatardialog.moc"