[kde-doc-english] [trojita] src/Gui: GUI: propagate changes in text fileds when editing finishes

Jan Kundrát jkt at flaska.net
Mon May 26 22:49:38 UTC 2014


Git commit 93a73b550acbb4c3871da60a770e8f66aa7508c6 by Jan Kundrát.
Committed on 26/05/2014 at 22:28.
Pushed by jkt into branch 'master'.

GUI: propagate changes in text fileds when editing finishes

Thanks to Thomas Lübking for proposing this.

REVIEW: 118336

M  +7    -0    src/Gui/LineEdit.cpp
M  +4    -0    src/Gui/LineEdit.h
M  +4    -4    src/Gui/SettingsDialog.cpp

http://commits.kde.org/trojita/93a73b550acbb4c3871da60a770e8f66aa7508c6

diff --git a/src/Gui/LineEdit.cpp b/src/Gui/LineEdit.cpp
index bcd5d05..54dfdf1 100644
--- a/src/Gui/LineEdit.cpp
+++ b/src/Gui/LineEdit.cpp
@@ -55,6 +55,8 @@ void LineEdit::init()
     layout->setContentsMargins(0, 0, 0, 0);
     layout->addStretch();
     layout->addWidget(m_clearButton);
+
+    connect(this, SIGNAL(editingFinished()), this, SLOT(doEmitTextEditingFinished()));
 }
 
 QToolButton *LineEdit::clearButton()
@@ -183,3 +185,8 @@ void LineEdit::restoreInlineCompletion()
     completer()->setCompletionMode(QCompleter::InlineCompletion);
     CALL_LATER_NOARG(this, setFocus); // can't get in the second event cycle either
 }
+
+void LineEdit::doEmitTextEditingFinished()
+{
+    emit textEditingFinished(text());
+}
diff --git a/src/Gui/LineEdit.h b/src/Gui/LineEdit.h
index 244ec5f..f124f0e 100644
--- a/src/Gui/LineEdit.h
+++ b/src/Gui/LineEdit.h
@@ -27,6 +27,9 @@ public:
     void setHistoryEnabled(bool enabled = true);
     virtual QSize sizeHint() const;
 
+signals:
+    void textEditingFinished(const QString &text);
+
 protected:
     bool eventFilter(QObject *o, QEvent *e);
     void keyReleaseEvent(QKeyEvent *ke);
@@ -35,6 +38,7 @@ private Q_SLOTS:
     void updateClearButton(const QString &text);
     void learnEntry();
     void restoreInlineCompletion();
+    void doEmitTextEditingFinished();
 
 private:
     void init();
diff --git a/src/Gui/SettingsDialog.cpp b/src/Gui/SettingsDialog.cpp
index 146e29c..80fd378 100644
--- a/src/Gui/SettingsDialog.cpp
+++ b/src/Gui/SettingsDialog.cpp
@@ -753,13 +753,13 @@ OutgoingPage::OutgoingPage(SettingsDialog *parent, QSettings &s): QScrollArea(pa
     connect(smtpAuth, SIGNAL(toggled(bool)), m_smtpAccountSettings, SLOT(setAuthenticateEnabled(bool)));
     connect(saveToImap, SIGNAL(toggled(bool)), m_smtpAccountSettings, SLOT(setSaveToImap(bool)));
 
-    connect(smtpHost, SIGNAL(textChanged(QString)), m_smtpAccountSettings, SLOT(setServer(QString)));
-    connect(smtpUser, SIGNAL(textChanged(QString)), m_smtpAccountSettings, SLOT(setUsername(QString)));
-    connect(smtpPort, SIGNAL(textChanged(QString)), this, SLOT(setPortByText(QString)));
+    connect(smtpHost, SIGNAL(textEditingFinished(QString)), m_smtpAccountSettings, SLOT(setServer(QString)));
+    connect(smtpUser, SIGNAL(textEditingFinished(QString)), m_smtpAccountSettings, SLOT(setUsername(QString)));
+    connect(smtpPort, SIGNAL(textEditingFinished(QString)), this, SLOT(setPortByText(QString)));
     connect(m_smtpAccountSettings, SIGNAL(showPortWarning(QString)), this, SLOT(showPortWarning(QString)));
     connect(smtpAuth, SIGNAL(toggled(bool)), m_smtpAccountSettings, SLOT(setAuthenticateEnabled(bool)));
     connect(saveToImap, SIGNAL(toggled(bool)), m_smtpAccountSettings, SLOT(setSaveToImap(bool)));
-    connect(saveFolderName, SIGNAL(textChanged(QString)), m_smtpAccountSettings, SLOT(setSentMailboxName(QString)));
+    connect(saveFolderName, SIGNAL(textEditingFinished(QString)), m_smtpAccountSettings, SLOT(setSentMailboxName(QString)));
     connect(smtpBurl, SIGNAL(toggled(bool)), m_smtpAccountSettings, SLOT(setUseBurl(bool)));
 
     m_pwWatcher = new UiUtils::PasswordWatcher(this, m_parent->pluginManager(), QLatin1String("account-0"), QLatin1String("smtp"));


More information about the kde-doc-english mailing list