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 7d2b53ae authored by Laurent Montel's avatar Laurent Montel 😁

improve create gravatar

parent 1ac13412
......@@ -16,6 +16,8 @@
*/
#include "gravatarcreatewidgettest.h"
#include "../widgets/gravatarcreatewidget.h"
#include <QLabel>
#include <qtest_kde.h>
GravatarCreateWidgetTest::GravatarCreateWidgetTest(QObject *parent)
: QObject(parent)
......@@ -28,4 +30,15 @@ GravatarCreateWidgetTest::~GravatarCreateWidgetTest()
}
void GravatarCreateWidgetTest::shouldHaveDefaultValue()
{
KABGravatar::GravatarCreateWidget widget;
QLabel *lab = widget.findChild<QLabel *>(QLatin1String("emaillabel"));
QVERIFY(lab);
QLabel *emaillabel = widget.findChild<QLabel *>(QLatin1String("email"));
QVERIFY(emaillabel);
}
QTEST_KDEMAIN(GravatarCreateWidgetTest, GUI)
......@@ -27,6 +27,9 @@ class GravatarCreateWidgetTest : public QObject
public:
explicit GravatarCreateWidgetTest(QObject *parent = 0);
~GravatarCreateWidgetTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // GRAVATARCREATEWIDGETTEST_H
......@@ -21,6 +21,10 @@
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QPushButton>
#include <KConfigGroup>
#include <KGlobal>
#include <KSharedConfig>
using namespace KABGravatar;
GravatarCreateDialog::GravatarCreateDialog(QWidget *parent)
: QDialog(parent)
......@@ -35,10 +39,31 @@ GravatarCreateDialog::GravatarCreateDialog(QWidget *parent)
mainLayout->addWidget(buttonBox);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
readConfig();
}
GravatarCreateDialog::~GravatarCreateDialog()
{
writeConfig();
}
void GravatarCreateDialog::setEmail(const QString &email)
{
mCreateWidget->setEmail(email);
}
void GravatarCreateDialog::readConfig()
{
KConfigGroup grp( KGlobal::config(), "GravatarCreateDialog" );
const QSize size = grp.readEntry( "Size", QSize(300, 200) );
if ( size.isValid() ) {
resize( size );
}
}
void GravatarCreateDialog::writeConfig()
{
KConfigGroup grp( KGlobal::config(), "GravatarCreateDialog");
grp.writeEntry( "Size", size() );
grp.sync();
}
......@@ -28,7 +28,12 @@ class GravatarCreateDialog : public QDialog
public:
explicit GravatarCreateDialog(QWidget *parent=0);
~GravatarCreateDialog();
void setEmail(const QString &email);
private:
void readConfig();
void writeConfig();
GravatarCreateWidget *mCreateWidget;
};
}
......
......@@ -18,12 +18,23 @@
#include "gravatarcreatewidget.h"
#include <QLabel>
#include <QGridLayout>
using namespace KABGravatar;
GravatarCreateWidget::GravatarCreateWidget(QWidget *parent)
: QWidget(parent)
{
QGridLayout *mainLayout = new QGridLayout;
setLayout(mainLayout);
//KF5 add i18n
QLabel *lab = new QLabel(QLatin1String("Email:"));
lab->setObjectName(QLatin1String("emaillabel"));
mainLayout->addWidget(lab, 0, 0);
mEmailLab = new QLabel;
mEmailLab->setObjectName(QLatin1String("email"));
mainLayout->addWidget(mEmailLab, 0, 1);
}
......@@ -31,3 +42,11 @@ GravatarCreateWidget::~GravatarCreateWidget()
{
}
void GravatarCreateWidget::setEmail(const QString &email)
{
if (mEmail != email) {
mEmail = email;
mEmailLab->setText(mEmail);
}
}
......@@ -20,6 +20,7 @@
#define GRAVATARCREATEWIDGET_H
#include <QWidget>
class QLabel;
namespace KABGravatar {
class GravatarCreateWidget : public QWidget
{
......@@ -27,6 +28,10 @@ class GravatarCreateWidget : public QWidget
public:
explicit GravatarCreateWidget(QWidget *parent = 0);
~GravatarCreateWidget();
void setEmail(const QString &email);
private:
QString mEmail;
QLabel *mEmailLab;
};
}
......
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