mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 05:28:09 +08:00
Ref T135, moved TDistributionSetting to BlackCore::Application::TDistribution
* own file * can use loaded distribution info in sApp
This commit is contained in:
committed by
Mathew Sutcliffe
parent
97f687077c
commit
f07bdc204a
50
src/blackcore/application/distributionsettings.h
Normal file
50
src/blackcore/application/distributionsettings.h
Normal file
@@ -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 <QStringList>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Application
|
||||
{
|
||||
//! Distribution settings, QStringList with 2 values: channel/platform
|
||||
struct TDistribution : public BlackMisc::TSettingTrait<QStringList>
|
||||
{
|
||||
//! \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
|
||||
@@ -131,32 +131,6 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(platformVersions, 0, DisabledForComparison | DisabledForHashing)
|
||||
);
|
||||
};
|
||||
//! Distribution settings: channel/platform
|
||||
struct TDistributionSetting : public BlackMisc::TSettingTrait<QStringList>
|
||||
{
|
||||
//! \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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user