File indexing completed on 2024-04-14 14:08:59
0001 /* 0002 SPDX-FileCopyrightText: 2004 Jason Harris <kstars@30doradus.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QDialog> 0010 #include <QDialogButtonBox> 0011 #include <QProcess> 0012 #include <QPlainTextEdit> 0013 #include <qsystemdetection.h> 0014 0015 #include <QNetworkAccessManager> 0016 #include <QNetworkRequest> 0017 #include <QNetworkReply> 0018 0019 #include "ui_wizwelcome.h" 0020 #include "ui_wizlocation.h" 0021 #include "ui_wizdownload.h" 0022 #include "ui_wizdata.h" 0023 #include "QProgressIndicator.h" 0024 0025 class GeoLocation; 0026 class QStackedWidget; 0027 0028 class WizWelcomeUI : public QFrame, public Ui::WizWelcome 0029 { 0030 Q_OBJECT 0031 0032 public: 0033 explicit WizWelcomeUI(QWidget *parent = nullptr); 0034 }; 0035 0036 class WizLocationUI : public QFrame, public Ui::WizLocation 0037 { 0038 Q_OBJECT 0039 0040 public: 0041 explicit WizLocationUI(QWidget *parent = nullptr); 0042 }; 0043 0044 class WizDataUI : public QFrame, public Ui::WizData 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 explicit WizDataUI(QWidget *parent = nullptr); 0050 }; 0051 0052 class WizDownloadUI : public QFrame, public Ui::WizDownload 0053 { 0054 Q_OBJECT 0055 0056 public: 0057 explicit WizDownloadUI(QWidget *parent = nullptr); 0058 }; 0059 0060 /** 0061 * @class KSWizard 0062 * The Startup Wizard will be automatically opened when KStars runs 0063 * for the first time. It allows the user to set up some basic parameters: 0064 * @li Geographic Location 0065 * @li Download extra data files 0066 * 0067 * @author Jason Harris 0068 * @version 1.0 0069 */ 0070 class KSWizard : public QDialog 0071 { 0072 Q_OBJECT 0073 public: 0074 /** 0075 * Constructor 0076 * @param parent Pointer to the parent widget 0077 */ 0078 explicit KSWizard(QWidget *parent = nullptr); 0079 0080 // Do NOT delete members of filteredCityList! They are not created by KSWizard. 0081 ~KSWizard() override = default; 0082 0083 /** @return pointer to the geographic location selected by the user */ 0084 const GeoLocation *geo() const 0085 { 0086 return Geo; 0087 } 0088 0089 private slots: 0090 void slotNextPage(); 0091 void slotPrevPage(); 0092 0093 /** 0094 * Set the geo pointer to the user's selected city, and display 0095 * its longitude and latitude in the window. 0096 * @note called when the highlighted city in the list box changes 0097 */ 0098 void slotChangeCity(); 0099 0100 /** 0101 * Display only those cities which meet the user's search criteria in the city list box. 0102 * @note called when one of the name filters is modified 0103 */ 0104 void slotFilterCities(); 0105 0106 void slotDownload(); 0107 0108 void slotInstallGSC(); 0109 0110 void slotExtractGSC(); 0111 0112 void slotGSCInstallerFinished(); 0113 0114 void slotUpdateDataButtons(); 0115 0116 void slotOpenOrCopyKStarsDataDirectory(); 0117 0118 private: 0119 /** 0120 * @short Initialize the geographic location page. 0121 * Populate the city list box, and highlight the current location in the list. 0122 */ 0123 void initGeoPage(); 0124 0125 /** @short set enabled/disable state of Next/Prev buttins based on current page */ 0126 void setButtonsEnabled(); 0127 0128 #ifdef Q_OS_OSX 0129 0130 bool GSCExists(); 0131 bool dataDirExists(); 0132 0133 0134 QProgressIndicator *gscMonitor { nullptr }; 0135 QTimer *downloadMonitor { nullptr }; 0136 QString gscZipPath; 0137 0138 #endif 0139 0140 QStackedWidget *wizardStack { nullptr }; 0141 WizWelcomeUI *welcome { nullptr }; 0142 WizLocationUI *location { nullptr }; 0143 WizDataUI *data { nullptr }; 0144 QPushButton *nextB { nullptr }; 0145 QPushButton *backB { nullptr }; 0146 QPushButton *completeB { nullptr }; 0147 QDialogButtonBox *buttonBox { nullptr }; 0148 GeoLocation *Geo { nullptr }; 0149 QList<GeoLocation *> filteredCityList; 0150 };