Files
pilotclient/src/blackcore/coremodeenums.h
Lars Toenning bcc4bdd31e Add SPDX identifiers for REUSE compliance
Co-authored-by: Mat Sutcliffe <oktal3700@gmail.com>
2023-10-03 09:29:49 +02:00

53 lines
1.5 KiB
C++

// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
//! \file
#ifndef BLACKGUI_GUIMODEENUMS_H
#define BLACKGUI_GUIMODEENUMS_H
#include <QString>
namespace BlackCore
{
//! Modes, how GUI can be started (core/GUI)
struct CoreModes
{
public:
//! Core runs how and where?
enum CoreMode
{
Standalone,
Distributed
};
//! String to core mode
static CoreMode stringToCoreMode(const QString &m)
{
QString cm(m.toLower().trimmed());
if (cm.isEmpty()) { return Standalone; }
if (m == coreModeToString(Standalone)) { return Standalone; }
if (m == coreModeToString(Distributed)) { return Distributed; }
// some alternative names
if (cm.contains("distribute")) { return Distributed; }
if (cm.contains("standalone")) { return Standalone; }
if (cm.contains("external")) { return Distributed; }
if (cm.contains("gui")) { return Standalone; }
return Standalone;
}
//! Core mode as string
static QString coreModeToString(CoreMode mode)
{
switch (mode)
{
case Standalone: return QStringLiteral("standalone");
case Distributed: return QStringLiteral("distributed");
}
return {};
}
};
}
#endif // guard