2017-02-20 00:19:13 +00:00
|
|
|
// LauncherMainWindow.hxx - GUI launcher dialog using Qt5
|
2015-10-16 01:05:17 +00:00
|
|
|
//
|
|
|
|
// Written by James Turner, started October 2015.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015 James Turner <zakalawe@mac.com>
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2017-02-20 00:19:13 +00:00
|
|
|
#ifndef LAUNCHER_MAIN_WINDOW_HXX
|
|
|
|
#define LAUNCHER_MAIN_WINDOW_HXX
|
2015-10-16 01:05:17 +00:00
|
|
|
|
2017-01-26 00:31:41 +00:00
|
|
|
#include <QMainWindow>
|
2015-10-16 01:05:17 +00:00
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QModelIndex>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
#include <simgear/package/Package.hxx>
|
|
|
|
#include <simgear/package/Catalog.hxx>
|
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class Launcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
class QModelIndex;
|
|
|
|
class AircraftProxyModel;
|
|
|
|
class AircraftItemModel;
|
|
|
|
class QCheckBox;
|
|
|
|
class CatalogListModel;
|
2017-02-21 11:01:06 +00:00
|
|
|
class QQmlEngine;
|
|
|
|
class LaunchConfig;
|
|
|
|
class ExtraSettingsSection;
|
|
|
|
class ViewCommandLinePage;
|
|
|
|
class MPServersModel;
|
2017-10-13 15:48:24 +00:00
|
|
|
class QQuickItem;
|
2018-02-11 21:28:25 +00:00
|
|
|
class QmlAircraftInfo;
|
2015-10-16 01:05:17 +00:00
|
|
|
|
2017-02-20 00:19:13 +00:00
|
|
|
class LauncherMainWindow : public QMainWindow
|
2015-10-16 01:05:17 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-06-22 09:45:47 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(bool showNoOfficialHanger READ showNoOfficialHanger NOTIFY showNoOfficialHangarChanged)
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
Q_PROPERTY(AircraftProxyModel* installedAircraftModel MEMBER m_installedAircraftModel CONSTANT)
|
|
|
|
Q_PROPERTY(AircraftProxyModel* browseAircraftModel MEMBER m_browseAircraftModel CONSTANT)
|
|
|
|
Q_PROPERTY(AircraftProxyModel* searchAircraftModel MEMBER m_aircraftSearchModel CONSTANT)
|
|
|
|
|
|
|
|
Q_PROPERTY(AircraftItemModel* baseAircraftModel MEMBER m_aircraftModel CONSTANT)
|
|
|
|
|
|
|
|
Q_PROPERTY(QUrl selectedAircraft READ selectedAircraft WRITE setSelectedAircraft NOTIFY selectedAircraftChanged)
|
2018-02-11 21:28:25 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QmlAircraftInfo* selectedAircraftInfo READ selectedAircraftInfo NOTIFY selectedAircraftChanged)
|
2015-10-16 01:05:17 +00:00
|
|
|
public:
|
2017-02-20 00:19:13 +00:00
|
|
|
LauncherMainWindow();
|
|
|
|
virtual ~LauncherMainWindow();
|
2015-10-16 01:05:17 +00:00
|
|
|
|
2017-01-26 00:31:41 +00:00
|
|
|
bool execInApp();
|
2016-01-10 22:38:01 +00:00
|
|
|
|
2017-01-26 00:31:41 +00:00
|
|
|
bool wasRejected();
|
2017-05-18 08:17:27 +00:00
|
|
|
|
|
|
|
Q_INVOKABLE bool validateMetarString(QString metar);
|
2017-06-22 09:45:47 +00:00
|
|
|
|
|
|
|
Q_INVOKABLE void requestInstallUpdate(QUrl aircraftUri);
|
|
|
|
|
|
|
|
Q_INVOKABLE void requestUninstall(QUrl aircraftUri);
|
|
|
|
|
|
|
|
Q_INVOKABLE void requestInstallCancel(QUrl aircraftUri);
|
2017-05-18 08:17:27 +00:00
|
|
|
|
2017-07-19 18:24:33 +00:00
|
|
|
Q_INVOKABLE void downloadDirChanged(QString path);
|
|
|
|
|
2017-06-22 09:45:47 +00:00
|
|
|
Q_INVOKABLE void requestUpdateAllAircraft();
|
|
|
|
|
|
|
|
bool showNoOfficialHanger() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void officialCatalogAction(QString s);
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
QUrl selectedAircraft() const;
|
|
|
|
|
|
|
|
// work around the fact, that this is not available on QQuickItem until 5.7
|
|
|
|
Q_INVOKABLE QPointF mapToGlobal(QQuickItem* item, const QPointF& pos) const;
|
2018-02-11 21:28:25 +00:00
|
|
|
|
|
|
|
QmlAircraftInfo* selectedAircraftInfo() const;
|
2017-10-13 15:48:24 +00:00
|
|
|
public slots:
|
|
|
|
void setSelectedAircraft(QUrl selectedAircraft);
|
|
|
|
|
2017-06-22 09:45:47 +00:00
|
|
|
signals:
|
|
|
|
void showNoOfficialHangarChanged();
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
void selectedAircraftChanged(QUrl selectedAircraft);
|
|
|
|
|
2016-02-24 19:50:37 +00:00
|
|
|
protected:
|
2017-01-26 00:31:41 +00:00
|
|
|
virtual void closeEvent(QCloseEvent *event) override;
|
2016-02-24 19:50:37 +00:00
|
|
|
|
2015-10-16 01:05:17 +00:00
|
|
|
private slots:
|
|
|
|
// run is used when the launcher is invoked before the main app is
|
|
|
|
// started
|
|
|
|
void onRun();
|
|
|
|
|
|
|
|
// apply is used in-app, where we must set properties and trigger
|
|
|
|
// a reset; setting command line options won't help us.
|
|
|
|
void onApply();
|
2016-07-08 08:36:42 +00:00
|
|
|
|
2015-10-16 01:05:17 +00:00
|
|
|
void onQuit();
|
|
|
|
|
|
|
|
void onPopupAircraftHistory();
|
2016-11-07 11:54:38 +00:00
|
|
|
void onPopupLocationHistory();
|
2015-10-16 01:05:17 +00:00
|
|
|
|
|
|
|
void updateSettingsSummary();
|
|
|
|
|
|
|
|
void onSubsytemIdleTimeout();
|
|
|
|
|
|
|
|
void onAircraftInstalledCompleted(QModelIndex index);
|
|
|
|
void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
|
2016-01-10 18:56:46 +00:00
|
|
|
|
2016-04-08 09:26:19 +00:00
|
|
|
void onRestoreDefaults();
|
2017-02-21 11:01:06 +00:00
|
|
|
void onViewCommandLine();
|
2016-04-08 09:26:19 +00:00
|
|
|
|
2017-01-30 07:00:37 +00:00
|
|
|
void onClickToolboxButton();
|
2017-02-20 00:19:13 +00:00
|
|
|
|
|
|
|
void setSceneryPaths();
|
2017-02-22 17:09:13 +00:00
|
|
|
void onAircraftPathsChanged();
|
2017-02-21 11:01:06 +00:00
|
|
|
void onChangeDataDir();
|
2017-04-08 02:21:51 +00:00
|
|
|
void onSettingsSearchChanged();
|
2015-10-16 01:05:17 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the passed index is the selected aircraft, and if so, refresh
|
|
|
|
* the associated UI data
|
|
|
|
*/
|
|
|
|
void maybeUpdateSelectedAircraft(QModelIndex index);
|
|
|
|
void updateSelectedAircraft();
|
|
|
|
|
|
|
|
void restoreSettings();
|
|
|
|
void saveSettings();
|
|
|
|
|
|
|
|
simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
|
|
|
|
|
2016-01-10 19:47:57 +00:00
|
|
|
// need to wait after a model reset before restoring selection and
|
|
|
|
// scrolling, to give the view time it seems.
|
|
|
|
void delayedAircraftModelReset();
|
|
|
|
|
2016-11-07 11:54:38 +00:00
|
|
|
void updateLocationHistory();
|
2016-11-07 19:49:33 +00:00
|
|
|
bool shouldShowOfficialCatalogMessage() const;
|
2016-11-07 11:54:38 +00:00
|
|
|
|
2017-02-21 11:01:06 +00:00
|
|
|
void buildSettingsSections();
|
|
|
|
void buildEnvironmentSections();
|
|
|
|
void collectAircraftArgs();
|
|
|
|
void initQML();
|
|
|
|
|
2018-02-11 21:28:25 +00:00
|
|
|
std::string selectStateAutomatically();
|
|
|
|
|
2015-10-16 01:05:17 +00:00
|
|
|
QScopedPointer<Ui::Launcher> m_ui;
|
2017-10-13 15:48:24 +00:00
|
|
|
AircraftProxyModel* m_installedAircraftModel;
|
2015-10-16 01:05:17 +00:00
|
|
|
AircraftItemModel* m_aircraftModel;
|
2017-10-13 15:48:24 +00:00
|
|
|
AircraftProxyModel* m_aircraftSearchModel;
|
|
|
|
AircraftProxyModel* m_browseAircraftModel;
|
2017-02-21 11:01:06 +00:00
|
|
|
MPServersModel* m_serversModel = nullptr;
|
2015-10-16 01:05:17 +00:00
|
|
|
|
|
|
|
QUrl m_selectedAircraft;
|
|
|
|
QList<QUrl> m_recentAircraft;
|
|
|
|
QTimer* m_subsystemIdleTimer;
|
2017-01-26 00:31:41 +00:00
|
|
|
bool m_inAppMode = false;
|
|
|
|
bool m_runInApp = false;
|
|
|
|
bool m_accepted = false;
|
2017-02-21 11:01:06 +00:00
|
|
|
int m_ratingFilters[4] = {3, 3, 3, 3};
|
2016-11-07 11:54:38 +00:00
|
|
|
QVariantList m_recentLocations;
|
2017-02-21 11:01:06 +00:00
|
|
|
QQmlEngine* m_qmlEngine = nullptr;
|
|
|
|
LaunchConfig* m_config = nullptr;
|
|
|
|
ExtraSettingsSection* m_extraSettings = nullptr;
|
|
|
|
ViewCommandLinePage* m_viewCommandLinePage = nullptr;
|
2018-02-11 21:28:25 +00:00
|
|
|
QmlAircraftInfo* m_selectedAircraftInfo = nullptr;
|
2015-10-16 01:05:17 +00:00
|
|
|
};
|
|
|
|
|
2017-02-20 00:19:13 +00:00
|
|
|
#endif // of LAUNCHER_MAIN_WINDOW_HXX
|