cleanup firstRun with a common setting

This commit is contained in:
Brad Hefta-Gaub 2016-05-10 11:32:29 -07:00
parent 22f4beab1a
commit 33c5cb519a
6 changed files with 12 additions and 5 deletions

View file

@ -1091,6 +1091,11 @@ void Application::checkChangeCursor() {
_cursorNeedsChanging = false;
}
// After all of the constructor is completed, then set firstRun to false.
Setting::Handle<bool> firstRun{ Settings::firstRun, true };
firstRun.set(false);
}
void Application::showCursor(const QCursor& cursor) {
@ -2950,7 +2955,7 @@ void Application::init() {
addressLookupString = arguments().value(urlIndex + 1);
}
Setting::Handle<bool> firstRun { "firstRun", true };
Setting::Handle<bool> firstRun { Settings::firstRun, true };
if (addressLookupString.isEmpty() && firstRun.get()) {
qDebug() << "First run and no URL passed... attempting to Go Home...";
DependencyManager::get<AddressManager>()->goHomeOrElsewhere();

View file

@ -270,12 +270,12 @@ void ScriptEngines::loadOneScript(const QString& scriptFilename) {
void ScriptEngines::loadScripts() {
// check first run...
if (_firstRun.get()) {
Setting::Handle<bool> firstRun { Settings::firstRun, true };
if (firstRun.get()) {
qCDebug(scriptengine) << "This is a first run...";
// clear the scripts, and set out script to our default scripts
clearScripts();
loadDefaultScripts();
_firstRun.set(false);
return;
}

View file

@ -87,8 +87,6 @@ protected:
void onScriptEngineError(const QString& scriptFilename);
void launchScriptEngine(ScriptEngine* engine);
Setting::Handle<bool> _firstRun { "firstRun", true };
QReadWriteLock _scriptEnginesHashLock;
QHash<QUrl, ScriptEngine*> _scriptEnginesHash;
QSet<ScriptEngine*> _allKnownScriptEngines;

View file

@ -13,6 +13,7 @@
#include <math.h>
const QString Settings::firstRun { "firstRun" };
void Settings::getFloatValueIfValid(const QString& name, float& floatValue) {
const QVariant badDefaultValue = NAN;

View file

@ -26,6 +26,8 @@
// TODO: remove
class Settings : public QSettings {
public:
static const QString firstRun;
void getFloatValueIfValid(const QString& name, float& floatValue);
void getBoolValue(const QString& name, bool& boolValue);

View file

@ -16,6 +16,7 @@
#include <QVariant>
namespace Setting {
void preInit();
void init();
void cleanupSettings();