1
0
Fork 0
flightgear/src/GUI/LauncherMainWindow.hxx

169 lines
4.5 KiB
C++
Raw Normal View History

// 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.
#ifndef LAUNCHER_MAIN_WINDOW_HXX
#define LAUNCHER_MAIN_WINDOW_HXX
2015-10-16 01:05:17 +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;
2016-07-08 08:36:42 +00:00
class RemoteXMLRequest;
2015-10-16 01:05:17 +00:00
class LauncherMainWindow : public QMainWindow
2015-10-16 01:05:17 +00:00
{
Q_OBJECT
public:
LauncherMainWindow();
virtual ~LauncherMainWindow();
2015-10-16 01:05:17 +00:00
bool execInApp();
bool wasRejected();
protected:
virtual void closeEvent(QCloseEvent *event) override;
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 onAircraftSelected(const QModelIndex& index);
void onRequestPackageInstall(const QModelIndex& index);
void onRequestPackageUninstall(const QModelIndex& index);
2017-02-06 14:09:07 +00:00
void onShowPreviews(const QModelIndex& index);
2015-10-16 01:05:17 +00:00
void onCancelDownload(const QModelIndex& index);
void onPopupAircraftHistory();
void onPopupLocationHistory();
2015-10-16 01:05:17 +00:00
void onEditRatingsFilter();
void updateSettingsSummary();
void onRembrandtToggled(bool b);
void onToggleTerrasync(bool enabled);
void onSubsytemIdleTimeout();
void onAircraftInstalledCompleted(QModelIndex index);
void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
void onShowInstalledAircraftToggled(bool b);
void maybeRestoreAircraftSelection();
void onRestoreDefaults();
void onDownloadDirChanged();
2016-07-08 08:36:42 +00:00
void onRefreshMPServers();
2016-07-08 08:36:42 +00:00
void onMPServerActivated(int index);
2016-07-08 08:36:42 +00:00
void onUpdateAllAircraft();
void onPackagesNeedUpdate(bool yes);
2016-07-08 08:36:42 +00:00
2017-01-30 07:00:37 +00:00
void onClickToolboxButton();
void setSceneryPaths();
void onAircraftPathsChanged();
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();
QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
void checkOfficialCatalogMessage();
void onOfficialCatalogMessageLink(QUrl link);
void checkUpdateAircraft();
2016-07-08 08:36:42 +00:00
void onRefreshMPServersDone(simgear::HTTP::Request*);
void onRefreshMPServersFailed(simgear::HTTP::Request*);
int findMPServerPort(const std::string& host);
2016-07-08 08:36:42 +00:00
void restoreMPServerSelection();
2016-07-08 08:36:42 +00:00
// need to wait after a model reset before restoring selection and
// scrolling, to give the view time it seems.
void delayedAircraftModelReset();
void onRatingsFilterToggled();
void updateLocationHistory();
bool shouldShowOfficialCatalogMessage() const;
2015-10-16 01:05:17 +00:00
QScopedPointer<Ui::Launcher> m_ui;
AircraftProxyModel* m_aircraftProxy;
AircraftItemModel* m_aircraftModel;
QUrl m_selectedAircraft;
QList<QUrl> m_recentAircraft;
QTimer* m_subsystemIdleTimer;
bool m_inAppMode = false;
bool m_runInApp = false;
bool m_accepted = false;
2015-10-16 01:05:17 +00:00
int m_ratingFilters[4];
2016-07-08 08:36:42 +00:00
SGSharedPtr<RemoteXMLRequest> m_mpServerRequest;
bool m_doRestoreMPServer;
QVariantList m_recentLocations;
2015-10-16 01:05:17 +00:00
};
#endif // of LAUNCHER_MAIN_WINDOW_HXX