From f35ca0d2c82b4a41d53f2651831db9472a3866a9 Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 24 Jan 2018 21:16:00 +0100 Subject: [PATCH] fixed right clicking links --- src/widgets/helper/channelview.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index b6c18e828..ed9c5374b 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -13,6 +13,7 @@ #include "widgets/split.hpp" #include "widgets/tooltipwidget.hpp" +#include #include #include #include @@ -825,7 +826,24 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) break; } case messages::Link::Url: { - QDesktopServices::openUrl(QUrl(link.getValue())); + if (event->button() == Qt::RightButton) { + 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.getValue(); + menu->move(QCursor::pos()); + menu->show(); + } else { + QDesktopServices::openUrl(QUrl(link.getValue())); + } break; } case messages::Link::UserAction: {