Marble

PopupLayer.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
4// SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org>
5// SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com>
6//
7
8#ifndef POPUPLAYER_H
9#define POPUPLAYER_H
10
11#include "LayerInterface.h"
12
13#include <QObject>
14#include <QUrl>
15
16class QSizeF;
17
18namespace Marble
19{
20
21class GeoDataCoordinates;
22class MarbleWidget;
23
24/**
25 * @brief The PopupLayer class
26 *
27 * A popup dialog opening on top of the map. The content is shown in a QWebView,
28 * acting like a minimalistic web browser.
29 *
30 */
31class MARBLE_EXPORT PopupLayer : public QObject, public LayerInterface
32{
33 Q_OBJECT
34public:
35 explicit PopupLayer(MarbleWidget *widget, QObject *parent = nullptr);
36 ~PopupLayer() override;
37
38 QStringList renderPosition() const override;
39 bool render(GeoPainter *painter, ViewportParams *viewport, const QString &, GeoSceneLayer *) override;
40 bool eventFilter(QObject *, QEvent *) override;
41 qreal zValue() const override;
42
43 RenderState renderState() const override;
44
45 QString runtimeTrace() const override
46 {
47 return QStringLiteral("PopupLayer");
48 }
49
50 /**
51 * @brief Is popup item visible
52 *
53 * If popup item visible, it will return `true`,
54 * otherwise - `false`
55 *
56 * @return visibility of the item
57 */
58 bool visible() const;
59
60 /**
61 * @brief Set visibility of the item
62 *
63 * If @p visible is `true`, popup will be visible,
64 * otherwise - popup won't be visible.
65 *
66 * @param visible visibility of the item
67 */
68 void setVisible(bool visible);
69
70 /**
71 * @brief Make the dialog pop up
72 *
73 * This has the same effect as setVisible( true ) and additionally
74 * adjusts the viewport so that the dialog is fully visible.
75 */
76 void popup();
77
78 /**
79 * @brief Sets coordinates
80 *
81 * Use a geo position as the dialog base position. The dialog will be shown if
82 * it is visible and if the map viewport includes the given coordinates.
83 * This invalidates a screen position set with setPosition(), if any.
84 *
85 * Alignment of the dialog from the point of view of the coordinates. For example,
86 * Qt::AlignRight | Qt::AlignVCenter shows the dialog to the right of the geo position,
87 * vertically centered. An arrow points from the dialog to the geo position.
88 *
89 * @param coordinates geo coordinates
90 * @param alignment alignment of popup when it visible
91 */
92 void setCoordinates(const GeoDataCoordinates &coordinates, Qt::Alignment alignment);
93
94 /**
95 * @brief Sets URL of the browser
96 *
97 * @see PopupItem::setUrl();
98 *
99 * @param url url for web browser
100 */
101 void setUrl(const QUrl &url);
102
103 /**
104 * @brief Sets size of popup item
105 *
106 * Sets the @p size of the dialog (including the arrow, if any).
107 *
108 * @param size popup size, arrows in count
109 */
110 void setSize(const QSizeF &size);
111
112 /**
113 * @brief Sets content of the browser
114 *
115 * @see PopupItem::setContent();
116 *
117 * @param html content (in html format)
118 */
119 void setContent(const QString &html, const QUrl &baseUrl = QUrl());
120
121 /**
122 * @brief Sets background color of the header
123 *
124 * @see PopupItem::setBackgroundColor();
125 *
126 * @param color color to set
127 */
128 void setBackgroundColor(const QColor &color);
129
130 /**
131 * @brief Sets text color of the header
132 *
133 * @see PopupItem::setTextColor();
134 *
135 * @param color color to set
136 */
137 void setTextColor(const QColor &color);
138
139Q_SIGNALS:
140 void repaintNeeded();
141
142private Q_SLOTS:
143 void hidePopupItem();
144
145private:
146 class Private;
147 Private *const d;
148};
149
150}
151
152#endif
A 3d point representation.
A painter that allows to draw geometric primitives on the map.
Definition GeoPainter.h:86
Layer of a GeoScene document.
A widget class that displays a view of the earth.
The PopupLayer class.
Definition PopupLayer.h:32
A public class that controls what is visible in the viewport of a Marble map.
Binds a QML item to a specific geodetic location in screen coordinates.
typedef Alignment
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.