Debian Codegraph @

src/GUI/SetupRootDialog.hxx

raw symbols SCIP
1 // SetupRootDialog.hxx - part of GUI launcher using Qt5
2 //
3 // Written by James Turner, started December 2014.
4 //
5 // Copyright (C) 2014 James Turner <[email protected]>
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 #include <QDialog>
22 #include <QScopedPointer>
23 #include <QString>
24
25 #include <string>
26
27 #include <simgear/misc/sg_path.hxx>
28
29 #include "QtLauncher.hxx"
30
31 namespace Ui
32 {
33 class SetupRootDialog;
34 }
35
36 class QNetworkAccessManager;
37
38 class SetupRootDialog : public QDialog
39 {
40 Q_OBJECT
41 public:
42
43 ~SetupRootDialog();
44
45 static bool runDialog(flightgear::SetupRootReason r);
46
47 static bool runUpdateDialog(flightgear::SetupRootReason r);
48
49 static flightgear::SetupRootResult restoreUserSelectedRoot(SGPath& path);
50
51 static void askRootOnNextLaunch();
52
53 static QString rootPathKey();
54 private slots:
55
56 void onBrowse();
57
58 void onDownload();
59 void onUpdate();
60 void onSelectDownloadDir();
61 void onUseDefaultDownloadDir();
62 void updatePromptText();
63 private:
64 enum PromptState {
65 DefaultPathCheckFailed,
66 ExplicitPathCheckFailed,
67 VersionCheckFailed,
68 NeedToUpdateDownloadedData,
69 ManualChoiceRequested,
70 ChoseInvalidLocation,
71 ChoseInvalidVersion,
72 ChoseInvalidArchive,
73 DownloadingExtractingArchive,
74 UpdatingViaTerrasync,
75 DownloadFailed,
76 ChoseInvalidDownloadLocation
77 };
78
79 SetupRootDialog(PromptState prompt, const SGPath&);
80
81 bool locationIsWritable(QString path);
82
83 static bool runDialog(PromptState prompt, const SGPath& checkedPath);
84
85 static bool validatePath(QString path);
86 static bool validateVersion(QString path);
87
88 static bool defaultRootAcceptable();
89 static bool downloadedDataAcceptable();
90 static bool downloadedDataExistsButStale();
91
92 void startSharedDataDownload();
93
94 PromptState m_promptState;
95 QScopedPointer<Ui::SetupRootDialog> m_ui;
96 QString m_browsedPath;
97 SGPath m_checkedPath;
98 QString m_lastErrorMessage;
99 QNetworkAccessManager* m_networkManager;
100 QString m_archiveName;
101 };