1 /*
2     SPDX-FileCopyrightText: 2004 Jason Harris <kstars@30doradus.org>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QDialog>
10 #include <QDialogButtonBox>
11 #include <QProcess>
12 #include <QPlainTextEdit>
13 #include <qsystemdetection.h>
14 
15 #include <QNetworkAccessManager>
16 #include <QNetworkRequest>
17 #include <QNetworkReply>
18 
19 #include "ui_wizwelcome.h"
20 #include "ui_wizlocation.h"
21 #include "ui_wizdownload.h"
22 #include "ui_wizdata.h"
23 #include "QProgressIndicator.h"
24 
25 class GeoLocation;
26 class QStackedWidget;
27 
28 class WizWelcomeUI : public QFrame, public Ui::WizWelcome
29 {
30         Q_OBJECT
31 
32     public:
33         explicit WizWelcomeUI(QWidget *parent = nullptr);
34 };
35 
36 class WizLocationUI : public QFrame, public Ui::WizLocation
37 {
38         Q_OBJECT
39 
40     public:
41         explicit WizLocationUI(QWidget *parent = nullptr);
42 };
43 
44 class WizDataUI : public QFrame, public Ui::WizData
45 {
46         Q_OBJECT
47 
48     public:
49         explicit WizDataUI(QWidget *parent = nullptr);
50 };
51 
52 class WizDownloadUI : public QFrame, public Ui::WizDownload
53 {
54         Q_OBJECT
55 
56     public:
57         explicit WizDownloadUI(QWidget *parent = nullptr);
58 };
59 
60 /**
61  * @class KSWizard
62  * The Startup Wizard will be automatically opened when KStars runs
63  * for the first time.  It allows the user to set up some basic parameters:
64  * @li Geographic Location
65  * @li Download extra data files
66  *
67  * @author Jason Harris
68  * @version 1.0
69  */
70 class KSWizard : public QDialog
71 {
72         Q_OBJECT
73     public:
74         /**
75          * Constructor
76          * @param parent Pointer to the parent widget
77          */
78         explicit KSWizard(QWidget *parent = nullptr);
79 
80         // Do NOT delete members of filteredCityList! They are not created by KSWizard.
81         ~KSWizard() override = default;
82 
83         /** @return pointer to the geographic location selected by the user */
geo()84         const GeoLocation *geo() const
85         {
86             return Geo;
87         }
88 
89     private slots:
90         void slotNextPage();
91         void slotPrevPage();
92 
93         /**
94          * Set the geo pointer to the user's selected city, and display
95          * its longitude and latitude in the window.
96          * @note called when the highlighted city in the list box changes
97          */
98         void slotChangeCity();
99 
100         /**
101          * Display only those cities which meet the user's search criteria in the city list box.
102          * @note called when one of the name filters is modified
103          */
104         void slotFilterCities();
105 
106         void slotDownload();
107 
108         void slotInstallGSC();
109 
110         void slotExtractGSC();
111 
112         void slotGSCInstallerFinished();
113 
114         void slotUpdateDataButtons();
115 
116         void slotOpenOrCopyKStarsDataDirectory();
117 
118     private:
119         /**
120          * @short Initialize the geographic location page.
121          * Populate the city list box, and highlight the current location in the list.
122          */
123         void initGeoPage();
124 
125         /** @short set enabled/disable state of Next/Prev buttins based on current page */
126         void setButtonsEnabled();
127 
128 #ifdef Q_OS_OSX
129 
130         bool GSCExists();
131         bool dataDirExists();
132 
133 
134         QProgressIndicator *gscMonitor { nullptr };
135         QTimer *downloadMonitor { nullptr };
136         QString gscZipPath;
137 
138 #endif
139 
140         QStackedWidget *wizardStack { nullptr };
141         WizWelcomeUI *welcome { nullptr };
142         WizLocationUI *location { nullptr };
143         WizDataUI *data { nullptr };
144         QPushButton *nextB { nullptr };
145         QPushButton *backB { nullptr };
146         QPushButton *completeB { nullptr };
147         QDialogButtonBox *buttonBox { nullptr };
148         GeoLocation *Geo { nullptr };
149         QList<GeoLocation *> filteredCityList;
150 };
151