]> git.mxchange.org Git - flightgear.git/blob - src/GUI/QtLauncher_private.hxx
Code cleanups, code updates and fix at least on (possible) devide-by-zero
[flightgear.git] / src / GUI / QtLauncher_private.hxx
1 // QtLauncher_private.hxx - GUI launcher dialog using Qt5
2 //
3 // Written by James Turner, started October 2015.
4 //
5 // Copyright (C) 2015 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 #ifndef FG_QTLAUNCHER_PRIVATE_HXX
22 #define FG_QTLAUNCHER_PRIVATE_HXX
23
24 #include <QDialog>
25 #include <QScopedPointer>
26 #include <QStringList>
27 #include <QModelIndex>
28 #include <QTimer>
29 #include <QUrl>
30
31 #include <simgear/package/Package.hxx>
32 #include <simgear/package/Catalog.hxx>
33
34 namespace Ui
35 {
36     class Launcher;
37 }
38
39 class QModelIndex;
40 class AircraftProxyModel;
41 class AircraftItemModel;
42 class QCheckBox;
43 class CatalogListModel;
44
45 class QtLauncher : public QDialog
46 {
47     Q_OBJECT
48 public:
49     QtLauncher();
50     virtual ~QtLauncher();
51
52     void setInAppMode();
53
54     void setSceneryPaths();
55
56     static void restartTheApp(QStringList fgArgs);
57 protected:
58     virtual void closeEvent(QCloseEvent *event);
59     virtual void reject();
60
61 private slots:
62     // run is used when the launcher is invoked before the main app is
63     // started
64     void onRun();
65
66     // apply is used in-app, where we must set properties and trigger
67     // a reset; setting command line options won't help us.
68     void onApply();
69     
70     void onQuit();
71
72
73     void onAircraftSelected(const QModelIndex& index);
74     void onRequestPackageInstall(const QModelIndex& index);
75     void onCancelDownload(const QModelIndex& index);
76
77     void onPopupAircraftHistory();
78
79     void onEditRatingsFilter();
80
81     void updateSettingsSummary();
82
83
84     void onRembrandtToggled(bool b);
85     void onToggleTerrasync(bool enabled);
86
87     void onSubsytemIdleTimeout();
88
89     void onAircraftInstalledCompleted(QModelIndex index);
90     void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
91
92     void onShowInstalledAircraftToggled(bool b);
93
94     void maybeRestoreAircraftSelection();
95
96     void onRestoreDefaults();
97
98     void onDownloadDirChanged();
99 private:
100
101     /**
102      * Check if the passed index is the selected aircraft, and if so, refresh
103      * the associated UI data
104      */
105     void maybeUpdateSelectedAircraft(QModelIndex index);
106     void updateSelectedAircraft();
107
108     void restoreSettings();
109     void saveSettings();
110
111     QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
112     QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
113
114     void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
115
116     simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
117
118     void checkOfficialCatalogMessage();
119     void onOfficialCatalogMessageLink(QUrl link);
120
121     // need to wait after a model reset before restoring selection and
122     // scrolling, to give the view time it seems.
123     void delayedAircraftModelReset();
124     void onRatingsFilterToggled();
125
126     QScopedPointer<Ui::Launcher> m_ui;
127     AircraftProxyModel* m_aircraftProxy;
128     AircraftItemModel* m_aircraftModel;
129
130     QUrl m_selectedAircraft;
131     QList<QUrl> m_recentAircraft;
132     QTimer* m_subsystemIdleTimer;
133     bool m_inAppMode;
134
135     int m_ratingFilters[4];
136 };
137
138 #endif // of FG_QTLAUNCHER_PRIVATE_HXX