From b0035602d3739325537e4668d92fdd9932f7eccc Mon Sep 17 00:00:00 2001 From: Lee Starnes Date: Sun, 6 Sep 2020 04:33:27 -0500 Subject: [PATCH] qtui: Keep editing topic while someone talks Without this change, it's almost impossible to edit the topic with the topic widget in busy channels because every message would trigger the dataChanged signal which would reset the topic and switch the topic widget out of editing mode. Fixes #1485. --- src/qtui/topicwidget.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index f351597f..336b902d 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -152,13 +152,17 @@ void TopicWidget::setTopic(const QModelIndex& index) } } - _topic = sanitizeTopic(newtopic); - _readonly = readonly; - - ui.topicEditButton->setVisible(!_readonly); - ui.topicLabel->setText(_topic); - ui.topicLineEdit->setPlainText(_topic); - switchPlain(); + QString sanitizedNewTopic = sanitizeTopic(newtopic); + if (readonly != _readonly || sanitizedNewTopic != _topic) + { + _topic = sanitizedNewTopic; + _readonly = readonly; + + ui.topicEditButton->setVisible(!_readonly); + ui.topicLabel->setText(_topic); + ui.topicLineEdit->setPlainText(_topic); + switchPlain(); + } } void TopicWidget::setReadOnly(const bool& readonly) -- 2.20.1