File indexing completed on 2025-01-05 03:59:19
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com> 0004 // SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org> 0005 // SPDX-FileCopyrightText: 2012 Illya Kovalevskyy <illya.kovalevskyy@gmail.com> 0006 // 0007 0008 #ifndef POPUPLAYER_H 0009 #define POPUPLAYER_H 0010 0011 #include "LayerInterface.h" 0012 0013 #include <QObject> 0014 #include <QUrl> 0015 0016 class QSizeF; 0017 0018 namespace Marble 0019 { 0020 0021 class GeoDataCoordinates; 0022 class MarbleWidget; 0023 0024 /** 0025 * @brief The PopupLayer class 0026 * 0027 * A popup dialog opening on top of the map. The content is shown in a QWebView, 0028 * acting like a minimalistic web browser. 0029 * 0030 */ 0031 class DIGIKAM_EXPORT PopupLayer : public QObject, public LayerInterface 0032 { 0033 Q_OBJECT 0034 public: 0035 explicit PopupLayer( MarbleWidget *widget, QObject* parent = nullptr ); 0036 ~PopupLayer() override; 0037 0038 QStringList renderPosition() const override; 0039 bool render( GeoPainter *painter, ViewportParams *viewport, 0040 const QString &, GeoSceneLayer * ) override; 0041 /* 0042 bool eventFilter( QObject *, QEvent * ) override; 0043 qreal zValue() const override; 0044 0045 RenderState renderState() const override; 0046 */ 0047 QString runtimeTrace() const override { return QStringLiteral("PopupLayer"); } 0048 0049 /** 0050 * @brief Is popup item visible 0051 * 0052 * If popup item visible, it will return `true`, 0053 * otherwise - `false` 0054 * 0055 * @return visibility of the item 0056 */ 0057 bool visible() const; 0058 0059 /** 0060 * @brief Set visibility of the item 0061 * 0062 * If @p visible is `true`, popup will be visible, 0063 * otherwise - popup won't be visible. 0064 * 0065 * @param visible visibility of the item 0066 */ 0067 void setVisible( bool visible ); 0068 0069 /** 0070 * @brief Make the dialog pop up 0071 * 0072 * This has the same effect as setVisible( true ) and additionally 0073 * adjusts the viewport so that the dialog is fully visible. 0074 */ 0075 void popup(); 0076 0077 /** 0078 * @brief Sets coordinates 0079 * 0080 * Use a geo position as the dialog base position. The dialog will be shown if 0081 * it is visible and if the map viewport includes the given coordinates. 0082 * This invalidates a screen position set with setPosition(), if any. 0083 * 0084 * Alignment of the dialog from the point of view of the coordinates. For example, 0085 * Qt::AlignRight | Qt::AlignVCenter shows the dialog to the right of the geo position, 0086 * vertically centered. An arrow points from the dialog to the geo position. 0087 * 0088 * @param coordinates geo coordinates 0089 * @param alignment alignment of popup when it visible 0090 */ 0091 void setCoordinates( const GeoDataCoordinates &coordinates, Qt::Alignment alignment ); 0092 0093 /** 0094 * @brief Sets URL of the browser 0095 * 0096 * @see PopupItem::setUrl(); 0097 * 0098 * @param url url for web browser 0099 */ 0100 void setUrl( const QUrl &url ); 0101 0102 /** 0103 * @brief Sets size of popup item 0104 * 0105 * Sets the @p size of the dialog (including the arrow, if any). 0106 * 0107 * @param size popup size, arrows in count 0108 */ 0109 void setSize( const QSizeF &size ); 0110 0111 /** 0112 * @brief Sets content of the browser 0113 * 0114 * @see PopupItem::setContent(); 0115 * 0116 * @param html content (in html format) 0117 */ 0118 void setContent( const QString &html, const QUrl & baseUrl = QUrl() ); 0119 0120 /** 0121 * @brief Sets background color of the header 0122 * 0123 * @see PopupItem::setBackgroundColor(); 0124 * 0125 * @param color color to set 0126 */ 0127 void setBackgroundColor( const QColor &color ); 0128 0129 /** 0130 * @brief Sets text color of the header 0131 * 0132 * @see PopupItem::setTextColor(); 0133 * 0134 * @param color color to set 0135 */ 0136 void setTextColor( const QColor &color ); 0137 0138 Q_SIGNALS: 0139 void repaintNeeded(); 0140 0141 private Q_SLOTS: 0142 void hidePopupItem(); 0143 0144 private: 0145 class Private; 0146 Private *const d; 0147 }; 0148 0149 } 0150 0151 #endif