mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Made #channel link in /mentions jump to #channel split (#2220)
This commit is contained in:
parent
1a4d4dca79
commit
49fa9bfd72
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
|
- Minor: Made "#channel" in `/mentions` tab a clickable link which takes you to the channel that you were mentioned in. (#2220)
|
||||||
- Minor: Added a keyboard shortcut (Ctrl+F5) for "Reconnect" (#2215)
|
- Minor: Added a keyboard shortcut (Ctrl+F5) for "Reconnect" (#2215)
|
||||||
- Minor: Made `Try to find usernames without @ prefix` option still resolve usernames when special characters (commas, dots, (semi)colons, exclamation mark, question mark) are appended to them. (#2212)
|
- Minor: Made `Try to find usernames without @ prefix` option still resolve usernames when special characters (commas, dots, (semi)colons, exclamation mark, question mark) are appended to them. (#2212)
|
||||||
- Minor: Made usercard update user's display name (#2160)
|
- Minor: Made usercard update user's display name (#2160)
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
AutoModAllow,
|
AutoModAllow,
|
||||||
AutoModDeny,
|
AutoModDeny,
|
||||||
OpenAccountsPage,
|
OpenAccountsPage,
|
||||||
|
JumpToChannel,
|
||||||
};
|
};
|
||||||
|
|
||||||
Link();
|
Link();
|
||||||
|
|
|
@ -356,7 +356,7 @@ void SharedMessageBuilder::addTextOrEmoji(const QString &string_)
|
||||||
void SharedMessageBuilder::appendChannelName()
|
void SharedMessageBuilder::appendChannelName()
|
||||||
{
|
{
|
||||||
QString channelName("#" + this->channel->getName());
|
QString channelName("#" + this->channel->getName());
|
||||||
Link link(Link::Url, this->channel->getName() + "\n" + this->message().id);
|
Link link(Link::JumpToChannel, this->channel->getName());
|
||||||
|
|
||||||
this->emplace<TextElement>(channelName, MessageElementFlag::ChannelName,
|
this->emplace<TextElement>(channelName, MessageElementFlag::ChannelName,
|
||||||
MessageColor::System)
|
MessageColor::System)
|
||||||
|
|
|
@ -2043,6 +2043,41 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link,
|
||||||
SettingsDialogPreference::Accounts);
|
SettingsDialogPreference::Accounts);
|
||||||
}
|
}
|
||||||
break;
|
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:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue