qtui: Keep editing topic while someone talks
authorLee Starnes <lee@canned-death.us>
Sun, 6 Sep 2020 09:33:27 +0000 (04:33 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 8 Dec 2020 08:37:15 +0000 (09:37 +0100)
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

index f351597..336b902 100644 (file)
@@ -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)