Skip to content

Commit

Permalink
Improved link detection
Browse files Browse the repository at this point in the history
  • Loading branch information
medo64 committed Apr 14, 2021
1 parent afcb2c8 commit f11ae5d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/storage/fileitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@ QString FileItem::findAnchorAt(QPoint pos) {
|| (ch == '-')
|| (ch == '.')
|| (ch == '_')
|| (ch == ':')
|| (ch == '/')
|| (ch == '?')
|| (ch == '&')
|| (ch == '~')
|| (ch == '%');
if (!isUrlChar) {
Expand Down Expand Up @@ -720,14 +724,19 @@ void FileItem::onContextMenuRequested(const QPoint& point) {

QString anchor = findAnchorAt(point);
if (!anchor.isEmpty()) {
QString anchorText = anchor;
int questionMark = anchorText.indexOf('?');
if (questionMark > 0) { anchorText = anchorText.left(questionMark); }
if (anchorText.length() > 42) { anchorText = anchorText.left(39) + ""; }

menu.addSeparator();

QAction* copyUrlAction = new QAction("Copy " + anchor);
QAction* copyUrlAction = new QAction("Copy " + anchorText);
copyUrlAction->setData(anchor);
connect(copyUrlAction, &QAction::triggered, this, &FileItem::onContextCopyUrl);
menu.addAction(copyUrlAction);

QAction* goToUrlAction = new QAction("Go to " + anchor);
QAction* goToUrlAction = new QAction("Go to " + anchorText);
goToUrlAction->setData(anchor);
connect(goToUrlAction, &QAction::triggered, this, &FileItem::onContextGoToUrl);
menu.addAction(goToUrlAction);
Expand Down

0 comments on commit f11ae5d

Please sign in to comment.