]> git.mxchange.org Git - flightgear.git/blob - src/GUI/SetupRootDialog.hxx
Code cleanups, code updates and fix at least on (possible) devide-by-zero
[flightgear.git] / src / GUI / SetupRootDialog.hxx
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 <zakalawe@mac.com>
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 namespace Ui
28 {
29     class SetupRootDialog;
30 }
31
32 class SetupRootDialog : public QDialog
33 {
34     Q_OBJECT
35 public:
36
37     ~SetupRootDialog();
38
39     static bool runDialog(bool usingDefaultRoot);
40
41     static std::string restoreUserSelectedRoot();
42 private slots:
43
44     void onBrowse();
45
46     void onDownload();
47
48     void onUseDefaults();
49
50     void updatePromptText();
51 private:
52     enum PromptState
53     {
54         DefaultPathCheckFailed,
55         ExplicitPathCheckFailed,
56         VersionCheckFailed,
57         ManualChoiceRequested,
58         ChoseInvalidLocation,
59         ChoseInvalidVersion
60     };
61     
62     SetupRootDialog(PromptState prompt);
63
64     static bool runDialog(PromptState prompt);
65
66     static bool validatePath(QString path);
67     static bool validateVersion(QString path);
68
69     static bool defaultRootAcceptable();
70
71
72     PromptState m_promptState;
73     QScopedPointer<Ui::SetupRootDialog> m_ui;
74     QString m_browsedPath;
75 };