LeechCraft Monocle 0.6.70-16373-g319c272718
Modular document viewer for LeechCraft
Loading...
Searching...
No Matches
ilink.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <memory>
12#include <QObject>
13#include <QRectF>
14#include <QMetaType>
15#include <QUrl>
16
17namespace LC::Monocle
18{
25 enum class LinkType
26 {
38
41 URL,
42
45 Command,
46
50 };
51
55 {
59
65 std::optional<QRectF> TargetArea_ {};
66
69 std::optional<double> Zoom_ {};
70
71 bool operator== (const NavigationAction&) const = default;
72 bool operator< (const NavigationAction& other) const
73 {
74 const auto toTuple = [] (const NavigationAction& act)
75 {
76 qreal x {};
77 qreal y {};
78 qreal w {};
79 qreal h {};
80 act.TargetArea_.value_or (QRectF {}).getRect (&x, &y, &w, &h);
81 return std::tie (act.PageNumber_, x, y, w, h); // don't care about the zoom
82 };
83
84 return toTuple (*this) < toTuple (other);
85 }
86 };
87
100
102 {
103 QUrl Url_;
104 };
105
106 using CustomAction = std::function<void ()>;
107
108 struct NoAction {};
109
110 using LinkAction = std::variant<NoAction, NavigationAction, ExternalNavigationAction, UrlAction, CustomAction>;
111
116 class ILink
117 {
118 public:
121 virtual ~ILink () = default;
122
127 virtual LinkType GetLinkType () const = 0;
128
139 virtual QRectF GetArea () const = 0;
140
143 virtual LinkAction GetLinkAction () const = 0;
144
147 virtual QString GetToolTip () const
148 {
149 return {};
150 }
151 };
152 typedef std::shared_ptr<ILink> ILink_ptr;
153}
154
155Q_DECLARE_INTERFACE (LC::Monocle::ILink, "org.LeechCraft.Monocle.ILink/1.0")
std::variant< NoAction, NavigationAction, ExternalNavigationAction, UrlAction, CustomAction > LinkAction
Definition ilink.h:110
std::shared_ptr< ILink > ILink_ptr
Definition ilink.h:152
LinkType
Describes various link types known to Monocle.
Definition ilink.h:26
@ OtherLink
Other link type.
@ URL
A link to an URL.
@ Command
Some standard command like printing.
@ PageLink
A link to a page.
std::function< void()> CustomAction
Definition ilink.h:106
A link action that represents navigating to a different document.
Definition ilink.h:91
NavigationAction DocumentNavigation_
Definition ilink.h:98
A link action that represents navigating inside the document.
Definition ilink.h:55
std::optional< QRectF > TargetArea_
Definition ilink.h:65
bool operator<(const NavigationAction &other) const
Definition ilink.h:72
bool operator==(const NavigationAction &) const =default
std::optional< double > Zoom_
Definition ilink.h:69