AircraftItemModel* m_model;
};
-AircraftItemModel::AircraftItemModel(QObject* pr, simgear::pkg::RootRef& rootRef) :
+AircraftItemModel::AircraftItemModel(QObject* pr, const simgear::pkg::RootRef& rootRef) :
QAbstractListModel(pr),
m_scanThread(NULL),
m_packageRoot(rootRef)
{
Q_OBJECT
public:
- AircraftItemModel(QObject* pr, simgear::pkg::RootRef& root);
+ AircraftItemModel(QObject* pr, const simgear::pkg::RootRef& root);
~AircraftItemModel();
include(FlightGearComponent)
set(SOURCES
- AirportList.cxx
- CanvasWidget.cxx
- MapWidget.cxx
- WaypointList.cxx
- dialog.cxx
- FGPUIDialog.cxx
- fonts.cxx
- gui.cxx
- gui_funcs.cxx
- layout-props.cxx
- layout.cxx
- menubar.cxx
- FGPUIMenuBar.cxx
- new_gui.cxx
- property_list.cxx
- FGFontCache.cxx
- FGColor.cxx
+ AirportList.cxx
+ CanvasWidget.cxx
+ MapWidget.cxx
+ WaypointList.cxx
+ dialog.cxx
+ FGPUIDialog.cxx
+ fonts.cxx
+ gui.cxx
+ gui_funcs.cxx
+ layout-props.cxx
+ layout.cxx
+ menubar.cxx
+ FGPUIMenuBar.cxx
+ new_gui.cxx
+ property_list.cxx
+ FGFontCache.cxx
+ FGColor.cxx
FileDialog.cxx
PUIFileDialog.cxx
MouseCursor.cxx
MessageBox.cxx
- )
+ )
set(HEADERS
- AirportList.hxx
- CanvasWidget.hxx
- MapWidget.hxx
- WaypointList.hxx
- dialog.hxx
- FGPUIDialog.hxx
- gui.h
- layout.hxx
- menubar.hxx
- FGPUIMenuBar.hxx
- new_gui.hxx
- property_list.hxx
- FGFontCache.hxx
- FGColor.hxx
+ AirportList.hxx
+ CanvasWidget.hxx
+ MapWidget.hxx
+ WaypointList.hxx
+ dialog.hxx
+ FGPUIDialog.hxx
+ gui.h
+ layout.hxx
+ menubar.hxx
+ FGPUIMenuBar.hxx
+ new_gui.hxx
+ property_list.hxx
+ FGFontCache.hxx
+ FGColor.hxx
FileDialog.hxx
PUIFileDialog.hxx
MouseCursor.hxx
MessageBox.hxx
- )
+ )
if(WIN32)
- list(APPEND HEADERS WindowsMouseCursor.hxx
- FGWindowsMenuBar.hxx
- WindowsFileDialog.hxx)
- list(APPEND SOURCES WindowsMouseCursor.cxx
- FGWindowsMenuBar.cxx
- WindowsFileDialog.cxx)
+ list(APPEND HEADERS WindowsMouseCursor.hxx
+ FGWindowsMenuBar.hxx
+ WindowsFileDialog.hxx)
+ list(APPEND SOURCES WindowsMouseCursor.cxx
+ FGWindowsMenuBar.cxx
+ WindowsFileDialog.cxx)
endif()
if (APPLE)
if (HAVE_QT)
- qt5_wrap_ui(uic_sources Launcher.ui
+ qt5_wrap_ui(uic_sources Launcher.ui
EditRatingsFilterDialog.ui
SetupRootDialog.ui
AddCatalogDialog.ui
add_library(fglauncher QtLauncher.cxx
QtLauncher.hxx
+ QtLauncher_private.hxx
AirportDiagram.cxx
AirportDiagram.hxx
EditRatingsFilterDialog.cxx
<rect>
<x>0</x>
<y>0</y>
- <width>700</width>
- <height>700</height>
+ <width>800</width>
+ <height>800</height>
</rect>
</property>
<property name="windowTitle">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>2</number>
+ <number>0</number>
</property>
- <widget class="QWidget" name="tab">
+ <widget class="QWidget" name="aircraftTab">
<attribute name="title">
<string>Aircraft</string>
</attribute>
</item>
</layout>
</widget>
- <widget class="QWidget" name="tab_2">
+ <widget class="QWidget" name="locationTab">
<attribute name="title">
<string>Location</string>
</attribute>
<item>
<widget class="QLineEdit" name="airportEdit">
<property name="placeholderText">
- <string>Enter an ICAO code or search by name</string>
+ <string>Enter an ICAO code, navaid or search by name</string>
</property>
</widget>
</item>
<number>0</number>
</property>
<widget class="QWidget" name="diagramPage">
- <layout class="QGridLayout" name="gridLayout">
+ <layout class="QGridLayout" name="gridLayout" columnstretch="0,1,1,0">
<property name="leftMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
- <item row="0" column="0" colspan="2">
- <widget class="AirportDiagram" name="airportDiagram" native="true">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <item row="3" column="0">
+ <widget class="QRadioButton" name="parkingRadio">
+ <property name="text">
+ <string>Parking:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="onFinalCheckbox">
+ <property name="text">
+ <string>On 10-mile final</string>
</property>
</widget>
</item>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="6" column="2">
+ <widget class="QSpinBox" name="offsetBearingSpinbox">
+ <property name="wrapping">
+ <bool>true</bool>
+ </property>
+ <property name="maximum">
+ <number>359</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="3">
+ <widget class="QComboBox" name="parkingCombo"/>
+ </item>
+ <item row="1" column="1" colspan="3">
<widget class="QComboBox" name="runwayCombo"/>
</item>
- <item row="2" column="0" rowspan="2">
- <widget class="QRadioButton" name="parkingRadio">
+ <item row="6" column="3">
+ <widget class="QCheckBox" name="trueBearing">
<property name="text">
- <string>Parking:</string>
+ <string>True</string>
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="onFinalCheckbox">
+ <item row="6" column="1">
+ <widget class="QLabel" name="offsetBearingLabel">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
<property name="text">
- <string>On 10-mile final</string>
+ <string>Bearing:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
- <item row="3" column="1">
- <widget class="QComboBox" name="parkingCombo"/>
+ <item row="5" column="0">
+ <widget class="QRadioButton" name="offsetRadioButton">
+ <property name="text">
+ <string>Bearing and distance offset:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="offsetDistanceLabel">
+ <property name="text">
+ <string>Distance:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QDoubleSpinBox" name="offsetNmSpinbox">
+ <property name="suffix">
+ <string>nm</string>
+ </property>
+ <property name="decimals">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <double>10000.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>10.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="4">
+ <widget class="AirportDiagram" name="airportDiagram" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
- <widget class="QWidget" name="tab_3">
+ <widget class="QWidget" name="settingsTab">
<attribute name="title">
<string>Settings</string>
</attribute>
<property name="text">
<string>Enable deferred rendering (Rembrandt)</string>
</property>
+ <property name="startupOnly" stdset="0">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="4" column="1">
<property name="text">
<string>Start full-screen</string>
</property>
+ <property name="startupOnly" stdset="0">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="4" column="0">
<property name="text">
<string>Enable Multi-sample anti-aliasing</string>
</property>
+ <property name="startupOnly" stdset="0">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="5" column="0">
<property name="text">
<string>Start paused</string>
</property>
+ <property name="startupOnly" stdset="0">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<property name="title">
<string>Additional options</string>
</property>
+ <property name="startupOnly" stdset="0">
+ <bool>true</bool>
+ </property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QPlainTextEdit" name="commandLineArgs"/>
<property name="text">
<string>Configure add-on aircraft and scenery</string>
</property>
+ <property name="startupOnly" stdset="0">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "QtLauncher.hxx"
+#include "QtLauncher_private.hxx"
// Qt
#include <QProgressDialog>
#include <QMessageBox>
#include <QDateTime>
#include <QApplication>
+#include <QSpinBox>
+#include <QDoubleSpinBox>
// Simgear
#include <simgear/timing/timestamp.hxx>
#include <Navaids/NavDataCache.hxx>
#include <Airports/airport.hxx>
#include <Airports/dynamics.hxx> // for parking
+#include <Navaids/navrecord.hxx>
+
#include <Main/options.hxx>
#include <Main/fg_init.hxx>
#include <Viewer/WindowBuilder.hxx>
// sleep to give the rebuild thread more time
SGTimeStamp::sleepForMSec(50);
phase = cache->rebuild();
-
+
switch (phase) {
case NavDataCache::REBUILD_AIRPORTS:
rebuildProgress.setLabelText(QT_TR_NOOP("Loading airport data"));
std::string term(t.toUpper().toStdString());
// try ICAO lookup first
FGAirportRef ref = FGAirport::findByIdent(term);
+
if (ref) {
m_ids.push_back(ref->guid());
m_airports.push_back(ref);
- } else {
- m_search.reset(new NavDataCache::ThreadedAirportSearch(term));
- QTimer::singleShot(100, this, SLOT(onSearchResultsPoll()));
- m_searchActive = true;
+ endResetModel();
+ return;
}
- endResetModel();
+ m_search.reset(new NavDataCache::ThreadedGUISearch(term));
+ QTimer::singleShot(100, this, SLOT(onSearchResultsPoll()));
+ m_searchActive = true;
}
bool isSearchActive() const
{
if (!index.isValid())
return QVariant();
-
+
FGAirportRef apt = m_airports[index.row()];
if (!apt.valid()) {
apt = FGPositioned::loadById<FGAirport>(m_ids[index.row()]);
void onSearchResultsPoll()
{
PositionedIDVec newIds = m_search->results();
-
+
beginInsertRows(QModelIndex(), m_ids.size(), newIds.size() - 1);
for (unsigned int i=m_ids.size(); i < newIds.size(); ++i) {
m_ids.push_back(newIds[i]);
PositionedIDVec m_ids;
mutable std::vector<FGAirportRef> m_airports;
bool m_searchActive;
- QScopedPointer<NavDataCache::ThreadedAirportSearch> m_search;
+ QScopedPointer<NavDataCache::ThreadedGUISearch> m_search;
};
class AircraftProxyModel : public QSortFilterProxyModel
int m_ratings[4];
};
+static void initQtResources()
+{
+ Q_INIT_RESOURCE(resources);
+}
+
+namespace flightgear
+{
+
+void initApp(int& argc, char** argv)
+{
+ static bool qtInitDone = false;
+ if (!qtInitDone) {
+ qtInitDone = true;
+
+ QApplication* app = new QApplication(argc, argv);
+ app->setOrganizationName("FlightGear");
+ app->setApplicationName("FlightGear");
+ app->setOrganizationDomain("flightgear.org");
+
+ // avoid double Apple menu and other weirdness if both Qt and OSG
+ // try to initialise various Cocoa structures.
+ flightgear::WindowBuilder::setPoseAsStandaloneApp(false);
+
+ Qt::KeyboardModifiers mods = app->queryKeyboardModifiers();
+ if (mods & Qt::AltModifier) {
+ qWarning() << "Alt pressed during launch";
+
+ // wipe out our settings
+ QSettings settings;
+ settings.clear();
+
+
+ Options::sharedInstance()->addOption("restore-defaults", "");
+ }
+ }
+}
+
+bool runLauncherDialog()
+{
+ sglog().setLogLevels( SG_ALL, SG_INFO );
+
+
+ initQtResources(); // can't be called inside a namespaceb
+
+ // startup the nav-cache now. This pre-empts normal startup of
+ // the cache, but no harm done. (Providing scenery paths are consistent)
+
+ initNavCache();
+
+
+ fgInitPackageRoot();
+
+ // startup the HTTP system now since packages needs it
+ FGHTTPClient* http = new FGHTTPClient;
+ globals->add_subsystem("http", http);
+ // we guard against re-init in the global phase; bind and postinit
+ // will happen as normal
+ http->init();
+
+
+ // setup scenery paths now, especially TerraSync path for airport
+ // parking locations (after they're downloaded)
+
+ QtLauncher dlg;
+ dlg.exec();
+ if (dlg.result() != QDialog::Accepted) {
+ return false;
+ }
+
+ return true;
+}
+
+bool runInAppLauncherDialog()
+{
+ QtLauncher dlg;
+ dlg.setInAppMode();
+ dlg.exec();
+ if (dlg.result() != QDialog::Accepted) {
+ return false;
+ }
+
+ return true;
+}
+
+} // of namespace flightgear
+
QtLauncher::QtLauncher() :
QDialog(),
- m_ui(NULL)
+ m_ui(NULL),
+ m_subsystemIdleTimer(NULL),
+ m_inAppMode(false)
{
m_ui.reset(new Ui::Launcher);
m_ui->setupUi(this);
connect(m_ui->onFinalCheckbox, SIGNAL(toggled(bool)),
this, SLOT(updateAirportDescription()));
-
+
connect(m_ui->airportDiagram, &AirportDiagram::clickedRunway,
this, &QtLauncher::onAirportDiagramClicked);
this, &QtLauncher::onToggleTerrasync);
updateSettingsSummary();
- fgInitPackageRoot();
- RootRef r(globals->packageRoot());
-
- FGHTTPClient* http = new FGHTTPClient;
- globals->add_subsystem("http", http);
-
- // we guard against re-init in the global phase; bind and postinit
- // will happen as normal
- http->init();
-
- m_aircraftModel = new AircraftItemModel(this, r);
+ m_aircraftModel = new AircraftItemModel(this, RootRef(globals->packageRoot()));
m_aircraftProxy->setSourceModel(m_aircraftModel);
m_aircraftProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
this, &QtLauncher::onAircraftInstalledCompleted);
connect(m_aircraftModel, &AircraftItemModel::aircraftInstallFailed,
this, &QtLauncher::onAircraftInstallFailed);
-
+
connect(m_ui->pathsButton, &QPushButton::clicked,
this, &QtLauncher::onEditPaths);
+
+ connect(m_ui->trueBearing, &QCheckBox::toggled, this, &QtLauncher::onOffsetBearingTrueChanged);
+ connect(m_ui->offsetRadioButton, &QRadioButton::toggled,
+ this, &QtLauncher::onOffsetRadioToggled);
+ connect(m_ui->trueBearing, &QCheckBox::toggled, this, &QtLauncher::onOffsetDataChanged);
+ connect(m_ui->offsetBearingSpinbox, SIGNAL(valueChanged(int)), this, SLOT(onOffsetDataChanged()));
+ connect(m_ui->offsetNmSpinbox, SIGNAL(valueChanged(double)),
+ this, SLOT(onOffsetDataChanged()));
+
restoreSettings();
QSettings settings;
QtLauncher::~QtLauncher()
{
-
+
+}
+
+void QtLauncher::setInAppMode()
+{
+ m_inAppMode = true;
+ m_ui->tabWidget->removeTab(2);
+ m_ui->runButton->setText(tr("Apply"));
+ m_ui->quitButton->setText(tr("Cancel"));
+
+ disconnect(m_ui->runButton, SIGNAL(clicked()), this, SLOT(onRun()));
+ connect(m_ui->runButton, SIGNAL(clicked()), this, SLOT(onApply()));
}
-void QtLauncher::initApp(int& argc, char** argv)
+bool QtLauncher::runLauncherDialog()
{
+ sglog().setLogLevels( SG_ALL, SG_INFO );
+ Q_INIT_RESOURCE(resources);
+
static bool qtInitDone = false;
static int s_argc;
if (!qtInitDone) {
QSettings settings;
settings.clear();
-
Options::sharedInstance()->addOption("restore-defaults", "");
}
}
-}
-
-bool QtLauncher::runLauncherDialog()
-{
- sglog().setLogLevels( SG_ALL, SG_INFO );
- Q_INIT_RESOURCE(resources);
- // startup the nav-cache now. This pre-empts normal startup of
+ // startup the nav-cache now. This preempts normal startup of
// the cache, but no harm done. (Providing scenery paths are consistent)
initNavCache();
if (dlg.result() != QDialog::Accepted) {
return false;
}
-
- return true;
}
void QtLauncher::restoreSettings()
} else {
qWarning() << "unsupported aircraft launch URL" << m_selectedAircraft;
}
-
+
// manage aircraft history
if (m_recentAircraft.contains(m_selectedAircraft))
m_recentAircraft.removeOne(m_selectedAircraft);
saveSettings();
}
+void QtLauncher::onApply()
+{
+ accept();
+
+ // aircraft
+ if (!m_selectedAircraft.isEmpty()) {
+ std::string aircraftPropValue,
+ aircraftDir;
+
+ if (m_selectedAircraft.isLocalFile()) {
+ QFileInfo setFileInfo(m_selectedAircraft.toLocalFile());
+ QString setFile = setFileInfo.fileName();
+ Q_ASSERT(setFile.endsWith("-set.xml"));
+ setFile.truncate(setFile.count() - 8); // drop the '-set.xml' portion
+ aircraftDir = setFileInfo.dir().absolutePath().toStdString();
+ aircraftPropValue = setFile.toStdString();
+ } else if (m_selectedAircraft.scheme() == "package") {
+ PackageRef pkg = packageForAircraftURI(m_selectedAircraft);
+ // no need to set aircraft-dir, handled by the corresponding code
+ // in fgInitAircraft
+ aircraftPropValue = pkg->qualifiedId();
+ } else {
+ qWarning() << "unsupported aircraft launch URL" << m_selectedAircraft;
+ }
+
+ // manage aircraft history
+ if (m_recentAircraft.contains(m_selectedAircraft))
+ m_recentAircraft.removeOne(m_selectedAircraft);
+ m_recentAircraft.prepend(m_selectedAircraft);
+ if (m_recentAircraft.size() > MAX_RECENT_AIRCRAFT)
+ m_recentAircraft.pop_back();
+
+ globals->get_props()->setStringValue("/sim/aircraft", aircraftPropValue);
+ globals->get_props()->setStringValue("/sim/aircraft-dir", aircraftDir);
+ }
+
+
+ saveSettings();
+}
+
void QtLauncher::onQuit()
{
reject();
}
}
+void QtLauncher::onOffsetRadioToggled(bool on)
+{
+ m_ui->offsetNmSpinbox->setEnabled(on);
+ m_ui->offsetBearingSpinbox->setEnabled(on);
+ m_ui->trueBearing->setEnabled(on);
+ m_ui->offsetBearingLabel->setEnabled(on);
+ m_ui->offsetDistanceLabel->setEnabled(on);
+}
+
void QtLauncher::onAirportDiagramClicked(FGRunwayRef rwy)
{
if (rwy) {
int rwyIndex = m_ui->runwayCombo->findText(QString::fromStdString(rwy->ident()));
m_ui->runwayCombo->setCurrentIndex(rwyIndex);
}
-
+
updateAirportDescription();
}
msg.addButton(QMessageBox::Cancel);
msg.addButton(tr("Change location"), QMessageBox::ActionRole);
int result = msg.exec();
-
+
if (result == QMessageBox::Cancel) {
m_ui->terrasyncCheck->setChecked(false);
return;
void QtLauncher::onAircraftInstallFailed(QModelIndex index, QString errorMessage)
{
qWarning() << Q_FUNC_INFO << index.data(AircraftURIRole) << errorMessage;
-
+
QMessageBox msg;
msg.setWindowTitle(tr("Aircraft installation failed"));
msg.setText(tr("An error occurred installing the aircraft %1: %2").
} else {
locationOnAirport = QString("on %1").arg(runwayName);
}
-
+
int runwayIndex = m_ui->runwayCombo->itemData(comboIndex).toInt();
FGRunwayRef rwy = (runwayIndex >= 0) ?
m_selectedAirport->getRunwayByIndex(runwayIndex) : FGRunwayRef();
setAirport(FGPositioned::loadById<FGAirport>(index.data(Qt::UserRole).toULongLong()));
}
+void QtLauncher::onOffsetBearingTrueChanged(bool on)
+{
+ m_ui->offsetBearingLabel->setText(on ? tr("True bearing:") :
+ tr("Magnetic bearing:"));
+}
+
void QtLauncher::onAircraftSelected(const QModelIndex& index)
{
m_selectedAircraft = index.data(AircraftURIRole).toUrl();
void QtLauncher::onCancelDownload(const QModelIndex& index)
{
QString pkg = index.data(AircraftPackageIdRole).toString();
- qDebug() << "cancel download of" << pkg;
simgear::pkg::PackageRef pref = globals->packageRoot()->getPackageById(pkg.toStdString());
simgear::pkg::InstallRef i = pref->existingInstall();
i->cancelDownload();
QPixmap pm = index.data(Qt::DecorationRole).value<QPixmap>();
m_ui->thumbnail->setPixmap(pm);
m_ui->aircraftDescription->setText(index.data(Qt::DisplayRole).toString());
-
+
int status = index.data(AircraftPackageStatusRole).toInt();
bool canRun = (status == PackageInstalled);
m_ui->runButton->setEnabled(canRun);
qWarning() << "invalid URL scheme:" << uri;
return simgear::pkg::PackageRef();
}
-
+
QString ident = uri.path();
return globals->packageRoot()->getPackageById(ident.toStdString());
}
-#include "QtLauncher.moc"
+void QtLauncher::onOffsetDataChanged()
+{
+ qDebug() << "implement me";
+}
+#include "QtLauncher.moc"
#ifndef FG_QTLAUNCHER_HXX
#define FG_QTLAUNCHER_HXX
-#include <QDialog>
-#include <QScopedPointer>
-#include <QStringList>
-#include <QModelIndex>
-#include <QTimer>
-#include <QUrl>
-
-
-#include <Airports/airport.hxx>
-#include <simgear/package/Package.hxx>
-#include <simgear/package/Catalog.hxx>
-
-namespace Ui
-{
- class Launcher;
-}
-
-class AirportSearchModel;
-class QModelIndex;
-class AircraftProxyModel;
-class AircraftItemModel;
-class QCheckBox;
-class CatalogListModel;
-
-class QtLauncher : public QDialog
+namespace flightgear
{
- Q_OBJECT
-public:
- QtLauncher();
- virtual ~QtLauncher();
-
- static void initApp(int& argc, char** argv);
-
- static bool runLauncherDialog();
-
-private slots:
- void onRun();
- void onQuit();
-
- void onSearchAirports();
-
- void onAirportChanged();
-
- void onAirportChoiceSelected(const QModelIndex& index);
- void onAircraftSelected(const QModelIndex& index);
- void onRequestPackageInstall(const QModelIndex& index);
- void onCancelDownload(const QModelIndex& index);
-
- void onPopupAirportHistory();
- void onPopupAircraftHistory();
+ void initApp(int& argc, char** argv);
- void onEditRatingsFilter();
+ bool runLauncherDialog();
- void updateAirportDescription();
- void updateSettingsSummary();
-
- void onAirportSearchComplete();
-
- void onRembrandtToggled(bool b);
- void onToggleTerrasync(bool enabled);
-
- void onSubsytemIdleTimeout();
-
- void onEditPaths();
-
- void onAirportDiagramClicked(FGRunwayRef rwy);
-
- void onAircraftInstalledCompleted(QModelIndex index);
- void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
-private:
- void setAirport(FGAirportRef ref);
-
- /**
- * 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;
-
- QScopedPointer<Ui::Launcher> m_ui;
- AirportSearchModel* m_airportsModel;
- AircraftProxyModel* m_aircraftProxy;
- AircraftItemModel* m_aircraftModel;
- FGAirportRef m_selectedAirport;
-
- QUrl m_selectedAircraft;
- QList<QUrl> m_recentAircraft;
- QStringList m_recentAirports;
- QTimer* m_subsystemIdleTimer;
-
- int m_ratingFilters[4];
-};
+ bool runInAppLauncherDialog();
+}
#endif // of FG_QTLAUNCHER_HXX
--- /dev/null
+// QtLauncher_private.hxx - GUI launcher dialog using Qt5
+//
+// 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 FG_QTLAUNCHER_PRIVATE_HXX
+#define FG_QTLAUNCHER_PRIVATE_HXX
+
+#include <QDialog>
+#include <QScopedPointer>
+#include <QStringList>
+#include <QModelIndex>
+#include <QTimer>
+#include <QUrl>
+
+
+#include <Airports/airport.hxx>
+#include <simgear/package/Package.hxx>
+#include <simgear/package/Catalog.hxx>
+
+namespace Ui
+{
+ class Launcher;
+}
+
+class AirportSearchModel;
+class QModelIndex;
+class AircraftProxyModel;
+class AircraftItemModel;
+class QCheckBox;
+class CatalogListModel;
+
+class QtLauncher : public QDialog
+{
+ Q_OBJECT
+public:
+ QtLauncher();
+ virtual ~QtLauncher();
+
+ void setInAppMode();
+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();
+
+ void onQuit();
+
+ void onSearchAirports();
+
+ void onAirportChanged();
+
+ void onAirportChoiceSelected(const QModelIndex& index);
+ void onAircraftSelected(const QModelIndex& index);
+ void onRequestPackageInstall(const QModelIndex& index);
+ void onCancelDownload(const QModelIndex& index);
+
+ void onPopupAirportHistory();
+ void onPopupAircraftHistory();
+
+ void onEditRatingsFilter();
+
+ void updateAirportDescription();
+ void updateSettingsSummary();
+
+ void onAirportSearchComplete();
+
+ void onRembrandtToggled(bool b);
+ void onToggleTerrasync(bool enabled);
+
+ void onSubsytemIdleTimeout();
+
+ void onEditPaths();
+
+ void onAirportDiagramClicked(FGRunwayRef rwy);
+ void onOffsetBearingTrueChanged(bool on);
+
+ void onOffsetDataChanged();
+ void onOffsetRadioToggled(bool on);
+
+ void onAircraftInstalledCompleted(QModelIndex index);
+ void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
+private:
+ void setAirport(FGAirportRef ref);
+
+ /**
+ * 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;
+
+ QScopedPointer<Ui::Launcher> m_ui;
+ AirportSearchModel* m_airportsModel;
+ AircraftProxyModel* m_aircraftProxy;
+ AircraftItemModel* m_aircraftModel;
+ FGAirportRef m_selectedAirport;
+
+ QUrl m_selectedAircraft;
+ QList<QUrl> m_recentAircraft;
+ QStringList m_recentAirports;
+ QTimer* m_subsystemIdleTimer;
+ bool m_inAppMode;
+
+ int m_ratingFilters[4];
+};
+
+#endif // of FG_QTLAUNCHER_PRIVATE_HXX
# include <google/profiler.h>
#endif
+#if defined(HAVE_QT)
+#include <GUI/QtLauncher.hxx>
+#endif
+
using std::string;
using std::ifstream;
using std::ofstream;
return openBrowser(path);
}
+static bool
+do_open_launcher(const SGPropertyNode *)
+{
+#if defined(HAVE_QT)
+ bool ok = flightgear::runInAppLauncherDialog();
+ if (ok) {
+ // start a full reset
+ fgResetIdleState();
+ }
+ return ok;
+#else
+ return false;
+#endif
+}
+
/**
* Apply a value in the active XML-configured dialog.
*
{ "presets-commit", do_presets_commit },
{ "log-level", do_log_level },
{ "replay", do_replay },
+ { "open-launcher", do_open_launcher },
/*
{ "decrease-visibility", do_decrease_visibility },
{ "increase-visibility", do_increase_visibility },
showLauncher |= (::getenv("FG_LAUNCHER") != 0);
if (showLauncher) {
- QtLauncher::initApp(argc, argv);
- if (!QtLauncher::runLauncherDialog()) {
+ flightgear::initApp(argc, argv);
+ if (!flightgear::runLauncherDialog()) {
return EXIT_SUCCESS;
}
}
#if defined(HAVE_QT)
if (base_version != required_version) {
- QtLauncher::initApp(argc, argv);
+ flightgear::initApp(argc, argv);
if (SetupRootDialog::restoreUserSelectedRoot()) {
SG_LOG(SG_GENERAL, SG_INFO, "restored user selected fg_root = " << globals->get_fg_root() );
return;
/////////////////////////////////////////////////////////////////////////////
-class NavDataCache::ThreadedAirportSearch::ThreadedAirportSearchPrivate : public SGThread
+class NavDataCache::ThreadedGUISearch::ThreadedGUISearchPrivate : public SGThread
{
public:
- ThreadedAirportSearchPrivate() :
+ ThreadedGUISearchPrivate() :
db(NULL),
isComplete(false),
quit(false)
SGTimeStamp::sleepForMSec(1);
} else {
std::string errMsg = sqlite3_errmsg(db);
- SG_LOG(SG_NAVCACHE, SG_ALERT, "Sqlite error:" << errMsg << " running threaded airport query");
+ SG_LOG(SG_NAVCACHE, SG_ALERT, "Sqlite error:" << errMsg << " running threaded search query");
}
}
bool quit;
};
-NavDataCache::ThreadedAirportSearch::ThreadedAirportSearch(const std::string& term) :
- d(new ThreadedAirportSearchPrivate)
+NavDataCache::ThreadedGUISearch::ThreadedGUISearch(const std::string& term) :
+ d(new ThreadedGUISearchPrivate)
{
SGPath p = NavDataCache::instance()->path();
int openFlags = SQLITE_OPEN_READONLY;
d->start();
}
-NavDataCache::ThreadedAirportSearch::~ThreadedAirportSearch()
+NavDataCache::ThreadedGUISearch::~ThreadedGUISearch()
{
{
SGGuard<SGMutex> g(d->lock);
sqlite3_close_v2(d->db);
}
-PositionedIDVec NavDataCache::ThreadedAirportSearch::results() const
+PositionedIDVec NavDataCache::ThreadedGUISearch::results() const
{
PositionedIDVec r;
{
return r;
}
-bool NavDataCache::ThreadedAirportSearch::isComplete() const
+bool NavDataCache::ThreadedGUISearch::isComplete() const
{
SGGuard<SGMutex> g(d->lock);
return d->isComplete;
bool isReadOnly() const;
- class ThreadedAirportSearch
+ class ThreadedGUISearch
{
public:
- ThreadedAirportSearch(const std::string& term);
- ~ThreadedAirportSearch();
+ ThreadedGUISearch(const std::string& term);
+ ~ThreadedGUISearch();
PositionedIDVec results() const;
bool isComplete() const;
private:
- class ThreadedAirportSearchPrivate;
- std::auto_ptr<ThreadedAirportSearchPrivate> d;
+ class ThreadedGUISearchPrivate;
+ std::auto_ptr<ThreadedGUISearchPrivate> d;
};
private:
NavDataCache();