Kstars

infoboxwidget.h
1 /*
2  SPDX-FileCopyrightText: 2009 Khudyakov Alexey <[email protected]>
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 
15 class SkyPoint;
16 class SkyObject;
17 class 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  */
22 class InfoBoxes : public QWidget
23 {
24  Q_OBJECT
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:
38  QList<InfoBoxWidget *> m_boxes;
39 };
40 
41 /**
42 * @brief The InfoBoxWidget class is a widget that displays a transparent box for display of text messages.
43 */
44 class InfoBoxWidget : public QWidget
45 {
46  Q_OBJECT
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. */
77  void slotObjectChanged(SkyObject *obj);
78  /** Set information about pointing. */
79  void slotPointChanged(SkyPoint *p);
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 };
Q_OBJECTQ_OBJECT
int sticky() const
Get stickyness status of.
Definition: infoboxwidget.h:66
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
virtual bool event(QEvent *event) override
void slotPointChanged(SkyPoint *p)
Set information about pointing.
void clicked()
Emitted when widget is clicked.
The InfoBoxes class is a collection of InfoBoxWidget objects that display a transparent box for displ...
Definition: infoboxwidget.h:22
InfoBoxWidget(bool shade, const QPoint &pos, int anchor=0, const QStringList &str=QStringList(), QWidget *parent=nullptr)
Create one infobox.
void slotTimeChanged()
Set information about time.
void slotObjectChanged(SkyObject *obj)
Set information about object.
void slotGeoChanged()
Set information about location.
void adjust()
Adjust widget's position.
The InfoBoxWidget class is a widget that displays a transparent box for display of text messages.
Definition: infoboxwidget.h:44
virtual ~InfoBoxWidget() override=default
Destructor.
Information about an object in the sky.
Definition: skyobject.h:41
QObject * parent() const const
bool shaded() const
Check whether box is shaded.
Definition: infoboxwidget.h:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 04:05:56 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.