1
0
Fork 0

Launcher: fix bugs around paths setting.

We now show paths in ‘view command line’ and set them through the
standard mechanism. Re-ordering the paths also notifies the rest of
the system correctly.
This commit is contained in:
James Turner 2017-04-13 12:55:51 +01:00
parent dd0b9adbfc
commit 5f8f2886dc
3 changed files with 33 additions and 19 deletions

View file

@ -493,6 +493,18 @@ void LauncherMainWindow::collectAircraftArgs()
qWarning() << "unsupported aircraft launch URL" << m_selectedAircraft;
}
}
// scenery paths
QSettings settings;
Q_FOREACH(QString path, settings.value("scenery-paths").toStringList()) {
m_config->setArg("fg-scenery", path);
}
// aircraft paths
Q_FOREACH(QString path, settings.value("aircraft-paths").toStringList()) {
m_config->setArg("fg-aircraft", path);
}
}
void LauncherMainWindow::onRun()
@ -511,16 +523,16 @@ void LauncherMainWindow::onRun()
m_recentAircraft.pop_back();
}
// m_ui->location->setLocationProperties();
// aircraft paths
QSettings settings;
updateLocationHistory();
QSettings settings;
QString downloadDir = settings.value("download-dir").toString();
QString downloadDir = settings.value("downloadSettings/downloadDir").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?"),
tr("The selected location for downloads does not exist. (%1) Create it?").arg(downloadDir),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
if (result == QMessageBox::Cancel) {
return;
@ -532,17 +544,6 @@ void LauncherMainWindow::onRun()
}
}
// scenery paths
Q_FOREACH(QString path, settings.value("scenery-paths").toStringList()) {
opt->addOption("fg-scenery", path.toStdString());
}
// aircraft paths
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());
}
if (settings.contains("restore-defaults-on-run")) {
settings.remove("restore-defaults-on-run");
opt->addOption("restore-defaults", "");

View file

@ -68,9 +68,15 @@ AddOnsPage::AddOnsPage(QWidget *parent, simgear::pkg::RootRef root) :
QStringList sceneryPaths = settings.value("scenery-paths").toStringList();
m_ui->sceneryPathsList->addItems(sceneryPaths);
connect(m_ui->sceneryPathsList->model(), &QAbstractItemModel::rowsMoved,
this, &AddOnsPage::saveSceneryPaths);
QStringList aircraftPaths = settings.value("aircraft-paths").toStringList();
m_ui->aircraftPathsList->addItems(aircraftPaths);
connect(m_ui->aircraftPathsList->model(), &QAbstractItemModel::rowsMoved,
this, &AddOnsPage::saveAircraftPaths);
updateUi();
}
@ -160,7 +166,6 @@ void AddOnsPage::onAddAircraftPath()
}
saveAircraftPaths();
emit aircraftPathsChanged();
}
}
@ -169,7 +174,6 @@ void AddOnsPage::onRemoveAircraftPath()
if (m_ui->aircraftPathsList->currentItem()) {
delete m_ui->aircraftPathsList->currentItem();
saveAircraftPaths();
emit aircraftPathsChanged();
}
}
@ -183,6 +187,7 @@ void AddOnsPage::saveAircraftPaths()
}
settings.setValue("aircraft-paths", paths);
emit aircraftPathsChanged();
}
void AddOnsPage::saveSceneryPaths()
@ -293,3 +298,8 @@ void AddOnsPage::updateUi()
FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
m_ui->addDefaultCatalogButton->setEnabled(!http->isDefaultCatalogInstalled());
}
void AddOnsPage::onDraggedAircraftList()
{
qWarning() << "did drag aircraft list";
}

View file

@ -38,11 +38,14 @@ private slots:
void onAddDefaultCatalog();
void onInstallScenery();
private:
void updateUi();
void onDraggedAircraftList();
void saveAircraftPaths();
void saveSceneryPaths();
private:
void updateUi();
bool haveSceneryPath(QString path) const;
Ui::AddOnsPage* m_ui;