fixed right clicking links

This commit is contained in:
fourtf 2018-01-24 21:16:00 +01:00
parent 05339aad2d
commit f35ca0d2c8

View file

@ -13,6 +13,7 @@
#include "widgets/split.hpp" #include "widgets/split.hpp"
#include "widgets/tooltipwidget.hpp" #include "widgets/tooltipwidget.hpp"
#include <QClipboard>
#include <QDebug> #include <QDebug>
#include <QDesktopServices> #include <QDesktopServices>
#include <QGraphicsBlurEffect> #include <QGraphicsBlurEffect>
@ -825,7 +826,24 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
break; break;
} }
case messages::Link::Url: { case messages::Link::Url: {
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())); QDesktopServices::openUrl(QUrl(link.getValue()));
}
break; break;
} }
case messages::Link::UserAction: { case messages::Link::UserAction: {