Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 28dbee50 authored by Laurent Montel's avatar Laurent Montel 😁

Get gravatar

parent 7d2b53ae
......@@ -18,6 +18,7 @@
#include "gravatarcreatewidgettest.h"
#include "../widgets/gravatarcreatewidget.h"
#include <QLabel>
#include <QPushButton>
#include <qtest_kde.h>
GravatarCreateWidgetTest::GravatarCreateWidgetTest(QObject *parent)
: QObject(parent)
......@@ -36,9 +37,11 @@ void GravatarCreateWidgetTest::shouldHaveDefaultValue()
QLabel *lab = widget.findChild<QLabel *>(QLatin1String("emaillabel"));
QVERIFY(lab);
QLabel *emaillabel = widget.findChild<QLabel *>(QLatin1String("email"));
QVERIFY(emaillabel);
QPushButton *searchGravatar = widget.findChild<QPushButton *>(QLatin1String("search"));
QVERIFY(searchGravatar);
}
QTEST_KDEMAIN(GravatarCreateWidgetTest, GUI)
......@@ -17,9 +17,13 @@
#include "gravatarcreatewidget.h"
#include "pimcommon/gravatar/gravatarresolvurljob.h"
#include <QLabel>
#include <QGridLayout>
#include <QPushButton>
using namespace KABGravatar;
GravatarCreateWidget::GravatarCreateWidget(QWidget *parent)
......@@ -35,6 +39,13 @@ GravatarCreateWidget::GravatarCreateWidget(QWidget *parent)
mEmailLab = new QLabel;
mEmailLab->setObjectName(QLatin1String("email"));
mainLayout->addWidget(mEmailLab, 0, 1);
//KF5 add i18n
mSearchGravatar = new QPushButton(QLatin1String("Search"));
mSearchGravatar->setEnabled(false);
mSearchGravatar->setObjectName(QLatin1String("search"));
mainLayout->addWidget(mSearchGravatar, 0, 2);
connect(mSearchGravatar, SIGNAL(clicked(bool)), this, SLOT(slotSearchGravatar()));
}
......@@ -48,5 +59,27 @@ void GravatarCreateWidget::setEmail(const QString &email)
if (mEmail != email) {
mEmail = email;
mEmailLab->setText(mEmail);
mSearchGravatar->setEnabled(!mEmail.isEmpty());
}
}
void GravatarCreateWidget::slotSearchGravatar()
{
if (!mEmail.isEmpty()) {
PimCommon::GravatarResolvUrlJob *job = new PimCommon::GravatarResolvUrlJob(this);
job->setEmail(mEmail);
job->setUseDefaultPixmap(false);
connect(job, SIGNAL(finished(PimCommon::GravatarResolvUrlJob*)), this, SLOT(slotSearchGravatarFinished(PimCommon::GravatarResolvUrlJob*)));
job->start();
}
}
void GravatarCreateWidget::slotSearchGravatarFinished(PimCommon::GravatarResolvUrlJob *job)
{
if (job) {
if (job->hasGravatar()) {
//TODO show gravatar result!
}
}
//TODO
}
......@@ -21,6 +21,10 @@
#include <QWidget>
class QLabel;
class QPushButton;
namespace PimCommon {
class GravatarResolvUrlJob;
}
namespace KABGravatar {
class GravatarCreateWidget : public QWidget
{
......@@ -29,9 +33,14 @@ public:
explicit GravatarCreateWidget(QWidget *parent = 0);
~GravatarCreateWidget();
void setEmail(const QString &email);
private Q_SLOTS:
void slotSearchGravatar();
void slotSearchGravatarFinished(PimCommon::GravatarResolvUrlJob *);
private:
QString mEmail;
QLabel *mEmailLab;
QPushButton *mSearchGravatar;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment