Kstars

kstarslite.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
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
22class KStarsData;
23class SkyMapLite;
24class SkyPoint;
25class GeoLocation;
26class ImageProvider;
27
28class FindDialogLite;
29class DetailDialogLite;
31
33
34class 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 */
46class KStarsLite : public QObject
47{
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 */
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
160signals:
161 /** Sent when KStarsData finishes loading data */
163
164 /** Makes splash (Splash.qml) visible on startup */
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 */
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
209private 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};
Backend for "Find Object" dialog in QML The way we are searching for the object is as follows: Each S...
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
This class makes it possible to use QImages from C++ in QML.
KStarsData is the backbone of KStars.
Definition kstarsdata.h:74
This class loads QML files and connects SkyMapLite and KStarsData Unlike KStars class it is not a mai...
Definition kstarslite.h:47
void slotToggleTimer()
action slot: toggle whether kstars clock is running or not
void setRunTutorial(bool runTutorial)
set whether tutorial should be shown on next startup
void dataLoadFinished()
Sent when KStarsData finishes loading data.
ClientManagerLite * clientManagerLite() const
Definition kstarslite.h:107
bool getRunTutorial()
Q_INVOKABLE void applyConfig(bool doApplyFocus=true)
currently sets color scheme from config
bool writeConfig()
Write current settings to config file.
SkyMapLite * map() const
Definition kstarslite.h:80
void scaleChanged(float)
Emitted whenever TimeSpinBox in QML changes the scale.
QQuickWindow * getMainWindow()
void updateTime(const bool automaticDSTchange=true)
Update time-dependent data and (possibly) repaint the sky map.
static KStarsLite * Instance()
Definition kstarslite.h:77
void slotStepBackward()
action slot: advance one step backward in time
static KStarsLite * createInstance(bool doSplash, bool clockrunning=true, const QString &startDateString=QString())
Create an instance of this class.
QQmlApplicationEngine * qmlEngine()
Definition kstarslite.h:92
ImageProvider * imageProvider() const
Definition kstarslite.h:89
void slotTrack()
start tracking clickedPoint or stop tracking if we are already tracking some object
Q_INVOKABLE void fullUpdate()
used from QML to update positions of sky objects and update SkyMapLite
void notificationMessage(QString msg)
Once this signal is emitted, notification with text msg will appear on the screen.
void slotStepForward()
action slot: advance one step forward in time
void slotSetTime(QDateTime time)
sets time and date according to parameter time
void showSplash()
Makes splash (Splash.qml) visible on startup.
void loadColorScheme(const QString &name)
Load a color scheme.
KStarsData * data() const
Definition kstarslite.h:86
A backend of location dialog declared in QML.
Class that handles drawing of MilkyWay (both filled and non-filled)
Definition milkyway.h:25
This is the main item that displays all SkyItems.
Definition skymaplite.h:59
The sky coordinates of a point in the sky.
Definition skypoint.h:45
Q_INVOKABLE void toggleObjects(ObjectsToToggle toToggle, bool toggle)
toggles on/off objects of group toToggle
Q_INVOKABLE bool isToggled(ObjectsToToggle toToggle)
Q_INVOKABLE QColor getColor(QString name)
returns color with key name from current color scheme
Q_INVOKABLE void setProjection(uint proj)
setProjection calls Options::setProjection(proj) and updates SkyMapLite
Q_ENUMS(...)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
ApplicationState
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.