summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-08-05 13:51:56 +0200
committerMontel Laurent <[email protected]>2016-08-05 13:51:56 +0200
commit936758922f3e30ecd2542809e5c2e8c165e8bc48 (patch)
tree37167d44db291d60b2032fc3651bece07563404e
parent09f84fc16956d637d52786432e68a077d9a39ec0 (diff)
Fix enable disable ok button
-rw-r--r--plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp27
-rw-r--r--plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h1
-rw-r--r--plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp3
3 files changed, 30 insertions, 1 deletions
diff --git a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
index 4b1f768..480560e 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
+++ b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.cpp
@@ -22,6 +22,7 @@
#include <QTest>
#include <QLabel>
#include <QCheckBox>
+#include <QPushButton>
#include <QDialogButtonBox>
#include <Libkdepim/AddresseeLineEdit>
@@ -45,6 +46,7 @@ void DelegateSelectorTest::shouldHaveDefaultValue()
KPIM::AddresseeLineEdit *mDelegate = w.findChild<KPIM::AddresseeLineEdit *>(QStringLiteral("delegate"));
QVERIFY(mDelegate);
+ QVERIFY(mDelegate->text().isEmpty());
QCheckBox *mRsvp = w.findChild<QCheckBox *>(QStringLiteral("informcheckbox"));
QVERIFY(mRsvp);
@@ -53,6 +55,31 @@ void DelegateSelectorTest::shouldHaveDefaultValue()
QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
QVERIFY(buttonBox);
+
+ QPushButton *mOkButton = buttonBox->button(QDialogButtonBox::Ok);
+ QVERIFY(mOkButton);
+ QVERIFY(!mOkButton->isEnabled());
+}
+
+void DelegateSelectorTest::shouldChangeOkButtonState()
+{
+ DelegateSelector w;
+ KPIM::AddresseeLineEdit *mDelegate = w.findChild<KPIM::AddresseeLineEdit *>(QStringLiteral("delegate"));
+ mDelegate->setEnableAkonadiSearch(false);
+ mDelegate->setEnableBalooSearch(false);
+
+ QDialogButtonBox *buttonBox = w.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
+ QPushButton *mOkButton = buttonBox->button(QDialogButtonBox::Ok);
+ QVERIFY(!mOkButton->isEnabled());
+
+
+ mDelegate->setText(QStringLiteral("foo"));
+ QVERIFY(mOkButton->isEnabled());
+
+ mDelegate->clear();
+ QVERIFY(!mOkButton->isEnabled());
+ mDelegate->setText(QStringLiteral(" "));
+ QVERIFY(!mOkButton->isEnabled());
}
QTEST_MAIN(DelegateSelectorTest)
diff --git a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
index f2f575c..7e3b65d 100644
--- a/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
+++ b/plugins/messageviewer/bodypartformatter/autotests/delegateselectortest.h
@@ -30,6 +30,7 @@ public:
~DelegateSelectorTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
+ void shouldChangeOkButtonState();
};
#endif // DELEGATESELECTORTEST_H
diff --git a/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp b/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
index 7dc79ba..9e71207 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
+++ b/plugins/messageviewer/bodypartformatter/calendar/delegateselector.cpp
@@ -57,6 +57,7 @@ DelegateSelector::DelegateSelector(QWidget *parent)
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
+ mOkButton->setObjectName(QStringLiteral("okbutton"));
mOkButton->setDefault(true);
mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &DelegateSelector::accept);
@@ -69,7 +70,7 @@ DelegateSelector::DelegateSelector(QWidget *parent)
void DelegateSelector::slotTextChanged(const QString &text)
{
- mOkButton->setEnabled(!text.isEmpty());
+ mOkButton->setEnabled(!text.trimmed().isEmpty());
}
QString DelegateSelector::delegate() const