1 // QtLauncher_private.hxx - GUI launcher dialog using Qt5
3 // Written by James Turner, started October 2015.
5 // Copyright (C) 2015 James Turner <zakalawe@mac.com>
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.
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.
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.
21 #ifndef FG_QTLAUNCHER_PRIVATE_HXX
22 #define FG_QTLAUNCHER_PRIVATE_HXX
25 #include <QScopedPointer>
26 #include <QStringList>
27 #include <QModelIndex>
31 #include <simgear/package/Package.hxx>
32 #include <simgear/package/Catalog.hxx>
40 class AircraftProxyModel;
41 class AircraftItemModel;
43 class CatalogListModel;
45 class QtLauncher : public QDialog
50 virtual ~QtLauncher();
54 void setSceneryPaths();
56 static void restartTheApp(QStringList fgArgs);
58 virtual void closeEvent(QCloseEvent *event);
59 virtual void reject();
62 // run is used when the launcher is invoked before the main app is
66 // apply is used in-app, where we must set properties and trigger
67 // a reset; setting command line options won't help us.
73 void onAircraftSelected(const QModelIndex& index);
74 void onRequestPackageInstall(const QModelIndex& index);
75 void onCancelDownload(const QModelIndex& index);
77 void onPopupAircraftHistory();
79 void onEditRatingsFilter();
81 void updateSettingsSummary();
84 void onRembrandtToggled(bool b);
85 void onToggleTerrasync(bool enabled);
87 void onSubsytemIdleTimeout();
89 void onAircraftInstalledCompleted(QModelIndex index);
90 void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
92 void onShowInstalledAircraftToggled(bool b);
94 void maybeRestoreAircraftSelection();
96 void onRestoreDefaults();
98 void onDownloadDirChanged();
102 * Check if the passed index is the selected aircraft, and if so, refresh
103 * the associated UI data
105 void maybeUpdateSelectedAircraft(QModelIndex index);
106 void updateSelectedAircraft();
108 void restoreSettings();
111 QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
112 QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
114 void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
116 simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
118 void checkOfficialCatalogMessage();
119 void onOfficialCatalogMessageLink(QUrl link);
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();
126 QScopedPointer<Ui::Launcher> m_ui;
127 AircraftProxyModel* m_aircraftProxy;
128 AircraftItemModel* m_aircraftModel;
130 QUrl m_selectedAircraft;
131 QList<QUrl> m_recentAircraft;
132 QTimer* m_subsystemIdleTimer;
135 int m_ratingFilters[4];
138 #endif // of FG_QTLAUNCHER_PRIVATE_HXX