[tracking] Move setup of initial-tracking states to Config
- the *default* level from the config, can be handled inside the Config object as well; remove TrackingPage method that does the same.
This commit is contained in:
parent
1d143d95a0
commit
bed884c971
@ -18,11 +18,30 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "TrackingType.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
const NamedEnumTable< TrackingType >&
|
||||
trackingNames()
|
||||
{
|
||||
// *INDENT-OFF*
|
||||
// clang-format off
|
||||
static const NamedEnumTable< TrackingType > names {
|
||||
{ QStringLiteral( "none" ), TrackingType::NoTracking },
|
||||
{ QStringLiteral( "install" ), TrackingType::InstallTracking },
|
||||
{ QStringLiteral( "machine" ), TrackingType::MachineTracking },
|
||||
{ QStringLiteral( "user" ), TrackingType::UserTracking }
|
||||
};
|
||||
// clang-format on
|
||||
// *INDENT-ON*
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
TrackingStyleConfig::TrackingStyleConfig( QObject* parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
@ -154,6 +173,26 @@ Config::Config( QObject* parent )
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
enableLevelsBelow( Config* config, TrackingType level )
|
||||
{
|
||||
switch( level )
|
||||
{
|
||||
case TrackingType::UserTracking:
|
||||
config->userTracking()->setTracking( TrackingStyleConfig::TrackingState::EnabledByUser );
|
||||
FALLTHRU;
|
||||
case TrackingType::MachineTracking:
|
||||
config->machineTracking()->setTracking( TrackingStyleConfig::TrackingState::EnabledByUser );
|
||||
FALLTHRU;
|
||||
case TrackingType::InstallTracking:
|
||||
config->installTracking()->setTracking( TrackingStyleConfig::TrackingState::EnabledByUser );
|
||||
break;
|
||||
case TrackingType::NoTracking:
|
||||
config->noTracking( true );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
@ -183,6 +222,14 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_userTracking->setConfigurationMap( subconfig );
|
||||
}
|
||||
|
||||
auto level = trackingNames().find( CalamaresUtils::getString( configurationMap, "default" ), success );
|
||||
if ( !success )
|
||||
{
|
||||
cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" );
|
||||
level = TrackingType::NoTracking;
|
||||
}
|
||||
enableLevelsBelow( this, level );
|
||||
}
|
||||
|
||||
QString
|
||||
@ -190,3 +237,15 @@ Config::generalPolicy() const
|
||||
{
|
||||
return m_generalPolicy;
|
||||
}
|
||||
|
||||
void
|
||||
Config::noTracking( bool switchOffAllTracking )
|
||||
{
|
||||
if ( !switchOffAllTracking )
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_installTracking->setTracking( TrackingStyleConfig::TrackingState::DisabledByUser );
|
||||
m_machineTracking->setTracking( TrackingStyleConfig::TrackingState::DisabledByUser );
|
||||
m_userTracking->setTracking( TrackingStyleConfig::TrackingState::DisabledByUser );
|
||||
}
|
||||
|
@ -173,6 +173,9 @@ public Q_SLOTS:
|
||||
MachineTrackingConfig* machineTracking() const { return m_machineTracking; }
|
||||
UserTrackingConfig* userTracking() const { return m_userTracking; }
|
||||
|
||||
/// @brief Call with @c true to turn off all the trackings
|
||||
void noTracking( bool );
|
||||
|
||||
signals:
|
||||
void generalPolicyChanged( QString );
|
||||
|
||||
|
@ -29,7 +29,7 @@ enum class TrackingType
|
||||
UserTracking // Track the user, ongoing
|
||||
};
|
||||
|
||||
// Implemented in TrackingViewStep.cpp
|
||||
// Implemented in Config.cpp
|
||||
const NamedEnumTable< TrackingType >& trackingNames();
|
||||
|
||||
#endif //TRACKINGTYPE_H
|
||||
|
@ -127,28 +127,5 @@ void
|
||||
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_config->setConfigurationMap( configurationMap );
|
||||
|
||||
bool ok;
|
||||
m_widget->setTrackingLevel( trackingNames().find( CalamaresUtils::getString( configurationMap, "default" ), ok ) );
|
||||
if ( !ok )
|
||||
{
|
||||
cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" );
|
||||
}
|
||||
}
|
||||
|
||||
const NamedEnumTable< TrackingType >&
|
||||
trackingNames()
|
||||
{
|
||||
// *INDENT-OFF*
|
||||
// clang-format off
|
||||
static const NamedEnumTable< TrackingType > names {
|
||||
{ QStringLiteral( "none" ), TrackingType::NoTracking },
|
||||
{ QStringLiteral( "install" ), TrackingType::InstallTracking },
|
||||
{ QStringLiteral( "machine" ), TrackingType::MachineTracking },
|
||||
{ QStringLiteral( "user" ), TrackingType::UserTracking }
|
||||
};
|
||||
// clang-format on
|
||||
// *INDENT-ON*
|
||||
|
||||
return names;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user