From fadb7eb7506044cf8b57dba2af3b0d02e0fe3900 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 2 Dec 2015 01:38:05 +0100 Subject: [PATCH] refs #534 use cached data / settings * models * vPilot rules * DBus address --- src/blackcore/contextruntime.cpp | 15 +++++--- src/blackcore/data/aircraftmodels.h | 55 +++++++++++++++++++++++++++++ src/swiftlauncher/swiftlauncher.cpp | 3 +- src/swiftlauncher/swiftlauncher.h | 4 ++- 4 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 src/blackcore/data/aircraftmodels.h diff --git a/src/blackcore/contextruntime.cpp b/src/blackcore/contextruntime.cpp index 14a5449b1..2417ca603 100644 --- a/src/blackcore/contextruntime.cpp +++ b/src/blackcore/contextruntime.cpp @@ -42,12 +42,17 @@ namespace BlackCore this->connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CRuntime::gracefulShutdown); - // upfront reading of settings, as DBus server already relies on settings + // either use explicit setting or last value QString dbusAddress; - - //! \todo Change when settings ready RW: I wonder if this can be done cleaner. - if (config.hasDBusAddress()) { dbusAddress = config.getDBusAddress(); } // bootstrap / explicit - else { dbusAddress = m_dbusServerAddress.get(); } + if (config.hasDBusAddress()) + { + dbusAddress = config.getDBusAddress(); + m_dbusServerAddress.set(dbusAddress); + } + else + { + dbusAddress = m_dbusServerAddress.get(); + } // DBus if (config.requiresDBusSever()) { this->initDBusServer(dbusAddress); } diff --git a/src/blackcore/data/aircraftmodels.h b/src/blackcore/data/aircraftmodels.h new file mode 100644 index 000000000..1ab27205e --- /dev/null +++ b/src/blackcore/data/aircraftmodels.h @@ -0,0 +1,55 @@ +/* Copyright (C) 2015 + * swift project community / contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKCORE_DATA_AIRCRAFTMODELS_H +#define BLACKCORE_DATA_AIRCRAFTMODELS_H + +#include "blackcore/blackcoreexport.h" +#include "blackcore/datacache.h" +#include "blackmisc/simulation/aircraftmodellist.h" +#include "blackmisc/variant.h" + +namespace BlackCore +{ + namespace Data + { + //! Trait for own simulator models + struct OwnSimulatorAircraftModels : public BlackCore::CDataTrait + { + //! Key in data cache + static const char *key() { return "simulator/models"; } + + //! Default value + static const BlackMisc::Simulation::CAircraftModelList &defaultValue() + { + static const BlackMisc::Simulation::CAircraftModelList defaultValue; + return defaultValue; + } + }; + + //! Trait for vPilot derived models + struct VPilotAircraftModels : public BlackCore::CDataTrait + { + //! Key in data cache + static const char *key() { return "vpilot/models"; } + + //! Default value + static const BlackMisc::Simulation::CAircraftModelList &defaultValue() + { + static const BlackMisc::Simulation::CAircraftModelList defaultValue; + return defaultValue; + } + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index f0b035294..8d7e9cbb3 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -54,7 +54,8 @@ CSwiftLauncher::CSwiftLauncher(QWidget *parent) : new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), this, SLOT(ps_showLogPage())); this->ui->le_DBusServerPort->setValidator(new QIntValidator(0, 65535, this)); - // QTimer::singleShot(5000, this, &CSwiftLauncher::ps_loadedSetup); //deferred init of setup + // default from settings + this->ui->cb_DBusServerAddress->setCurrentText(this->m_dbusServerAddress.get()); } CSwiftLauncher::~CSwiftLauncher() diff --git a/src/swiftlauncher/swiftlauncher.h b/src/swiftlauncher/swiftlauncher.h index 5110c2871..bf4e33958 100644 --- a/src/swiftlauncher/swiftlauncher.h +++ b/src/swiftlauncher/swiftlauncher.h @@ -16,6 +16,7 @@ #include #include "blackcore/data/globalsetup.h" #include "blackcore/data/updateinfo.h" +#include "blackcore/settings/network.h" #include "blackgui/enableforframelesswindow.h" #include "blackgui/overlaymessagesframe.h" #include "swiftguistandard/guimodeenums.h" @@ -59,10 +60,11 @@ protected: private: QScopedPointer ui; - BlackCore::CData m_setup { this, &CSwiftLauncher::ps_changedCache }; //!< setup cache + BlackCore::CData m_setup { this, &CSwiftLauncher::ps_changedCache }; //!< setup cache BlackCore::CData m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache QString m_executable; QStringList m_executableArgs; + BlackCore::CSetting m_dbusServerAddress { this }; //! Get core mode GuiModes::CoreMode getCoreMode() const;