summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/simplewidgets.h
diff options
context:
space:
mode:
authorGravatar K. \"pestophagous\" Heller <pestophagous@gmail.com>2015-11-15 20:56:24 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-11-15 22:22:53 -0800
commit0a2f5d25c0cc246752db613a175bcd5416040a45 (patch)
treec5e6d48e4953a59815256fb5b8bdc52dc791ca1e /desktop-widgets/simplewidgets.h
parent99ed01e5710840976890551da4b02e630a8abee3 (diff)
downloadsubsurface-0a2f5d25c0cc246752db613a175bcd5416040a45.tar.gz
Parse html links in the Notes section.
In the spirit of "Do the simplest thing that could possibly work": capture Ctrl+leftclick mouse events in the Notes area. If the string under the clicked position is a valid url, then launch it. Many common URI schemes will work. Typing a url that starts with https:// will work. So will mailto: and file:// See #733 Signed-off-by: K. Heller <pestophagous@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/simplewidgets.h')
-rw-r--r--desktop-widgets/simplewidgets.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h
index 595c4cd4b..8a7a5df6a 100644
--- a/desktop-widgets/simplewidgets.h
+++ b/desktop-widgets/simplewidgets.h
@@ -231,6 +231,26 @@ private:
Ui::FilterWidget ui;
};
+class TextHyperlinkEventFilter : public QObject {
+ Q_OBJECT
+public:
+ explicit TextHyperlinkEventFilter(QTextEdit *txtEdit);
+
+ virtual bool eventFilter(QObject *target, QEvent *evt);
+
+private:
+ void handleUrlClick(const QString &urlStr);
+ void handleUrlTooltip(const QString &urlStr, const QPoint &pos);
+ bool stringMeetsOurUrlRequirements(const QString &maybeUrlStr);
+ QString fromCursorTilWhitespace(QTextCursor *cursor, const bool searchBackwards);
+ QString tryToFormulateUrl(QTextCursor *cursor);
+
+ QTextEdit const *const textEdit;
+ QWidget const *const scrollView;
+
+ Q_DISABLE_COPY(TextHyperlinkEventFilter)
+};
+
bool isGnome3Session();
QImage grayImage(const QImage &coloredImg);