11#include "GeoDataCoordinates.h"
12#include "GeoPainter.h"
15#include "RenderPlugin.h"
16#include "RenderState.h"
24class Q_DECL_HIDDEN PopupLayer::Private
27 Private(MarbleWidget *marbleWidget, PopupLayer *q);
33 void setAppropriateSize(
const ViewportParams *viewport);
35 static QString filterEmptyShortDescription(
const QString &description);
36 void setupDialogSatellite(
const GeoDataPlacemark *index);
37 void setupDialogCity(
const GeoDataPlacemark *index);
38 void setupDialogNation(
const GeoDataPlacemark *index);
39 void setupDialogGeoPlaces(
const GeoDataPlacemark *index);
40 void setupDialogSkyPlaces(
const GeoDataPlacemark *index);
42 PopupItem *
const m_popupItem;
43 MarbleWidget *
const m_widget;
45 bool m_hasCrosshairsPlugin;
46 bool m_crosshairsVisible;
49PopupLayer::Private::Private(MarbleWidget *marbleWidget, PopupLayer *q)
50 : m_popupItem(new PopupItem(q))
51 , m_widget(marbleWidget)
52 , m_hasCrosshairsPlugin(false)
53 , m_crosshairsVisible(true)
57PopupLayer::PopupLayer(MarbleWidget *marbleWidget,
QObject *parent)
59 , d(new Private(marbleWidget, this))
61 for (
const RenderPlugin *renderPlugin : d->m_widget->renderPlugins()) {
62 if (renderPlugin->nameId() == QLatin1StringView(
"crosshairs")) {
63 d->m_hasCrosshairsPlugin = true;
68 connect(d->m_popupItem, &PopupItem::repaintNeeded,
this, &PopupLayer::repaintNeeded);
69 connect(d->m_popupItem, &PopupItem::hide,
this, &PopupLayer::hidePopupItem);
72PopupLayer::~PopupLayer()
79 return QStringList(QStringLiteral(
"ALWAYS_ON_TOP"));
82bool PopupLayer::render(GeoPainter *painter, ViewportParams *viewport,
const QString &, GeoSceneLayer *)
85 d->setAppropriateSize(viewport);
86 d->m_popupItem->paintEvent(painter, viewport);
94 return visible() && d->m_popupItem->eventFilter(
object, e);
97qreal PopupLayer::zValue()
const
102RenderState PopupLayer::renderState()
const
104 return RenderState(QStringLiteral(
"Popup Window"));
107bool PopupLayer::visible()
const
109 return d->m_popupItem->visible();
112void PopupLayer::setVisible(
bool visible)
114 d->m_popupItem->setVisible(visible);
116 disconnect(d->m_popupItem, SIGNAL(repaintNeeded()),
this, SIGNAL(repaintNeeded()));
117 d->m_popupItem->clearHistory();
118 Q_EMIT repaintNeeded();
120 connect(d->m_popupItem, SIGNAL(repaintNeeded()),
this, SIGNAL(repaintNeeded()));
124void PopupLayer::popup()
130 d->m_widget->viewport()->radius(),
131 d->m_widget->viewport()->size());
132 qreal sx, sy, lon, lat;
134 sx = viewport.radius() < viewport.width() ? 0.5 * (viewport.width() + viewport.radius()) : 0.75 * viewport.width();
135 viewport.
geoCoordinates(sx, sy, lon, lat, GeoDataCoordinates::Radian);
138 d->m_widget->centerOn(coords,
true);
140 if (d->m_hasCrosshairsPlugin) {
141 d->m_crosshairsVisible = d->m_widget->showCrosshairs();
143 if (d->m_crosshairsVisible) {
144 d->m_widget->setShowCrosshairs(
false);
153 d->m_popupItem->setCoordinate(coordinates);
154 d->m_popupItem->setAlignment(alignment);
157void PopupLayer::setUrl(
const QUrl &url)
159 d->m_popupItem->setUrl(url);
162void PopupLayer::setContent(
const QString &html,
const QUrl &baseUrl)
164 d->m_popupItem->setContent(html, baseUrl);
167void PopupLayer::setBackgroundColor(
const QColor &color)
170 d->m_popupItem->setBackgroundColor(color);
174void PopupLayer::setTextColor(
const QColor &color)
177 d->m_popupItem->setTextColor(color);
181void PopupLayer::setSize(
const QSizeF &size)
183 d->m_requestedSize = size;
186void PopupLayer::Private::setAppropriateSize(
const ViewportParams *viewport)
191 maximumSize.
setWidth(viewport->width() - margin);
192 maximumSize.
setHeight(viewport->height() - margin);
194 QSizeF minimumSize(100.0, 100.0);
196 m_popupItem->setSize(m_requestedSize.boundedTo(maximumSize).expandedTo(minimumSize));
199void PopupLayer::hidePopupItem()
201 if (d->m_hasCrosshairsPlugin && d->m_crosshairsVisible) {
202 d->m_widget->setShowCrosshairs(d->m_crosshairsVisible);
210#include "moc_PopupLayer.cpp"
This file contains the headers for ViewportParams.
A 3d point representation.
void setLatitude(qreal lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
set the longitude in a GeoDataCoordinates object
void setLongitude(qreal lon, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Radian)
set the longitude in a GeoDataCoordinates object
A public class that controls what is visible in the viewport of a Marble map.
bool screenCoordinates(const qreal lon, const qreal lat, qreal &x, qreal &y) const
Get the screen coordinates corresponding to geographical coordinates in the map.
bool geoCoordinates(const int x, const int y, qreal &lon, qreal &lat, GeoDataCoordinates::Unit unit=GeoDataCoordinates::Degree) const
Get the earth coordinates corresponding to a pixel in the map.
Binds a QML item to a specific geodetic location in screen coordinates.
bool isValid() const const
void setHeight(qreal height)
void setWidth(qreal width)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)