[tracking] Use the config object

- right now only holds the global policy URL (as a string)
main
Adriaan de Groot 5 years ago
parent a69d47c115
commit 044f5ce2b5

@ -18,6 +18,7 @@
#include "TrackingPage.h" #include "TrackingPage.h"
#include "Config.h"
#include "ui_page_trackingstep.h" #include "ui_page_trackingstep.h"
#include "Branding.h" #include "Branding.h"
@ -32,27 +33,12 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QLabel> #include <QLabel>
TrackingPage::TrackingPage( QWidget* parent ) TrackingPage::TrackingPage( Config* config, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::TrackingPage ) , ui( new Ui::TrackingPage )
{ {
ui->setupUi( this ); ui->setupUi( this );
CALAMARES_RETRANSLATE( CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
QString product = Calamares::Branding::instance()->shortProductName(); ui->retranslateUi( this );
ui->generalExplanation->setText(
tr( "Install tracking helps %1 to see how many users they have, what hardware they install %1 to and (with "
"the last two options below), get continuous information about preferred applications. To see what "
"will be sent, please click the help icon next to each area." )
.arg( product ) );
ui->installExplanation->setText(
tr( "By selecting this you will send information about your installation and hardware. This information "
"will <b>only be sent once</b> after the installation finishes." ) );
ui->machineExplanation->setText( tr( "By selecting this you will <b>periodically</b> send information about "
"your installation, hardware and applications, to %1." )
.arg( product ) );
ui->userExplanation->setText( tr( "By selecting this you will <b>regularly</b> send information about your "
"installation, hardware, applications and usage patterns, to %1." )
.arg( product ) ); )
QButtonGroup* group = new QButtonGroup( this ); QButtonGroup* group = new QButtonGroup( this );
group->setExclusive( true ); group->setExclusive( true );
@ -61,8 +47,33 @@ TrackingPage::TrackingPage( QWidget* parent )
group->addButton( ui->machineRadio ); group->addButton( ui->machineRadio );
group->addButton( ui->userRadio ); group->addButton( ui->userRadio );
ui->noneRadio->setChecked( true ); ui->noneRadio->setChecked( true );
connect( config, &Config::generalPolicyChanged, this, &TrackingPage::setGeneralPolicy );
retranslate();
}
void
TrackingPage::retranslate()
{
QString product = Calamares::Branding::instance()->shortProductName();
ui->retranslateUi( this );
ui->generalExplanation->setText(
tr( "Install tracking helps %1 to see how many users they have, what hardware they install %1 to and (with "
"the last two options below), get continuous information about preferred applications. To see what "
"will be sent, please click the help icon next to each area." )
.arg( product ) );
ui->installExplanation->setText(
tr( "By selecting this you will send information about your installation and hardware. This information "
"will <b>only be sent once</b> after the installation finishes." ) );
ui->machineExplanation->setText( tr( "By selecting this you will <b>periodically</b> send information about "
"your installation, hardware and applications, to %1." )
.arg( product ) );
ui->userExplanation->setText( tr( "By selecting this you will <b>regularly</b> send information about your "
"installation, hardware, applications and usage patterns, to %1." )
.arg( product ) );
} }
void void
TrackingPage::enableTrackingOption( TrackingType t, bool enabled ) TrackingPage::enableTrackingOption( TrackingType t, bool enabled )
{ {
@ -154,7 +165,7 @@ TrackingPage::setTrackingPolicy( TrackingType t, QString url )
} }
else else
{ {
connect( button, &QToolButton::clicked, [ url ] { QDesktopServices::openUrl( url ); } ); connect( button, &QToolButton::clicked, [url] { QDesktopServices::openUrl( url ); } );
cDebug() << "Tracking policy" << int( t ) << "set to" << url; cDebug() << "Tracking policy" << int( t ) << "set to" << url;
} }
else else
@ -175,7 +186,7 @@ TrackingPage::setGeneralPolicy( QString url )
ui->generalPolicyLabel->show(); ui->generalPolicyLabel->show();
ui->generalPolicyLabel->setTextInteractionFlags( Qt::TextBrowserInteraction ); ui->generalPolicyLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
ui->generalPolicyLabel->show(); ui->generalPolicyLabel->show();
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [ url ] { QDesktopServices::openUrl( url ); } ); connect( ui->generalPolicyLabel, &QLabel::linkActivated, [url] { QDesktopServices::openUrl( url ); } );
} }
} }
@ -184,20 +195,20 @@ TrackingPage::setTrackingLevel( TrackingType t )
{ {
QRadioButton* button = nullptr; QRadioButton* button = nullptr;
switch( t ) switch ( t )
{ {
case TrackingType::NoTracking: case TrackingType::NoTracking:
button = ui->noneRadio; button = ui->noneRadio;
break; break;
case TrackingType::InstallTracking: case TrackingType::InstallTracking:
button = ui->installRadio; button = ui->installRadio;
break; break;
case TrackingType::MachineTracking: case TrackingType::MachineTracking:
button = ui->machineRadio; button = ui->machineRadio;
break; break;
case TrackingType::UserTracking: case TrackingType::UserTracking:
button = ui->userRadio; button = ui->userRadio;
break; break;
} }
if ( button != nullptr ) if ( button != nullptr )

@ -29,11 +29,13 @@ namespace Ui
class TrackingPage; class TrackingPage;
} }
class Config;
class TrackingPage : public QWidget class TrackingPage : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TrackingPage( QWidget* parent = nullptr ); explicit TrackingPage( Config* config, QWidget* parent = nullptr );
/** @brief Set initial state for each option /** @brief Set initial state for each option
* *
@ -54,11 +56,15 @@ public:
///@brief Set URL for given level @p t ///@brief Set URL for given level @p t
void setTrackingPolicy( TrackingType t, QString url ); void setTrackingPolicy( TrackingType t, QString url );
///@brief Set URL for the global link
void setGeneralPolicy( QString url );
///@brief Select one of the four levels by name ///@brief Select one of the four levels by name
void setTrackingLevel( TrackingType t ); void setTrackingLevel( TrackingType t );
public Q_SLOTS:
///@brief Set URL for the global link
void setGeneralPolicy( QString url );
void retranslate();
private: private:
Ui::TrackingPage* ui; Ui::TrackingPage* ui;
}; };

@ -18,6 +18,7 @@
#include "TrackingViewStep.h" #include "TrackingViewStep.h"
#include "Config.h"
#include "TrackingJobs.h" #include "TrackingJobs.h"
#include "TrackingPage.h" #include "TrackingPage.h"
@ -43,7 +44,8 @@ isValidStyle( const QString& s )
TrackingViewStep::TrackingViewStep( QObject* parent ) TrackingViewStep::TrackingViewStep( QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
, m_widget( new TrackingPage ) , m_config( new Config( this ) )
, m_widget( new TrackingPage( m_config ) )
{ {
emit nextStatusChanged( false ); emit nextStatusChanged( false );
} }
@ -186,9 +188,10 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); m_config->setConfigurationMap( configurationMap );
bool ok; bool ok;
m_widget->setTrackingLevel( trackingNames().find(CalamaresUtils::getString( configurationMap, "default" ), ok ) ); m_widget->setTrackingLevel( trackingNames().find( CalamaresUtils::getString( configurationMap, "default" ), ok ) );
if ( !ok ) if ( !ok )
{ {
cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" ); cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" );

@ -29,6 +29,7 @@
#include <QUrl> #include <QUrl>
#include <QVariantMap> #include <QVariantMap>
class Config;
class TrackingPage; class TrackingPage;
class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep
@ -58,6 +59,7 @@ public:
private: private:
QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t ); QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t );
Config* m_config;
TrackingPage* m_widget; TrackingPage* m_widget;
QString m_installTrackingUrl; QString m_installTrackingUrl;
QString m_machineTrackingStyle; QString m_machineTrackingStyle;

Loading…
Cancel
Save