diff --git a/src/widgets/chatwidget.cpp b/src/widgets/chatwidget.cpp index 89923021a..469e48ca2 100644 --- a/src/widgets/chatwidget.cpp +++ b/src/widgets/chatwidget.cpp @@ -38,6 +38,7 @@ static int index = 0; ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent) : BaseWidget(parent) + , parentPage(*parent) , channelManager(_channelManager) , completionManager(parent->completionManager) , channelName("/chatWidgets/" + std::to_string(index++) + "/channelName") @@ -176,6 +177,7 @@ bool ChatWidget::showChangeChannelPopup(const char *dialogTitle, bool empty) QString newChannelName = dialog.getText().trimmed(); this->channelName = newChannelName.toStdString(); + this->parentPage.refreshTitle(); return true; } diff --git a/src/widgets/chatwidget.hpp b/src/widgets/chatwidget.hpp index e05288f1a..e7112294d 100644 --- a/src/widgets/chatwidget.hpp +++ b/src/widgets/chatwidget.hpp @@ -71,6 +71,8 @@ private: void channelNameUpdated(const std::string &newChannelName); + NotebookPage &parentPage; + messages::LimitedQueue messages; std::shared_ptr channel; diff --git a/src/widgets/notebookpage.cpp b/src/widgets/notebookpage.cpp index 51c14c7b8..2c271fb16 100644 --- a/src/widgets/notebookpage.cpp +++ b/src/widgets/notebookpage.cpp @@ -43,6 +43,8 @@ NotebookPage::NotebookPage(ChannelManager &_channelManager, Notebook *parent, No this->ui.hbox.setSpacing(1); this->ui.hbox.setMargin(0); + + this->refreshTitle(); } std::pair NotebookPage::removeFromLayout(ChatWidget *widget) @@ -421,14 +423,24 @@ void NotebookPage::refreshTitle() bool first = true; for (const auto &chatWidget : this->chatWidgets) { + auto channelName = QString::fromStdString(chatWidget->channelName.getValue()); + + if (channelName.isEmpty()) { + continue; + } + if (!first) { newTitle += ", "; } - newTitle += QString::fromStdString(chatWidget->channelName.getValue()); + newTitle += channelName; first = false; } + if (newTitle.isEmpty()) { + newTitle = "empty"; + } + this->tab->setTitle(newTitle); }