mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed rightclicking links
This commit is contained in:
parent
0d76f6f39f
commit
a74c19d1f3
1 changed files with 16 additions and 18 deletions
|
@ -984,6 +984,17 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
if (!menu->actions().empty())
|
if (!menu->actions().empty())
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
|
// Link copy
|
||||||
|
if (hoverLayoutElement->getLink().type == Link::Url) {
|
||||||
|
QString url = hoverLayoutElement->getLink().value;
|
||||||
|
|
||||||
|
menu->addAction("Open link in browser",
|
||||||
|
[url] { QDesktopServices::openUrl(QUrl(url)); });
|
||||||
|
menu->addAction("Copy link", [url] { QApplication::clipboard()->setText(url); });
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
// Message actions
|
// Message actions
|
||||||
menu->addAction("Copy message", [layout] {
|
menu->addAction("Copy message", [layout] {
|
||||||
QString copyString;
|
QString copyString;
|
||||||
|
@ -1054,6 +1065,10 @@ void ChannelView::hideEvent(QHideEvent *)
|
||||||
void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link,
|
||||||
messages::MessageLayout *layout)
|
messages::MessageLayout *layout)
|
||||||
{
|
{
|
||||||
|
if (event->button() != Qt::LeftButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (link.type) {
|
switch (link.type) {
|
||||||
case messages::Link::UserInfo: {
|
case messages::Link::UserInfo: {
|
||||||
auto user = link.value;
|
auto user = link.value;
|
||||||
|
@ -1066,24 +1081,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case messages::Link::Url: {
|
case messages::Link::Url: {
|
||||||
if (event->button() == Qt::RightButton) {
|
QDesktopServices::openUrl(QUrl(link.value));
|
||||||
static QMenu *menu = nullptr;
|
|
||||||
static QString url;
|
|
||||||
|
|
||||||
if (menu == nullptr) {
|
|
||||||
menu = new QMenu;
|
|
||||||
menu->addAction("Open in browser",
|
|
||||||
[] { QDesktopServices::openUrl(QUrl(url)); });
|
|
||||||
menu->addAction("Copy to clipboard",
|
|
||||||
[] { QApplication::clipboard()->setText(url); });
|
|
||||||
}
|
|
||||||
|
|
||||||
url = link.value;
|
|
||||||
menu->move(QCursor::pos());
|
|
||||||
menu->show();
|
|
||||||
} else {
|
|
||||||
QDesktopServices::openUrl(QUrl(link.value));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case messages::Link::UserAction: {
|
case messages::Link::UserAction: {
|
||||||
|
|
Loading…
Reference in a new issue