qt5_wrap_ui(uic_sources Launcher.ui
EditRatingsFilterDialog.ui
SetupRootDialog.ui
- AddCatalogDialog.ui)
+ AddCatalogDialog.ui
+ PathsDialog.ui)
qt5_add_resources(qrc_sources resources.qrc)
include_directories(${PROJECT_BINARY_DIR}/src/GUI)
CatalogListModel.hxx
AddCatalogDialog.cxx
AddCatalogDialog.hxx
+ PathsDialog.cxx
+ PathsDialog.hxx
${uic_sources}
${qrc_sources})
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
</item>
</layout>
</item>
- <item row="7" column="0" colspan="2">
+ <item row="8" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Additional options</string>
</layout>
</widget>
</item>
- <item row="6" column="0">
+ <item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
- </layout>
- </widget>
- <widget class="QWidget" name="tab_4">
- <attribute name="title">
- <string>Add-ons</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="leftMargin">
- <number>8</number>
- </property>
- <property name="rightMargin">
- <number>8</number>
- </property>
- <property name="bottomMargin">
- <number>8</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,0">
- <item>
- <widget class="QLabel" name="customAircraftDirLabel">
- <property name="text">
- <string>Custom aircraft directory:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="openAircraftDirButton">
- <property name="text">
- <string>Open in Finder</string>
- </property>
- <property name="autoDefault">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Additional scenery locations</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_3">
- <property name="leftMargin">
- <number>8</number>
- </property>
- <property name="topMargin">
- <number>8</number>
- </property>
- <property name="rightMargin">
- <number>8</number>
- </property>
- <property name="bottomMargin">
- <number>8</number>
- </property>
- <property name="spacing">
- <number>0</number>
- </property>
- <item row="1" column="0">
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>567</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2">
- <widget class="QToolButton" name="removeSceneryPath">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>-</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QToolButton" name="addSceneryPath">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>+</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="3">
- <widget class="QListWidget" name="sceneryPathsList"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_4">
- <property name="title">
- <string>Aircraft hangar locations</string>
- </property>
- <layout class="QGridLayout" name="gridLayout_6">
- <property name="leftMargin">
- <number>8</number>
- </property>
- <property name="topMargin">
- <number>8</number>
- </property>
- <property name="rightMargin">
- <number>8</number>
- </property>
- <property name="bottomMargin">
- <number>8</number>
- </property>
- <property name="spacing">
- <number>0</number>
- </property>
- <item row="1" column="0">
- <spacer name="horizontalSpacer_5">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>567</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2">
- <widget class="QToolButton" name="removeCatalog">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>-</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QToolButton" name="addCatalog">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>+</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0" colspan="3">
- <widget class="QListView" name="catalogsList"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_3">
- <property name="title">
- <string>Additional aircraft locations</string>
+ <item row="6" column="0">
+ <widget class="QPushButton" name="pathsButton">
+ <property name="text">
+ <string>Configure add-on aircraft and scenery</string>
</property>
- <layout class="QGridLayout" name="gridLayout_4">
- <property name="leftMargin">
- <number>8</number>
- </property>
- <property name="topMargin">
- <number>8</number>
- </property>
- <property name="rightMargin">
- <number>8</number>
- </property>
- <property name="bottomMargin">
- <number>8</number>
- </property>
- <property name="spacing">
- <number>0</number>
- </property>
- <item row="0" column="0" colspan="3">
- <widget class="QListWidget" name="aircraftPathsList"/>
- </item>
- <item row="1" column="0">
- <spacer name="horizontalSpacer_4">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>567</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2">
- <widget class="QToolButton" name="removeAircraftPath">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>-</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QToolButton" name="addAircraftPath">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- <property name="text">
- <string>+</string>
- </property>
- </widget>
- </item>
- </layout>
</widget>
</item>
</layout>
--- /dev/null
+#ifndef PATHSDIALOG_HXX
+#define PATHSDIALOG_HXX
+
+#include <QDialog>
+
+#include <simgear/package/Root.hxx>
+
+
+namespace Ui {
+class PathsDialog;
+}
+
+class CatalogListModel;
+
+class PathsDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit PathsDialog(QWidget *parent, simgear::pkg::RootRef root);
+ ~PathsDialog();
+
+protected:
+ virtual void accept();
+
+private slots:
+ void onAddSceneryPath();
+ void onRemoveSceneryPath();
+
+ void onAddAircraftPath();
+ void onRemoveAircraftPath();
+
+ void onAddCatalog();
+ void onRemoveCatalog();
+
+ void onChangeDownloadDir();
+ void onClearDownloadDir();
+private:
+ void updateUi();
+
+ Ui::PathsDialog* m_ui;
+ CatalogListModel* m_catalogsModel;
+ simgear::pkg::RootRef m_packageRoot;
+ QString m_downloadDir;
+
+};
+
+#endif // PATHSDIALOG_HXX
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0" colspan="3">
- <widget class="QLabel" name="downloadLocation">
- <property name="text">
- <string>TextLabel</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="changeDownloadDir">
- <property name="text">
- <string>Change...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QPushButton" name="clearDownloadDir">
- <property name="text">
- <string>Use default location</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
+ <widget class="QLabel" name="downloadLocation">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0">
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
- <item row="2" column="0" colspan="3">
- <widget class="QLabel" name="label_2">
+ <item>
+ <widget class="QPushButton" name="changeDownloadDir">
<property name="text">
- <string>Aircraft hangars and automatic scenery downloads may cause this location to contain large numbers of files. Changing this location will cause files to be downloaded again.</string>
+ <string>Change...</string>
</property>
- <property name="wordWrap">
- <bool>true</bool>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearDownloadDir">
+ <property name="text">
+ <string>Use default location</string>
</property>
</widget>
</item>
</layout>
</item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Aircraft hangars and automatic scenery downloads may cause this location to contain large numbers of files. Changing this location will cause files to be downloaded again.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
#include "EditRatingsFilterDialog.hxx"
#include "AircraftItemDelegate.hxx"
#include "AircraftModel.hxx"
-#include "CatalogListModel.hxx"
-#include "AddCatalogDialog.hxx"
+#include "PathsDialog.hxx"
#include <Main/globals.hxx>
#include <Navaids/NavDataCache.hxx>
connect(m_airportsModel, &AirportSearchModel::searchComplete,
this, &QtLauncher::onAirportSearchComplete);
- // default value, restoreSettings() will override
- m_downloadDir = QString();
-
// create and configure the proxy model
m_aircraftProxy = new AircraftProxyModel(this);
connect(m_ui->ratingsFilterCheck, &QAbstractButton::toggled,
this, &QtLauncher::onToggleTerrasync);
updateSettingsSummary();
- connect(m_ui->addSceneryPath, &QToolButton::clicked,
- this, &QtLauncher::onAddSceneryPath);
- connect(m_ui->removeSceneryPath, &QToolButton::clicked,
- this, &QtLauncher::onRemoveSceneryPath);
-
- connect(m_ui->addAircraftPath, &QToolButton::clicked,
- this, &QtLauncher::onAddAircraftPath);
- connect(m_ui->removeAircraftPath, &QToolButton::clicked,
- this, &QtLauncher::onRemoveAircraftPath);
-
fgInitPackageRoot();
simgear::pkg::RootRef r(globals->packageRoot());
connect(delegate, &AircraftItemDelegate::variantChanged,
this, &QtLauncher::onAircraftSelected);
-
- m_catalogsModel = new CatalogListModel(this, r);
- m_ui->catalogsList->setModel(m_catalogsModel);
-
- connect(m_ui->addCatalog, &QToolButton::clicked,
- this, &QtLauncher::onAddCatalog);
- connect(m_ui->removeCatalog, &QToolButton::clicked,
- this, &QtLauncher::onRemoveCatalog);
+ connect(m_ui->pathsButton, &QPushButton::clicked,
+ this, &QtLauncher::onEditPaths);
QSettings settings;
m_aircraftModel->setPaths(settings.value("aircraft-paths").toStringList());
// select the default C172p
}
- QVariant downloadDir = settings.value("download-dir");
- if (downloadDir.isValid()) {
- m_downloadDir = downloadDir.toString();
- }
-
updateSelectedAircraft();
// ICAO identifiers
m_aircraftProxy->setRatingFilterEnabled(m_ui->ratingsFilterCheck->isChecked());
m_aircraftProxy->setRatings(m_ratingFilters);
- QStringList sceneryPaths = settings.value("scenery-paths").toStringList();
- m_ui->sceneryPathsList->addItems(sceneryPaths);
-
- QStringList aircraftPaths = settings.value("aircraft-paths").toStringList();
- m_ui->aircraftPathsList->addItems(aircraftPaths);
-
m_ui->commandLineArgs->setPlainText(settings.value("additional-args").toString());
}
settings.setValue("recent-airports", m_recentAirports);
settings.setValue("timeofday", m_ui->timeOfDayCombo->currentIndex());
settings.setValue("season", m_ui->seasonCombo->currentIndex());
-
- QStringList paths;
- for (int i=0; i<m_ui->sceneryPathsList->count(); ++i) {
- paths.append(m_ui->sceneryPathsList->item(i)->text());
- }
-
- settings.setValue("scenery-paths", paths);
- paths.clear();
-
- for (int i=0; i<m_ui->aircraftPathsList->count(); ++i) {
- paths.append(m_ui->aircraftPathsList->item(i)->text());
- }
-
- settings.setValue("aircraft-paths", paths);
settings.setValue("additional-args", m_ui->commandLineArgs->toPlainText());
-
- if (m_downloadDir.isEmpty()) {
- settings.remove("download-dir");
- } else {
- settings.setValue("download-dir", m_downloadDir);
- }
}
void QtLauncher::setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const
opt->addOption("season", dayval.toStdString());
}
- if (!m_downloadDir.isEmpty()) {
- QDir d(m_downloadDir);
+ QSettings settings;
+ QString downloadDir = settings.value("download-dir").toString();
+ if (!downloadDir.isEmpty()) {
+ QDir d(downloadDir);
if (!d.exists()) {
int result = QMessageBox::question(this, tr("Create download folder?"),
tr("The selected location for downloads does not exist. Create it?"),
}
if (result == QMessageBox::Yes) {
- d.mkpath(m_downloadDir);
+ d.mkpath(downloadDir);
}
}
}
// scenery paths
- for (int i=0; i<m_ui->sceneryPathsList->count(); ++i) {
- QString path = m_ui->sceneryPathsList->item(i)->text();
+ Q_FOREACH(QString path, settings.value("scenery-paths").toStringList()) {
opt->addOption("fg-scenery", path.toStdString());
}
// aircraft paths
- for (int i=0; i<m_ui->aircraftPathsList->count(); ++i) {
- QString path = m_ui->aircraftPathsList->item(i)->text();
+ Q_FOREACH(QString path, settings.value("aircraft-paths").toStringList()) {
// can't use fg-aircraft for this, as it is processed before the launcher is run
globals->append_aircraft_path(path.toStdString());
}
void QtLauncher::onToggleTerrasync(bool enabled)
{
if (enabled) {
- QFileInfo info(m_downloadDir);
+ QSettings settings;
+ QString downloadDir = settings.value("download-dir").toString();
+ if (downloadDir.isEmpty()) {
+ downloadDir = QString::fromStdString(flightgear::defaultDownloadDir());
+ }
+
+ QFileInfo info(downloadDir);
if (!info.exists()) {
QMessageBox msg;
msg.setWindowTitle(tr("Create download folder?"));
- msg.setText(tr("The current download folder '%1' does not exist, create it now? "
+ msg.setText(tr("The download folder '%1' does not exist, create it now? "
"Click 'change location' to choose another folder "
- "to store downloaded files").arg(m_downloadDir));
+ "to store downloaded files").arg(downloadDir));
msg.addButton(QMessageBox::Yes);
msg.addButton(QMessageBox::Cancel);
msg.addButton(tr("Change location"), QMessageBox::ActionRole);
}
if (result == QMessageBox::ActionRole) {
- qDebug() << "Change location!";
- // open the prefrences dialog?
+ onEditPaths();
return;
}
- QDir d(m_downloadDir);
- d.mkpath(m_downloadDir);
+ QDir d(downloadDir);
+ d.mkpath(downloadDir);
}
-
- }
+ } // of is enabled
}
void QtLauncher::updateAirportDescription()
updateAirportDescription();
}
-#if 0
-void QtLauncher::onOpenCustomAircraftDir()
-{
- QFileInfo info(m_customAircraftDir);
- if (!info.exists()) {
- int result = QMessageBox::question(this, "Create folder?",
- "The custom aircraft folder does not exist, create it now?",
- QMessageBox::Yes | QMessageBox::No,
- QMessageBox::Yes);
- if (result == QMessageBox::No) {
- return;
- }
-
- QDir d(m_customAircraftDir);
- d.mkpath(m_customAircraftDir);
- }
-
- QUrl u = QUrl::fromLocalFile(m_customAircraftDir);
- QDesktopServices::openUrl(u);
-}
-#endif
-
void QtLauncher::onEditRatingsFilter()
{
EditRatingsFilterDialog dialog(this);
m_ui->settingsDescription->setText(s);
}
-void QtLauncher::onAddSceneryPath()
-{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose scenery folder"));
- if (!path.isEmpty()) {
- m_ui->sceneryPathsList->addItem(path);
- saveSettings();
- }
-}
-
-void QtLauncher::onRemoveSceneryPath()
-{
- if (m_ui->sceneryPathsList->currentItem()) {
- delete m_ui->sceneryPathsList->currentItem();
- saveSettings();
- }
-}
-
-void QtLauncher::onAddAircraftPath()
-{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose aircraft folder"));
- if (!path.isEmpty()) {
- m_ui->aircraftPathsList->addItem(path);
- saveSettings();
-
- // re-scan the aircraft list
- QSettings settings;
- m_aircraftModel->setPaths(settings.value("aircraft-paths").toStringList());
- m_aircraftModel->scanDirs();
- }
-}
-
-void QtLauncher::onRemoveAircraftPath()
-{
- if (m_ui->aircraftPathsList->currentItem()) {
- delete m_ui->aircraftPathsList->currentItem();
- saveSettings();
- }
-}
-
-void QtLauncher::onChangeDownloadDir()
-{
- QString path = QFileDialog::getExistingDirectory(this, tr("Choose downloads folder"));
- if (!path.isEmpty()) {
- m_downloadDir = path;
- saveSettings();
- }
-}
-
-void QtLauncher::onClearDownloadDir()
-{
- // does this need an 'are you sure'?
- m_downloadDir.clear();
- saveSettings();
-}
-
void QtLauncher::onRembrandtToggled(bool b)
{
// Rembrandt and multi-sample are exclusive
globals->get_subsystem_mgr()->update(0.0);
}
-void QtLauncher::onAddCatalog()
+void QtLauncher::onEditPaths()
{
- AddCatalogDialog* dlg = new AddCatalogDialog(this, globals->packageRoot());
- dlg->exec();
- if (dlg->result() == QDialog::Accepted) {
- m_catalogsModel->refresh();
+ PathsDialog dlg(this, globals->packageRoot());
+ dlg.exec();
+ if (dlg.result() == QDialog::Accepted) {
+ // re-scan the aircraft list
+ QSettings settings;
+ m_aircraftModel->setPaths(settings.value("aircraft-paths").toStringList());
+ m_aircraftModel->scanDirs();
}
}
-void QtLauncher::onRemoveCatalog()
-{
-
-}
-
#include "QtLauncher.moc"
void onAirportSearchComplete();
- void onAddSceneryPath();
- void onRemoveSceneryPath();
-
- void onAddAircraftPath();
- void onRemoveAircraftPath();
-
- void onAddCatalog();
- void onRemoveCatalog();
-
void onRembrandtToggled(bool b);
void onToggleTerrasync(bool enabled);
void onSubsytemIdleTimeout();
- void onChangeDownloadDir();
- void onClearDownloadDir();
+ void onEditPaths();
private:
void setAirport(FGAirportRef ref);
void updateSelectedAircraft();
AirportSearchModel* m_airportsModel;
AircraftProxyModel* m_aircraftProxy;
AircraftItemModel* m_aircraftModel;
- CatalogListModel* m_catalogsModel;
-
FGAirportRef m_selectedAirport;
QString m_selectedAircraft;
QStringList m_recentAircraft,
m_recentAirports;
- QString m_downloadDir;
QTimer* m_subsystemIdleTimer;
int m_ratingFilters[4];