LeechCraft Monocle 0.6.70-17335-ge406ffdcaf
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 <QMetaType>
14#include <QUrl>
15#include "coordsbase.h"
16
17namespace LC::Monocle
18{
25 enum class LinkType
26 {
38
42
46
50 };
51
55 {
59
62 std::optional<PageRelativeRectBase> TargetArea_ {};
63
66 std::optional<double> Zoom_ {};
67
68 bool operator== (const NavigationAction&) const = default;
69 bool operator< (const NavigationAction& other) const
70 {
71 const auto toTuple = [] (const NavigationAction& act)
72 {
73 qreal x {};
74 qreal y {};
75 qreal w {};
76 qreal h {};
77 act.TargetArea_.value_or (PageRelativeRectBase {}).ToRectF ().getRect (&x, &y, &w, &h);
78 return std::tie (act.PageNumber_, x, y, w, h); // don't care about the zoom
79 };
80
81 return toTuple (*this) < toTuple (other);
82 }
83 };
84
97
98 struct UrlAction
99 {
100 QUrl Url_;
101 };
102
103 using CustomAction = std::function<void ()>;
104
105 struct NoAction {};
106
107 using LinkAction = std::variant<NoAction, NavigationAction, ExternalNavigationAction, UrlAction, CustomAction>;
108
113 class ILink
114 {
115 public:
118 virtual ~ILink () = default;
119
124 virtual LinkType GetLinkType () const = 0;
125
133 virtual PageRelativeRectBase GetArea () const = 0;
134
137 virtual LinkAction GetLinkAction () const = 0;
138
141 virtual QString GetToolTip () const
142 {
143 return {};
144 }
145 };
146 typedef std::shared_ptr<ILink> ILink_ptr;
147}
148
149Q_DECLARE_INTERFACE (LC::Monocle::ILink, "org.LeechCraft.Monocle.ILink/1.0")
std::variant< NoAction, NavigationAction, ExternalNavigationAction, UrlAction, CustomAction > LinkAction
Definition ilink.h:107
std::shared_ptr< ILink > ILink_ptr
Definition ilink.h:146
LinkType
Describes various link types known to Monocle.
Definition ilink.h:26
@ OtherLink
Other link type.
Definition ilink.h:49
@ URL
A link to an URL.
Definition ilink.h:41
@ Command
Some standard command like printing.
Definition ilink.h:45
@ PageLink
A link to a page.
Definition ilink.h:37
std::function< void()> CustomAction
Definition ilink.h:103
A link action that represents navigating to a different document.
Definition ilink.h:88
NavigationAction DocumentNavigation_
Definition ilink.h:95
A link action that represents navigating inside the document.
Definition ilink.h:55
bool operator<(const NavigationAction &other) const
Definition ilink.h:69
std::optional< PageRelativeRectBase > TargetArea_
Definition ilink.h:62
bool operator==(const NavigationAction &) const =default
std::optional< double > Zoom_
Definition ilink.h:66