mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-02 11:55:36 -04:00
[libcalamares] Add a base class for Config-objects
This is an optional (until 3.3) base class, which can handle Presets consistently for configurations.
This commit is contained in:
parent
381a4f9b53
commit
0be5e04c2e
3 changed files with 125 additions and 0 deletions
64
src/libcalamares/modulesystem/Config.cpp
Normal file
64
src/libcalamares/modulesystem/Config.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "Preset.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
namespace ModuleSystem
|
||||
{
|
||||
|
||||
|
||||
class Config::Private
|
||||
{
|
||||
public:
|
||||
std::unique_ptr< Presets > m_presets;
|
||||
};
|
||||
|
||||
|
||||
Config::Config( QObject* parent )
|
||||
: QObject( parent )
|
||||
, d( std::make_unique< Private >() )
|
||||
{
|
||||
}
|
||||
|
||||
Config::~Config() {}
|
||||
|
||||
void
|
||||
Config::loadPresets( const QVariantMap& configurationMap )
|
||||
{
|
||||
const QString key( "presets" );
|
||||
if ( !configurationMap.contains( key ) )
|
||||
{
|
||||
d->m_presets.reset();
|
||||
return;
|
||||
}
|
||||
bool bogus = true;
|
||||
d->m_presets = std::make_unique< Presets >( CalamaresUtils::getSubMap( configurationMap, key, bogus ) );
|
||||
}
|
||||
|
||||
void
|
||||
Config::loadPresets( const QVariantMap& configurationMap, const QStringList& recognizedKeys )
|
||||
{
|
||||
const QString key( "presets" );
|
||||
if ( !configurationMap.contains( key ) )
|
||||
{
|
||||
d->m_presets.reset();
|
||||
return;
|
||||
}
|
||||
bool bogus = true;
|
||||
d->m_presets
|
||||
= std::make_unique< Presets >( CalamaresUtils::getSubMap( configurationMap, key, bogus ), recognizedKeys );
|
||||
}
|
||||
|
||||
} // namespace ModuleSystem
|
||||
} // namespace Calamares
|
Loading…
Add table
Add a link
Reference in a new issue