Kstars

infoboxwidget.h
1/*
2 SPDX-FileCopyrightText: 2009 Khudyakov Alexey <alexey.skladnoy@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include <QWidget>
10#include <QPoint>
11#include <QList>
12#include <QString>
13#include <QStringList>
14
15class SkyPoint;
16class SkyObject;
17class InfoBoxWidget;
18
19/**
20 * @brief The InfoBoxes class is a collection of InfoBoxWidget objects that display a transparent box for display of text messages
21 */
22class InfoBoxes : public QWidget
23{
25
26 public:
27 explicit InfoBoxes(QWidget *parent = nullptr);
28
29 virtual ~InfoBoxes() override = default;
30
31 void addInfoBox(InfoBoxWidget *ibox);
32 QList<InfoBoxWidget *> getInfoBoxes() const { return m_boxes; }
33
34 protected:
35 void resizeEvent(QResizeEvent *event) override;
36
37 private:
39};
40
41/**
42* @brief The InfoBoxWidget class is a widget that displays a transparent box for display of text messages.
43*/
44class InfoBoxWidget : public QWidget
45{
47 public:
48 /** Alignment of widget. */
49 enum
50 {
51 NoAnchor = 0,
52 AnchorRight = 1,
53 AnchorBottom = 2,
54 AnchorBoth = 3
55 };
56
57 /** Create one infobox. */
58 InfoBoxWidget(bool shade, const QPoint &pos, int anchor = 0, const QStringList &str = QStringList(),
59 QWidget *parent = nullptr);
60 /** Destructor */
61 virtual ~InfoBoxWidget() override = default;
62
63 /** Check whether box is shaded. In this case only one line is shown. */
64 bool shaded() const { return m_shaded; }
65 /** Get stickyness status of */
66 int sticky() const { return m_anchor; }
67
68 /** Adjust widget's position */
69 void adjust();
70
71 public slots:
72 /** Set information about time. Data is taken from KStarsData. */
73 void slotTimeChanged();
74 /** Set information about location. Data is taken from KStarsData. */
75 void slotGeoChanged();
76 /** Set information about object. */
78 /** Set information about pointing. */
80 signals:
81 /** Emitted when widget is clicked */
82 void clicked();
83
84 protected:
85 void paintEvent(QPaintEvent *event) override;
86 void mouseDoubleClickEvent(QMouseEvent *event) override;
87 void mousePressEvent(QMouseEvent *event) override;
88 void mouseMoveEvent(QMouseEvent *event) override;
89 void mouseReleaseEvent(QMouseEvent *event) override;
90 void showEvent(QShowEvent *event) override;
91
92 private:
93 /** Uset to set information about object. */
94 void setPoint(QString name, SkyPoint *p);
95 /** Recalculate size of widget */
96 void updateSize();
97
98 /// List of string to show
99 QStringList m_strings;
100 /// True if widget coordinates were adjusted
101 bool m_adjusted { true };
102 /// True if widget is dragged around
103 bool m_grabbed { true };
104 /// True if widget if shaded
105 bool m_shaded { true };
106 /// Vertical alignment of widget
107 int m_anchor { 0 };
108
109 static const int padX;
110 static const int padY;
111};
The InfoBoxWidget class is a widget that displays a transparent box for display of text messages.
bool shaded() const
Check whether box is shaded.
InfoBoxWidget(bool shade, const QPoint &pos, int anchor=0, const QStringList &str=QStringList(), QWidget *parent=nullptr)
Create one infobox.
void adjust()
Adjust widget's position.
void slotObjectChanged(SkyObject *obj)
Set information about object.
void clicked()
Emitted when widget is clicked.
void slotGeoChanged()
Set information about location.
void slotPointChanged(SkyPoint *p)
Set information about pointing.
virtual ~InfoBoxWidget() override=default
Destructor.
int sticky() const
Get stickyness status of.
void slotTimeChanged()
Set information about time.
The InfoBoxes class is a collection of InfoBoxWidget objects that display a transparent box for displ...
Provides all necessary information about an object in the sky: its coordinates, name(s),...
Definition skyobject.h:42
The sky coordinates of a point in the sky.
Definition skypoint.h:45
Q_OBJECTQ_OBJECT
QObject * parent() const const
virtual bool event(QEvent *event) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:27 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.