]> git.mxchange.org Git - flightgear.git/blob - src/GUI/QtLauncher_private.hxx
Work on the launcher
[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
32 #include <Airports/airport.hxx>
33 #include <simgear/package/Package.hxx>
34 #include <simgear/package/Catalog.hxx>
35
36 namespace Ui
37 {
38     class Launcher;
39 }
40
41 class AirportSearchModel;
42 class QModelIndex;
43 class AircraftProxyModel;
44 class AircraftItemModel;
45 class QCheckBox;
46 class CatalogListModel;
47
48 class QtLauncher : public QDialog
49 {
50     Q_OBJECT
51 public:
52     QtLauncher();
53     virtual ~QtLauncher();
54
55     void setInAppMode();
56 private slots:
57     // run is used when the launcher is invoked before the main app is
58     // started
59     void onRun();
60
61     // apply is used in-app, where we must set properties and trigger
62     // a reset; setting command line options won't help us.
63     void onApply();
64     
65     void onQuit();
66
67     void onSearchAirports();
68
69     void onAirportChanged();
70
71     void onAirportChoiceSelected(const QModelIndex& index);
72     void onAircraftSelected(const QModelIndex& index);
73     void onRequestPackageInstall(const QModelIndex& index);
74     void onCancelDownload(const QModelIndex& index);
75
76     void onPopupAirportHistory();
77     void onPopupAircraftHistory();
78
79     void onEditRatingsFilter();
80
81     void updateAirportDescription();
82     void updateSettingsSummary();
83
84     void onAirportSearchComplete();
85
86     void onRembrandtToggled(bool b);
87     void onToggleTerrasync(bool enabled);
88
89     void onSubsytemIdleTimeout();
90
91     void onEditPaths();
92
93     void onAirportDiagramClicked(FGRunwayRef rwy);
94     void onOffsetBearingTrueChanged(bool on);
95
96     void onOffsetDataChanged();
97     void onOffsetRadioToggled(bool on);
98
99     void onAircraftInstalledCompleted(QModelIndex index);
100     void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
101 private:
102     void setAirport(FGAirportRef ref);
103
104     /**
105      * Check if the passed index is the selected aircraft, and if so, refresh
106      * the associated UI data
107      */
108     void maybeUpdateSelectedAircraft(QModelIndex index);
109     void updateSelectedAircraft();
110
111     void restoreSettings();
112     void saveSettings();
113
114     QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
115     QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
116
117     void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
118
119     simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
120
121     QScopedPointer<Ui::Launcher> m_ui;
122     AirportSearchModel* m_airportsModel;
123     AircraftProxyModel* m_aircraftProxy;
124     AircraftItemModel* m_aircraftModel;
125     FGAirportRef m_selectedAirport;
126
127     QUrl m_selectedAircraft;
128     QList<QUrl> m_recentAircraft;
129     QStringList m_recentAirports;
130     QTimer* m_subsystemIdleTimer;
131     bool m_inAppMode;
132
133     int m_ratingFilters[4];
134 };
135
136 #endif // of FG_QTLAUNCHER_PRIVATE_HXX