+void TopicWidget::on_topicLineEdit_textEntered() {
+ QModelIndex currentIdx = currentIndex();
+ if(currentIdx.isValid() && currentIdx.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer) {
+ BufferInfo bufferInfo = currentIdx.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+ if(ui.topicLineEdit->text().isEmpty())
+ Client::userInput(bufferInfo, QString("/quote TOPIC %1 :").arg(bufferInfo.bufferName()));
+ else
+ Client::userInput(bufferInfo, QString("/topic %1").arg(ui.topicLineEdit->text()));
+ }
+ switchPlain();
+}
+
+void TopicWidget::on_topicEditButton_clicked() {
+ switchEditable();
+}
+
+void TopicWidget::switchEditable() {
+ ui.stackedWidget->setCurrentIndex(1);
+ ui.topicLineEdit->setFocus();
+ updateGeometry();
+}
+
+void TopicWidget::switchPlain() {
+ ui.stackedWidget->setCurrentIndex(0);
+ ui.topicLineEdit->setText(_topic);
+ updateGeometry();
+}
+
+// filter for the input widget to switch back to normal mode
+bool TopicWidget::eventFilter(QObject *obj, QEvent *event) {
+ if(event->type() == QEvent::FocusOut) {
+ switchPlain();
+ return true;
+ }
+
+ if(event->type() != QEvent::KeyPress)
+ return QObject::eventFilter(obj, event);
+
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+
+ if(keyEvent->key() == Qt::Key_Escape) {
+ switchPlain();
+ return true;
+ }
+
+ return false;