summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-07-12 22:18:42 +0200
committerMontel Laurent <[email protected]>2017-07-12 22:18:42 +0200
commit01c8df729906a717c3d56baae34f0abb155e2599 (patch)
tree6efae76d6450c56c893933add0e39de1a20913e8
parent23efe8de6915f128b8611dcea9f1e02cc3aec53d (diff)
Fix enable/disable ok button
-rw-r--r--plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp10
-rw-r--r--plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp
index 7c9967d..cecef67 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp
+++ b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.cpp
@@ -24,6 +24,8 @@
#include <KLocalizedString>
#include <KConfigGroup>
#include <KSharedConfig>
+#include <QPushButton>
+#include <KPIMTextEdit/PlainTextEditor>
#include "kpimtextedit/plaintexteditorwidget.h"
ReactionToInvitationDialog::ReactionToInvitationDialog(QWidget *parent)
@@ -39,10 +41,12 @@ ReactionToInvitationDialog::ReactionToInvitationDialog(QWidget *parent)
mPlainTextEditor = new KPIMTextEdit::PlainTextEditorWidget(this);
mPlainTextEditor->setObjectName(QStringLiteral("plaintexteditor"));
layout->addWidget(mPlainTextEditor);
+ connect(mPlainTextEditor->editor(), &KPIMTextEdit::PlainTextEditor::textChanged, this, &ReactionToInvitationDialog::slotTextChanged);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
buttonBox->setObjectName(QStringLiteral("buttonbox"));
layout->addWidget(buttonBox);
+ mOkButton = buttonBox->button(QDialogButtonBox::Ok);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ReactionToInvitationDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ReactionToInvitationDialog::reject);
readConfig();
@@ -50,9 +54,15 @@ ReactionToInvitationDialog::ReactionToInvitationDialog(QWidget *parent)
ReactionToInvitationDialog::~ReactionToInvitationDialog()
{
+ disconnect(mPlainTextEditor->editor(), &KPIMTextEdit::PlainTextEditor::textChanged, this, &ReactionToInvitationDialog::slotTextChanged);
writeConfig();
}
+void ReactionToInvitationDialog::slotTextChanged()
+{
+ mOkButton->setEnabled(!mPlainTextEditor->editor()->document()->isEmpty());
+}
+
QString ReactionToInvitationDialog::comment() const
{
return mPlainTextEditor->toPlainText();
diff --git a/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h
index 37ec179..f540480 100644
--- a/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h
+++ b/plugins/messageviewer/bodypartformatter/calendar/reactiontoinvitationdialog.h
@@ -35,9 +35,11 @@ public:
QString comment() const;
private:
+ void slotTextChanged();
void writeConfig();
void readConfig();
KPIMTextEdit::PlainTextEditorWidget *mPlainTextEditor;
+ QPushButton *mOkButton;
};
#endif // REACTIONTOINVITATIONDIALOG_H