From f07bdc204a5b4406bdf8a11f6c1a9f4661dd9398 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 20 Sep 2017 02:50:23 +0200 Subject: [PATCH] Ref T135, moved TDistributionSetting to BlackCore::Application::TDistribution * own file * can use loaded distribution info in sApp --- .../application/distributionsettings.h | 50 +++++++++++++++++++ src/blackmisc/db/distribution.h | 26 ---------- 2 files changed, 50 insertions(+), 26 deletions(-) create mode 100644 src/blackcore/application/distributionsettings.h diff --git a/src/blackcore/application/distributionsettings.h b/src/blackcore/application/distributionsettings.h new file mode 100644 index 000000000..321a4478b --- /dev/null +++ b/src/blackcore/application/distributionsettings.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2017 + * 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_APPLICATION_DISTRIBUTIONSETTINGS_H +#define BLACKCORE_APPLICATION_DISTRIBUTIONSETTINGS_H + +#include "blackcore/application.h" +#include "blackconfig/buildconfig.h" +#include "blackmisc/settingscache.h" +#include + +namespace BlackCore +{ + namespace Application + { + //! Distribution settings, QStringList with 2 values: channel/platform + struct TDistribution : public BlackMisc::TSettingTrait + { + //! \copydoc BlackMisc::TSettingTrait::key + static const char *key() { return "distribution"; } + + //! \copydoc BlackMisc::TSettingTrait::defaultValue + static const QStringList &defaultValue() + { + // guessing / preseting some default values + static const QStringList d = (sApp && !sApp->getDistributionInfo().isEmpty()) ? + sApp->getDistributionInfo().guessMyDefaultChannelAndPlatform() : // from cached or loaded distribution data + QStringList({"ALPHA", BlackConfig::CBuildConfig::guessMyPlatformString()}); // guessing + return d; + } + + //! \copydoc BlackMisc::TSettingTrait::humanReadable + static const QString &humanReadable() + { + static const QString name("Download channel/platform"); + return name; + } + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackmisc/db/distribution.h b/src/blackmisc/db/distribution.h index e8f4d0a9f..7b0ab33d5 100644 --- a/src/blackmisc/db/distribution.h +++ b/src/blackmisc/db/distribution.h @@ -131,32 +131,6 @@ namespace BlackMisc BLACK_METAMEMBER(platformVersions, 0, DisabledForComparison | DisabledForHashing) ); }; - //! Distribution settings: channel/platform - struct TDistributionSetting : public BlackMisc::TSettingTrait - { - //! \copydoc BlackMisc::TSettingTrait::key - static const char *key() { return "distribution"; } - - //! \copydoc BlackMisc::TSettingTrait::defaultValue - static const QStringList &defaultValue() - { - // guessing / preseting some default values - static const QStringList d{"ALPHA", platformString()}; - return d; - } - - //! Guessed platform string - //! \todo this hardcoded stuff here is useful right now, but needs to go - static QString platformString() - { - QString p; - if (BlackConfig::CBuildConfig::isRunningOnWindowsNtPlatform()) { p = "win-64"; } - else if (BlackConfig::CBuildConfig::isRunningOnMacOSXPlatform()) { p = "macos-64"; } - else if (BlackConfig::CBuildConfig::isRunningOnLinuxPlatform()) { p = "linux-64"; } - if (!p.isEmpty() && BlackConfig::CBuildConfig::isVatsimVersion()) { p += "-vatsim"; } - return p; - } - }; } // ns } // ns