]> git.mxchange.org Git - flightgear.git/blob - src/GUI/QtLauncher_private.hxx
Launcher: Maintain aircraft selection better
[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 private slots:
54     // run is used when the launcher is invoked before the main app is
55     // started
56     void onRun();
57
58     // apply is used in-app, where we must set properties and trigger
59     // a reset; setting command line options won't help us.
60     void onApply();
61     
62     void onQuit();
63
64
65     void onAircraftSelected(const QModelIndex& index);
66     void onRequestPackageInstall(const QModelIndex& index);
67     void onCancelDownload(const QModelIndex& index);
68
69     void onPopupAircraftHistory();
70
71     void onEditRatingsFilter();
72
73     void updateSettingsSummary();
74
75
76     void onRembrandtToggled(bool b);
77     void onToggleTerrasync(bool enabled);
78
79     void onSubsytemIdleTimeout();
80
81     void onEditPaths();
82
83
84     void onAircraftInstalledCompleted(QModelIndex index);
85     void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
86
87     void onShowInstalledAircraftToggled(bool b);
88 private:
89
90     /**
91      * Check if the passed index is the selected aircraft, and if so, refresh
92      * the associated UI data
93      */
94     void maybeUpdateSelectedAircraft(QModelIndex index);
95     void updateSelectedAircraft();
96
97     void restoreSettings();
98     void saveSettings();
99
100     QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
101     QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
102
103     void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
104
105     simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
106
107     void maybeRestoreAircraftSelection();
108     // need to wait after a model reset before restoring selection and
109     // scrolling, to give the view time it seems.
110     void delayedAircraftModelReset();
111     void onRatingsFilterToggled();
112
113     QScopedPointer<Ui::Launcher> m_ui;
114     AircraftProxyModel* m_aircraftProxy;
115     AircraftItemModel* m_aircraftModel;
116
117     QUrl m_selectedAircraft;
118     QList<QUrl> m_recentAircraft;
119     QTimer* m_subsystemIdleTimer;
120     bool m_inAppMode;
121
122     int m_ratingFilters[4];
123 };
124
125 #endif // of FG_QTLAUNCHER_PRIVATE_HXX