]> git.mxchange.org Git - flightgear.git/blob - src/GUI/QtLauncher_private.hxx
7eb6b38546cc31296efacdb25e4f6e9f020dc268
[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 onLocationChanged();
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 updateLocationDescription();
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 setLocationOptions();
103     void setBaseLocation(FGPositionedRef ref);
104
105     /**
106      * Check if the passed index is the selected aircraft, and if so, refresh
107      * the associated UI data
108      */
109     void maybeUpdateSelectedAircraft(QModelIndex index);
110     void updateSelectedAircraft();
111
112     void restoreSettings();
113     void saveSettings();
114
115     QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
116     QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
117
118     void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
119
120     simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
121
122     QScopedPointer<Ui::Launcher> m_ui;
123     AirportSearchModel* m_airportsModel;
124     AircraftProxyModel* m_aircraftProxy;
125     AircraftItemModel* m_aircraftModel;
126     FGPositionedRef m_location;
127
128     QUrl m_selectedAircraft;
129     QList<QUrl> m_recentAircraft;
130     QVector<PositionedID> m_recentAirports;
131     QTimer* m_subsystemIdleTimer;
132     bool m_inAppMode;
133
134     int m_ratingFilters[4];
135 };
136
137 #endif // of FG_QTLAUNCHER_PRIVATE_HXX