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

Enable/disable checkbox

parent a8566101
......@@ -22,6 +22,7 @@
#include <QLabel>
#include <QPushButton>
#include <qtest_kde.h>
#include <qtestmouse.h>
GravatarConfigWidgetTest::GravatarConfigWidgetTest(QObject *parent)
: QObject(parent)
......@@ -51,7 +52,36 @@ void GravatarConfigWidgetTest::shouldHaveDefaultValue()
KIntSpinBox *gravatarCacheSize = qFindChild<KIntSpinBox *>(&w, QLatin1String("gravatarcachesize"));
QVERIFY(gravatarCacheSize);
}
void GravatarConfigWidgetTest::shouldChangeState()
{
MessageViewer::GravatarConfigWidget w;
w.show();
QCheckBox *checkBox = qFindChild<QCheckBox *>(&w, QLatin1String("gravatarcheckbox"));
QCheckBox *useDefaultImage = qFindChild<QCheckBox *>(&w, QLatin1String("usedefaultimage"));
QPushButton *clearGravatarCache = qFindChild<QPushButton *>(&w, QLatin1String("cleargravatarcachebutton"));
KIntSpinBox *gravatarCacheSize = qFindChild<KIntSpinBox *>(&w, QLatin1String("gravatarcachesize"));
checkBox->setChecked(false);
QVERIFY(checkBox->isEnabled());
QVERIFY(!checkBox->isChecked());
QVERIFY(!useDefaultImage->isEnabled());
QVERIFY(!clearGravatarCache->isEnabled());
QVERIFY(!gravatarCacheSize->isEnabled());
QTest::mouseClick(checkBox, Qt::LeftButton);
QVERIFY(checkBox->isEnabled());
QVERIFY(checkBox->isChecked());
QVERIFY(useDefaultImage->isEnabled());
QVERIFY(clearGravatarCache->isEnabled());
QVERIFY(gravatarCacheSize->isEnabled());
QTest::mouseClick(checkBox, Qt::LeftButton);
QVERIFY(checkBox->isEnabled());
QVERIFY(!useDefaultImage->isEnabled());
QVERIFY(!clearGravatarCache->isEnabled());
QVERIFY(!gravatarCacheSize->isEnabled());
}
QTEST_KDEMAIN(GravatarConfigWidgetTest, GUI)
......@@ -29,6 +29,7 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldChangeState();
};
#endif // GRAVATARCONFIGWIDGETTEST_H
......@@ -71,10 +71,11 @@ GravatarConfigWidget::GravatarConfigWidget(QWidget *parent)
buttonLayout->addWidget(mClearGravatarCache);
buttonLayout->addStretch();
updateWidgetState(false);
connect(mClearGravatarCache, SIGNAL(clicked(bool)), this, SLOT(slotClearGravatarCache()));
connect(mUseDefaultPixmap, SIGNAL(clicked(bool)), SIGNAL(configChanged(bool)));
connect(mEnableGravatarSupport, SIGNAL(clicked(bool)), SIGNAL(configChanged(bool)));
connect(mEnableGravatarSupport, SIGNAL(clicked(bool)), this, SLOT(slotGravatarEnableChanged(bool)));
}
GravatarConfigWidget::~GravatarConfigWidget()
......@@ -82,6 +83,19 @@ GravatarConfigWidget::~GravatarConfigWidget()
}
void GravatarConfigWidget::slotGravatarEnableChanged(bool state)
{
updateWidgetState(state);
Q_EMIT configChanged(state);
}
void GravatarConfigWidget::updateWidgetState(bool state)
{
mUseDefaultPixmap->setEnabled(state);
mClearGravatarCache->setEnabled(state);
mGravatarCacheSize->setEnabled(state);
}
void GravatarConfigWidget::save()
{
saveCheckBox(mEnableGravatarSupport, MessageViewer::GlobalSettings::self()->gravatarSupportEnabledItem());
......@@ -94,6 +108,7 @@ void GravatarConfigWidget::doLoadFromGlobalSettings()
loadWidget(mEnableGravatarSupport, MessageViewer::GlobalSettings::self()->gravatarSupportEnabledItem());
loadWidget(mUseDefaultPixmap, MessageViewer::GlobalSettings::self()->gravatarUseDefaultImageItem());
loadWidget(mGravatarCacheSize, MessageViewer::GlobalSettings::self()->gravatarCacheSizeItem());
updateWidgetState(mEnableGravatarSupport->isChecked());
}
void GravatarConfigWidget::doResetToDefaultsOther()
......
......@@ -41,8 +41,10 @@ Q_SIGNALS:
private Q_SLOTS:
void slotClearGravatarCache();
void slotGravatarCacheSizeChanged();
void slotGravatarEnableChanged(bool state);
private:
void updateWidgetState(bool state);
QCheckBox *mEnableGravatarSupport;
QCheckBox *mUseDefaultPixmap;
QPushButton *mClearGravatarCache;
......
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