improved tab titles

added default and fixed refresh triggers on split rename
This commit is contained in:
fourtf 2017-08-17 22:25:41 +02:00
parent ab6474150d
commit 5b6596066e
3 changed files with 17 additions and 1 deletions

View file

@ -38,6 +38,7 @@ static int index = 0;
ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent) ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
: BaseWidget(parent) : BaseWidget(parent)
, parentPage(*parent)
, channelManager(_channelManager) , channelManager(_channelManager)
, completionManager(parent->completionManager) , completionManager(parent->completionManager)
, channelName("/chatWidgets/" + std::to_string(index++) + "/channelName") , channelName("/chatWidgets/" + std::to_string(index++) + "/channelName")
@ -176,6 +177,7 @@ bool ChatWidget::showChangeChannelPopup(const char *dialogTitle, bool empty)
QString newChannelName = dialog.getText().trimmed(); QString newChannelName = dialog.getText().trimmed();
this->channelName = newChannelName.toStdString(); this->channelName = newChannelName.toStdString();
this->parentPage.refreshTitle();
return true; return true;
} }

View file

@ -71,6 +71,8 @@ private:
void channelNameUpdated(const std::string &newChannelName); void channelNameUpdated(const std::string &newChannelName);
NotebookPage &parentPage;
messages::LimitedQueue<messages::SharedMessageRef> messages; messages::LimitedQueue<messages::SharedMessageRef> messages;
std::shared_ptr<Channel> channel; std::shared_ptr<Channel> channel;

View file

@ -43,6 +43,8 @@ NotebookPage::NotebookPage(ChannelManager &_channelManager, Notebook *parent, No
this->ui.hbox.setSpacing(1); this->ui.hbox.setSpacing(1);
this->ui.hbox.setMargin(0); this->ui.hbox.setMargin(0);
this->refreshTitle();
} }
std::pair<int, int> NotebookPage::removeFromLayout(ChatWidget *widget) std::pair<int, int> NotebookPage::removeFromLayout(ChatWidget *widget)
@ -421,14 +423,24 @@ void NotebookPage::refreshTitle()
bool first = true; bool first = true;
for (const auto &chatWidget : this->chatWidgets) { for (const auto &chatWidget : this->chatWidgets) {
auto channelName = QString::fromStdString(chatWidget->channelName.getValue());
if (channelName.isEmpty()) {
continue;
}
if (!first) { if (!first) {
newTitle += ", "; newTitle += ", ";
} }
newTitle += QString::fromStdString(chatWidget->channelName.getValue()); newTitle += channelName;
first = false; first = false;
} }
if (newTitle.isEmpty()) {
newTitle = "empty";
}
this->tab->setTitle(newTitle); this->tab->setTitle(newTitle);
} }