1
0
Fork 0

GUI ‘restore defaults’ support.

- Hold ‘alt’ on launch to restore defaults, including launcher prefs.
This commit is contained in:
James Turner 2015-03-08 00:40:22 +00:00
parent f9c23eb096
commit c3543f8fdd
4 changed files with 38 additions and 16 deletions

View file

@ -81,7 +81,7 @@ const int AircraftVariantDescriptionRole = Qt::UserRole + 200;
void initNavCache() void initNavCache()
{ {
NavDataCache* cache = NavDataCache::instance(); NavDataCache* cache = NavDataCache::createInstance();
if (cache->isRebuildRequired()) { if (cache->isRebuildRequired()) {
QProgressDialog rebuildProgress("Initialising navigation data, this may take several minutes", QProgressDialog rebuildProgress("Initialising navigation data, this may take several minutes",
QString() /* cancel text */, QString() /* cancel text */,
@ -1102,6 +1102,18 @@ void QtLauncher::initApp(int argc, char** argv)
// avoid double Apple menu and other weirdness if both Qt and OSG // avoid double Apple menu and other weirdness if both Qt and OSG
// try to initialise various Cocoa structures. // try to initialise various Cocoa structures.
flightgear::WindowBuilder::setPoseAsStandaloneApp(false); 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", "");
}
} }
} }

View file

@ -590,17 +590,22 @@ int fgInitAircraft(bool reinit)
bool bool
fgInitNav () fgInitNav ()
{ {
flightgear::NavDataCache* cache = flightgear::NavDataCache::instance(); flightgear::NavDataCache* cache = flightgear::NavDataCache::instance();
static bool doingRebuild = false; static bool doingRebuild = false;
if (doingRebuild || cache->isRebuildRequired()) {
doingRebuild = true; if (!cache) {
bool finished = cache->rebuild(); cache = flightgear::NavDataCache::createInstance();
if (!finished) { doingRebuild = cache->isRebuildRequired();
// sleep to give the rebuild thread more time }
SGTimeStamp::sleepForMSec(50);
return false; if (doingRebuild) {
bool finished = cache->rebuild();
if (!finished) {
// sleep to give the rebuild thread more time
SGTimeStamp::sleepForMSec(50);
return false;
}
} }
}
// depend on when the NavCache was initialised, scenery paths may not // depend on when the NavCache was initialised, scenery paths may not
// have been setup. This is a safe place to consistently check the value, // have been setup. This is a safe place to consistently check the value,

View file

@ -1121,20 +1121,22 @@ NavDataCache::NavDataCache()
d->airwayDatPath = SGPath(globals->get_fg_root()); d->airwayDatPath = SGPath(globals->get_fg_root());
d->airwayDatPath.append("Navaids/awy.dat.gz"); d->airwayDatPath.append("Navaids/awy.dat.gz");
} }
NavDataCache::~NavDataCache() NavDataCache::~NavDataCache()
{ {
assert(static_instance == this); assert(static_instance == this);
static_instance = NULL; static_instance = NULL;
d.reset(); d.reset();
} }
NavDataCache* NavDataCache::createInstance()
{
static_instance = new NavDataCache;
return static_instance;
}
NavDataCache* NavDataCache::instance() NavDataCache* NavDataCache::instance()
{ {
if (!static_instance) {
static_instance = new NavDataCache;
}
return static_instance; return static_instance;
} }

View file

@ -58,6 +58,9 @@ public:
// singleton accessor // singleton accessor
static NavDataCache* instance(); static NavDataCache* instance();
// static creator
static NavDataCache* createInstance();
SGPath path() const; SGPath path() const;
/** /**