Marble

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

KDE's Doxygen guidelines are available online.