Made #channel link in /mentions jump to #channel split (#2220)
This commit is contained in:
@@ -2043,6 +2043,41 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
||||
SettingsDialogPreference::Accounts);
|
||||
}
|
||||
break;
|
||||
case Link::JumpToChannel: {
|
||||
// Get all currently open pages
|
||||
QList<SplitContainer *> openPages;
|
||||
|
||||
auto &nb = getApp()->windows->getMainWindow().getNotebook();
|
||||
for (int i = 0; i < nb.getPageCount(); ++i)
|
||||
{
|
||||
openPages.push_back(
|
||||
static_cast<SplitContainer *>(nb.getPageAt(i)));
|
||||
}
|
||||
|
||||
for (auto *page : openPages)
|
||||
{
|
||||
auto splits = page->getSplits();
|
||||
|
||||
// Search for channel matching link in page/split container
|
||||
// TODO(zneix): Consider opening a channel if it's closed (?)
|
||||
auto it = std::find_if(
|
||||
splits.begin(), splits.end(), [link](Split *split) {
|
||||
return split->getChannel()->getName() == link.value;
|
||||
});
|
||||
|
||||
if (it != splits.end())
|
||||
{
|
||||
// Select SplitContainer and Split itself where mention message was sent
|
||||
// TODO(zneix): Try exploring ways of scrolling to a certain message as well
|
||||
nb.select(page);
|
||||
|
||||
Split *split = *it;
|
||||
page->setSelected(split);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user