summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-05-23 14:48:39 +0200
committerMontel Laurent <[email protected]>2015-05-23 14:48:57 +0200
commitf73dc8b9d3bd2db2064050c32d974dee4b39705a (patch)
tree9d668be01e1a4da7388cd5de73829fb878332769
parenta8566101377b8a0c05722ca241386073db6eeef8 (diff)
Enable/disable checkbox
-rw-r--r--messageviewer/tests/gravatarconfigwidgettest.cpp30
-rw-r--r--messageviewer/tests/gravatarconfigwidgettest.h1
-rw-r--r--messageviewer/widgets/gravatarconfigwidget.cpp17
-rw-r--r--messageviewer/widgets/gravatarconfigwidget.h2
4 files changed, 49 insertions, 1 deletions
diff --git a/messageviewer/tests/gravatarconfigwidgettest.cpp b/messageviewer/tests/gravatarconfigwidgettest.cpp
index 500a077..db0417c 100644
--- a/messageviewer/tests/gravatarconfigwidgettest.cpp
+++ b/messageviewer/tests/gravatarconfigwidgettest.cpp
@@ -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)
diff --git a/messageviewer/tests/gravatarconfigwidgettest.h b/messageviewer/tests/gravatarconfigwidgettest.h
index c175c1a..f80add8 100644
--- a/messageviewer/tests/gravatarconfigwidgettest.h
+++ b/messageviewer/tests/gravatarconfigwidgettest.h
@@ -29,6 +29,7 @@ public:
private Q_SLOTS:
void shouldHaveDefaultValue();
+ void shouldChangeState();
};
#endif // GRAVATARCONFIGWIDGETTEST_H
diff --git a/messageviewer/widgets/gravatarconfigwidget.cpp b/messageviewer/widgets/gravatarconfigwidget.cpp
index e398f72..2221307 100644
--- a/messageviewer/widgets/gravatarconfigwidget.cpp
+++ b/messageviewer/widgets/gravatarconfigwidget.cpp
@@ -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()
diff --git a/messageviewer/widgets/gravatarconfigwidget.h b/messageviewer/widgets/gravatarconfigwidget.h
index 214628c..bee7f16 100644
--- a/messageviewer/widgets/gravatarconfigwidget.h
+++ b/messageviewer/widgets/gravatarconfigwidget.h
@@ -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;