Launcher bugfix: custom download dirs
Partial fixes for: https://sourceforge.net/p/flightgear/codetickets/2019/ But further work needed on Windows I expect, will do that now.
This commit is contained in:
parent
2e438e357e
commit
6f8a788d80
3 changed files with 17 additions and 25 deletions
|
@ -344,9 +344,9 @@ void LauncherController::downloadDirChanged(QString path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the default dir is passed in, map that back to the emptru string
|
// if the default dir is passed in, map that back to the empty string
|
||||||
if (path == m_config->defaultDownloadDir()) {
|
if (path == m_config->defaultDownloadDir()) {
|
||||||
path.clear();;
|
path.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto options = flightgear::Options::sharedInstance();
|
auto options = flightgear::Options::sharedInstance();
|
||||||
|
@ -364,25 +364,9 @@ void LauncherController::downloadDirChanged(QString path)
|
||||||
options->clearOption("download-dir");
|
options->clearOption("download-dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
// replace existing package root
|
m_config->setValueForKey("", "download-dir", path);
|
||||||
globals->get_subsystem<FGHTTPClient>()->shutdown();
|
saveSettings();
|
||||||
globals->setPackageRoot(simgear::pkg::RootRef());
|
flightgear::restartTheApp();
|
||||||
|
|
||||||
// create new root with updated download-dir value
|
|
||||||
fgInitPackageRoot();
|
|
||||||
|
|
||||||
globals->get_subsystem<FGHTTPClient>()->init();
|
|
||||||
|
|
||||||
QSettings settings;
|
|
||||||
// re-scan the aircraft list
|
|
||||||
m_aircraftModel->setPackageRoot(globals->packageRoot());
|
|
||||||
|
|
||||||
auto aircraftCache = LocalAircraftCache::instance();
|
|
||||||
aircraftCache->setPaths(settings.value("aircraft-paths").toStringList());
|
|
||||||
aircraftCache->scanDirs();
|
|
||||||
|
|
||||||
// re-set scenery dirs
|
|
||||||
flightgear::launcherSetSceneryPaths();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlAircraftInfo *LauncherController::selectedAircraftInfo() const
|
QmlAircraftInfo *LauncherController::selectedAircraftInfo() const
|
||||||
|
|
|
@ -62,6 +62,9 @@ Item {
|
||||||
|
|
||||||
function saveState()
|
function saveState()
|
||||||
{
|
{
|
||||||
|
if (root.setting === "")
|
||||||
|
return;
|
||||||
|
|
||||||
if (this.hasOwnProperty("value")) {
|
if (this.hasOwnProperty("value")) {
|
||||||
_config.setValueForKey("", root.setting, this.value)
|
_config.setValueForKey("", root.setting, this.value)
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,10 +74,8 @@ Item {
|
||||||
|
|
||||||
function restoreState()
|
function restoreState()
|
||||||
{
|
{
|
||||||
if (root.setting == "") {
|
if (root.setting === "")
|
||||||
console.warn("Missing setting key on " + label)
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!"value" in root) {
|
if (!"value" in root) {
|
||||||
console.warn("No value property on " + root);
|
console.warn("No value property on " + root);
|
||||||
|
|
|
@ -309,7 +309,8 @@ Item {
|
||||||
label: qsTr("Download location")
|
label: qsTr("Download location")
|
||||||
description: qsTr("FlightGear stores downloaded files (scenery and aircraft) in this location. "
|
description: qsTr("FlightGear stores downloaded files (scenery and aircraft) in this location. "
|
||||||
+ "Depending on your settings, it may grow to a considerable size (many gigabytes). "
|
+ "Depending on your settings, it may grow to a considerable size (many gigabytes). "
|
||||||
+ "If you change the download location, files will need to be downloaded again.")
|
+ "If you change the download location, files will need to be downloaded again. "
|
||||||
|
+ "When changing this setting, FlightGear will restart to use the new location correctly.")
|
||||||
advanced: true
|
advanced: true
|
||||||
chooseDirectory: true
|
chooseDirectory: true
|
||||||
defaultPath: _config.defaultDownloadDir
|
defaultPath: _config.defaultDownloadDir
|
||||||
|
@ -327,6 +328,12 @@ Item {
|
||||||
// value is changed.
|
// value is changed.
|
||||||
_launcher.downloadDirChanged(path);
|
_launcher.downloadDirChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveState()
|
||||||
|
{
|
||||||
|
// ensure this is a no-op, we write the value explicity
|
||||||
|
// in LauncherController::downloadDirChanged
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue