Kstars

kstarslite.h
1 /*
2  SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "config-kstars.h"
10 
11 //Needed for Projection enum
12 #include "projections/projector.h"
13 
14 #include <QQuickWindow>
15 #include <QPalette>
16 #include <QString>
17 #include <QtQml/QQmlApplicationEngine>
18 
19 #include <memory>
20 
21 // forward declaration is enough. We only need pointers
22 class KStarsData;
23 class SkyMapLite;
24 class SkyPoint;
25 class GeoLocation;
26 class ImageProvider;
27 
28 class FindDialogLite;
29 class DetailDialogLite;
30 class LocationDialogLite;
31 
32 class ClientManagerLite;
33 
34 class QQuickItem;
35 
36 /**
37  * @class KStarsLite
38  * @short This class loads QML files and connects SkyMapLite and KStarsData
39  * Unlike KStars class it is not a main window (see KStarsLite::m_Engine) but a root object that contains the program clock and
40  * holds pointers to SkyMapLite and KStarsData objects.
41  * KStarsLite is a singleton, use KStarsLite::createInstance() to create an instance and KStarsLite::Instance() to get a pointer to the instance
42  *
43  * @author Artem Fedoskin
44  * @version 1.0
45  */
46 class KStarsLite : public QObject
47 {
48  Q_OBJECT
49  //runTutorial is a wrapper for Options::RunStartupWizard()
50  Q_PROPERTY(bool runTutorial WRITE setRunTutorial READ getRunTutorial NOTIFY runTutorialChanged)
51  private:
52 
53  /**
54  * @short Constructor.
55  * @param doSplash should the splash panel be displayed during initialization.
56  * @param startClockRunning should the clock be running on startup?
57  * @param startDateString date (in string representation) to start running from.
58  */
59  explicit KStarsLite(bool doSplash, bool startClockRunning = true, const QString &startDateString = QString());
60  virtual ~KStarsLite();
61 
62  static KStarsLite *pinstance; // Pointer to an instance of KStarsLite
63 
64  public:
65  /**
66  * @short Create an instance of this class. Destroy any previous instance
67  * @param doSplash
68  * @param clockrunning
69  * @param startDateString
70  * @note See KStarsLite::KStarsLite for details on parameters
71  * @return a pointer to the instance
72  */
73  static KStarsLite *createInstance(bool doSplash, bool clockrunning = true,
74  const QString &startDateString = QString());
75 
76  /** @return a pointer to the instance of this class */
77  inline static KStarsLite *Instance() { return pinstance; }
78 
79  /** @return pointer to SkyMapLite object which draws SkyMap. */
80  inline SkyMapLite *map() const { return m_SkyMapLite; }
81 
82  /** @return pointer to the main window. */
84 
85  /** @return pointer to KStarsData object which contains application data. */
86  inline KStarsData *data() const { return m_KStarsData; }
87 
88  /** @return pointer to ImageProvider that is used in QML to display image fetched from CCD **/
89  inline ImageProvider *imageProvider() const { return m_imgProvider.get(); }
90 
91  /** @return pointer to QQmlApplicationEngine that runs QML **/
92  inline QQmlApplicationEngine *qmlEngine() { return &m_Engine; }
93 
94  /** @short used from QML to update positions of sky objects and update SkyMapLite */
95  Q_INVOKABLE void fullUpdate();
96 
97  /** @short currently sets color scheme from config **/
98  Q_INVOKABLE void applyConfig(bool doApplyFocus = true);
99 
100  /** @short set whether tutorial should be shown on next startup **/
101  void setRunTutorial(bool runTutorial);
102 
103  /** @return true if tutorial should be shown **/
104  bool getRunTutorial();
105 
106  /** @return pointer to KStarsData object which handles connection to INDI server. */
107  inline ClientManagerLite *clientManagerLite() const { return m_clientManager; }
108 
109  /**
110  * @defgroup kconfigwrappers QML wrappers around KConfig
111  * @{
112  */
113  enum class ObjectsToToggle
114  {
115  Stars,
116  DeepSky,
117  Planets,
118  CLines,
119  CBounds,
120  ConstellationArt,
121  MilkyWay,
122  CNames,
123  EquatorialGrid,
124  HorizontalGrid,
125  Ground,
126  Flags,
127  Satellites,
128  Supernovae
129  };
130 
131  Q_ENUMS(ObjectsToToggle)
132 
133  /** setProjection calls Options::setProjection(proj) and updates SkyMapLite */
134  // Having projection as uint is not good but it will go away once KConfig is fixed
135  // The reason for this is that you can't use Enums of another in class in Q_INVOKABLE function
136  Q_INVOKABLE void setProjection(uint proj);
137 
138  // These functions are just convenient getters to access internals of KStars from QML
139 
140  /**
141  * @short returns color with key name from current color scheme
142  * @param name the key name of the color to be retrieved from current color scheme
143  * @return color from name
144  */
146 
147  Q_INVOKABLE QString getConfigCScheme();
148 
149  /**
150  * @short toggles on/off objects of group toToggle
151  * @see ObjectsToToggle
152  */
153  Q_INVOKABLE void toggleObjects(ObjectsToToggle toToggle, bool toggle);
154 
155  /** @return true if objects from group toToggle are currently toggled on **/
156  Q_INVOKABLE bool isToggled(ObjectsToToggle toToggle);
157 
158  /** @} */ // end of kconfigwrappers group
159 
160 signals:
161  /** Sent when KStarsData finishes loading data */
162  void dataLoadFinished();
163 
164  /** Makes splash (Splash.qml) visible on startup */
165  void showSplash();
166 
167  /** Emitted whenever TimeSpinBox in QML changes the scale **/
168  void scaleChanged(float);
169 
170  void runTutorialChanged();
171 
172  /**
173  * Once this signal is emitted, notification with text msg will appear on the screen.
174  * Use this signal to output messages to user (warnings, info etc.)
175  */
176  void notificationMessage(QString msg);
177 
178  public Q_SLOTS:
179  /**
180  * Update time-dependent data and (possibly) repaint the sky map.
181  * @param automaticDSTchange change DST status automatically?
182  */
183  void updateTime(const bool automaticDSTchange = true);
184 
185  /** Write current settings to config file. Used to save config file upon exit */
186  bool writeConfig();
187 
188  /**
189  * Load a color scheme.
190  * @param name the name of the color scheme to load (e.g., "Moonless Night")
191  */
192  void loadColorScheme(const QString &name);
193 
194  /** sets time and date according to parameter time*/
195  void slotSetTime(QDateTime time);
196 
197  /** action slot: toggle whether kstars clock is running or not */
198  void slotToggleTimer();
199 
200  /** action slot: advance one step forward in time */
201  void slotStepForward();
202 
203  /** action slot: advance one step backward in time */
204  void slotStepBackward();
205 
206  /** start tracking clickedPoint or stop tracking if we are already tracking some object **/
207  void slotTrack();
208 
209 private slots:
210  /** finish setting up after the KStarsData has finished */
211  void datainitFinished();
212 
213  /** Save data to config file before exiting.*/
214  void handleStateChange(Qt::ApplicationState state);
215 
216  private:
217  /** Initialize focus position */
218  void initFocus();
219 
220  QQmlApplicationEngine m_Engine;
221  SkyMapLite *m_SkyMapLite { nullptr };
222  QPalette OriginalPalette, DarkPalette;
223 
224  QObject *m_RootObject { nullptr };
225  bool StartClockRunning { false };
226 
227  KStarsData *m_KStarsData { nullptr };
228  std::unique_ptr<ImageProvider> m_imgProvider;
229 
230  //Dialogs
231  FindDialogLite *m_findDialogLite { nullptr };
232  DetailDialogLite *m_detailDialogLite { nullptr };
233  LocationDialogLite *m_locationDialogLite { nullptr };
234 
235  ClientManagerLite *m_clientManager { nullptr };
236 };
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This class loads QML files and connects SkyMapLite and KStarsData Unlike KStars class it is not a mai...
Definition: kstarslite.h:46
void slotTrack()
start tracking clickedPoint or stop tracking if we are already tracking some object
Definition: kstarslite.cpp:185
Q_INVOKABLE QColor getColor(QString name)
returns color with key name from current color scheme
Definition: kstarslite.cpp:405
QQuickWindow * getMainWindow()
Definition: kstarslite.cpp:177
Q_SLOTSQ_SLOTS
bool getRunTutorial()
Definition: kstarslite.cpp:517
Stores dms coordinates for a point in the sky. for converting between coordinate systems.
Definition: skypoint.h:44
KStarsData * data() const
Definition: kstarslite.h:86
Backend for "Find Object" dialog in QML The way we are searching for the object is as follows: Each S...
static KStarsLite * Instance()
Definition: kstarslite.h:77
Q_ENUMS(...)
void loadColorScheme(const QString &name)
Load a color scheme.
Definition: kstarslite.cpp:297
Class that handles drawing of MilkyWay (both filled and non-filled)
Definition: milkyway.h:24
void dataLoadFinished()
Sent when KStarsData finishes loading data.
void scaleChanged(float)
Emitted whenever TimeSpinBox in QML changes the scale.
void slotStepForward()
action slot: advance one step forward in time
Definition: kstarslite.cpp:372
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
Definition: kstarslite.cpp:234
void notificationMessage(QString msg)
Once this signal is emitted, notification with text msg will appear on the screen.
SkyMapLite * map() const
Definition: kstarslite.h:80
Q_INVOKABLE void toggleObjects(ObjectsToToggle toToggle, bool toggle)
toggles on/off objects of group toToggle
Definition: kstarslite.cpp:415
ImageProvider * imageProvider() const
Definition: kstarslite.h:89
Q_INVOKABLE void fullUpdate()
used from QML to update positions of sky objects and update SkyMapLite
Definition: kstarslite.cpp:226
Q_INVOKABLEQ_INVOKABLE
void setRunTutorial(bool runTutorial)
set whether tutorial should be shown on next startup
Definition: kstarslite.cpp:508
Item for displaying sky objects; also handles user interaction events.
Definition: skymaplite.h:58
bool writeConfig()
Write current settings to config file.
Definition: kstarslite.cpp:264
void slotSetTime(QDateTime time)
sets time and date according to parameter time
Definition: kstarslite.cpp:326
ClientManagerLite * clientManagerLite() const
Definition: kstarslite.h:107
void slotToggleTimer()
action slot: toggle whether kstars clock is running or not
Definition: kstarslite.cpp:352
void showSplash()
Makes splash (Splash.qml) visible on startup.
void slotStepBackward()
action slot: advance one step backward in time
Definition: kstarslite.cpp:380
QQmlApplicationEngine * qmlEngine()
Definition: kstarslite.h:92
Q_INVOKABLE bool isToggled(ObjectsToToggle toToggle)
Definition: kstarslite.cpp:471
ApplicationState
static KStarsLite * createInstance(bool doSplash, bool clockrunning=true, const QString &startDateString=QString())
Create an instance of this class.
Definition: kstarslite.cpp:217
Relevant data about an observing location on Earth.
Definition: geolocation.h:27
Q_INVOKABLE void applyConfig(bool doApplyFocus=true)
currently sets color scheme from config
Definition: kstarslite.cpp:390
Q_INVOKABLE void setProjection(uint proj)
setProjection calls Options::setProjection(proj) and updates SkyMapLite
Definition: kstarslite.cpp:398
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:52 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.