diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index ba1d5efd0..359fac4b4 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -172,34 +172,28 @@ TrackingPage::setGeneralPolicy( QString url ) } void -TrackingPage::setTrackingLevel( const QString& l ) +TrackingPage::setTrackingLevel( TrackingType t ) { - QString level = l.toLower(); QRadioButton* button = nullptr; - if ( level.isEmpty() || level == "none" ) + switch( t ) { - button = ui->noneRadio; - } - else if ( level == "install" ) - { - button = ui->installRadio; - } - else if ( level == "machine" ) - { - button = ui->machineRadio; - } - else if ( level == "user" ) - { - button = ui->userRadio; + case TrackingType::NoTracking: + button = ui->noneRadio; + break; + case TrackingType::InstallTracking: + button = ui->installRadio; + break; + case TrackingType::MachineTracking: + button = ui->machineRadio; + break; + case TrackingType::UserTracking: + button = ui->userRadio; + break; } if ( button != nullptr ) { button->setChecked( true ); } - else - { - cWarning() << "unknown default tracking level" << l; - } } diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index 560115b92..52cfca493 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -35,7 +35,8 @@ class TrackingPage : public QWidget public: explicit TrackingPage( QWidget* parent = nullptr ); - /** + /** @brief Set initial state for each option + * * Enables or disables the tracking-option block for the given * tracking option @p t, and sets the initial state of the * checkbox to the @p user default. @@ -43,19 +44,20 @@ public: * Call this in ascending order of tracking type. */ void enableTrackingOption( TrackingType t, bool enabled ); - /** + /** @brief Is the given tracking type enabled? + * * Returns whether tracking type @p is selected by the user * (i.e. is the radio button for that level, or for a higher * tracking level, enabled). */ bool getTrackingOption( TrackingType t ); - /* URL for given level @p t */ + ///@brief Set URL for given level @p t void setTrackingPolicy( TrackingType t, QString url ); - /* URL for the global link */ + ///@brief Set URL for the global link void setGeneralPolicy( QString url ); - /* Select one of the four levels by name */ - void setTrackingLevel( const QString& level ); + ///@brief Select one of the four levels by name + void setTrackingLevel( TrackingType t ); private: Ui::TrackingPage* ui; diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 2cb97f079..f934301bd 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -187,7 +187,12 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); - m_widget->setTrackingLevel( CalamaresUtils::getString( configurationMap, "default" ) ); + 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 >&