Marble

PopupItem.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Torsten Rahn <[email protected]>
4 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <[email protected]>
5 // SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <[email protected]>
6 //
7 
8 #ifndef POPUPITEM_H
9 #define POPUPITEM_H
10 
11 #include <QObject>
12 #include <QUrl>
13 
14 #include "BillboardGraphicsItem.h"
15 
16 #ifdef MARBLE_NO_WEBKITWIDGETS
17 #include "ui_NullWebPopupWidget.h"
18 #else
19 #include "ui_WebPopupWidget.h"
20 #endif
21 
22 class QPainter;
23 
24 namespace Marble
25 {
26 
27 /**
28  * @brief The PopupItem Class
29  *
30  * This class represents graphics item for information bubble.
31  * Mostly used by @see MapInfoDialog.
32  *
33  * It has nice API for QWebEngineView and methods for styling it.
34  *
35  */
36 class PopupItem : public QObject, public BillboardGraphicsItem
37 {
38  Q_OBJECT
39 public:
40  explicit PopupItem( QObject* parent = nullptr );
41  ~PopupItem() override;
42 
43  /**
44  * @brief Print button visibility indicator
45  *
46  * There is a button in the header of item with print icon.
47  * It used to print the content of QWebEngineView inside.
48  * This method indicates visibility of this button.
49  *
50  * @see setPrintButtonVisible();
51  *
52  * @return visibility of the print button
53  */
54  bool isPrintButtonVisible() const;
55 
56  /**
57  * @brief Sets visibility of the print button
58  *
59  * There is a button in the header of item with print icon.
60  * It used to print the content of QWebEngineView inside
61  *
62  * This method sets visibility of this button.
63  *
64  * If @p display is `true`, button will be displayed,
65  * otherwise - button won't be displayed
66  *
67  * @param display visibility of the print button
68  */
69  void setPrintButtonVisible(bool display);
70 
71  /**
72  * @brief Set URL for web window
73  *
74  * There is a small web browser inside.
75  * It can show open websites.
76  *
77  * This method sets @p url for its window.
78  *
79  * @param url new url for web window
80  */
81  void setUrl( const QUrl &url );
82 
83  /**
84  * @brief Set content of the popup
85  *
86  * There is a small web browser inside. It can show custom HTML.
87  * This method sets custom @p html for its window
88  *
89  * @param html custom html for popup
90  * @param baseUrl base URL for popup
91  */
92  void setContent( const QString &html, const QUrl & baseUrl = QUrl() );
93 
94  /**
95  * @brief Sets text color of the header
96  *
97  * Frame of the web browser is called bubble. Bubble has
98  * a header - part of the bubble at the top. Usually
99  * it contains the name of the page which can be set via
100  * TITLE html tag in HTML document loaded.
101  * This method sets text @p color of the header.
102  *
103  * @param color text color of the header
104  */
105  void setTextColor( const QColor &color );
106 
107  /**
108  * @brief Sets background color of the bubble
109  *
110  * Frame of the web browser is called bubble. This method
111  * sets background @p color of this bubble.
112  *
113  * @param color background color of the bubble
114  */
115  void setBackgroundColor( const QColor &color );
116 
117  bool eventFilter( QObject *, QEvent *e ) override;
118 
119  void clearHistory();
120 
121 private Q_SLOTS:
122  /**
123  * @brief Marks cache as dirty and tells the world its need for repainting.
124  */
125  void requestUpdate();
126 
127  /**
128  * @brief Print content of the web browser
129  *
130  * Popup Item has built-in mini-browser. This function
131  * executes print dialog for printing its content.
132  *
133  */
134  void printContent() const;
135 
136  /**
137  * @brief Updates Back Button (web surfing history)
138  *
139  * When you are browsing the site you may need to visit
140  * the page, you have visited before (Go Back).
141  *
142  * For this action Popup Item has a button Go Back placed
143  * in the left of the header.
144  *
145  * @note it's visible only if web surfing history is not clear or
146  * you are not on its first page.
147  *
148  * @see goBack();
149  *
150  */
151  void updateBackButton();
152 
153  /**
154  * @brief Go Back (web surfing history)
155  *
156  * This method moves you one step backwards in
157  * web surfing history.
158  *
159  */
160  void goBack();
161 
162  /**
163  * @brief Opens clicked URL in external browser.
164  * @param url URL to be opened in external browser
165  */
166  void openUrl(const QUrl &url);
167 
168 protected:
169  void paint( QPainter *painter ) override;
170 
171 Q_SIGNALS:
172  void repaintNeeded();
173  void hide();
174 
175 private:
176  QPixmap pixmap( const QString &imageid ) const;
177  static void colorize( QImage &img, const QColor &col );
178  QWidget* transform( QPoint &point ) const;
179 
180  QWidget *m_widget;
181  Ui::WebPopupWidget m_ui;
182  QString m_content;
183  QColor m_textColor;
184  QColor m_backColor;
185  bool m_needMouseRelease;
186  QUrl m_baseUrl;
187 };
188 
189 }
190 
191 #endif
Q_OBJECTQ_OBJECT
void setUrl(const QUrl &url)
Set URL for web window.
Definition: PopupItem.cpp:97
Q_SLOTSQ_SLOTS
void setPrintButtonVisible(bool display)
Sets visibility of the print button.
Definition: PopupItem.cpp:92
Base class for all 2D labels (a.k.a.
bool isPrintButtonVisible() const
Print button visibility indicator.
Definition: PopupItem.cpp:87
void setBackgroundColor(const QColor &color)
Sets background color of the bubble.
Definition: PopupItem.cpp:134
Binds a QML item to a specific geodetic location in screen coordinates.
Q_SIGNALSQ_SIGNALS
The PopupItem Class.
Definition: PopupItem.h:36
void setTextColor(const QColor &color)
Sets text color of the header.
Definition: PopupItem.cpp:122
QObject * parent() const const
void setContent(const QString &html, const QUrl &baseUrl=QUrl())
Set content of the popup.
Definition: PopupItem.cpp:111
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Dec 4 2023 04:12:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.