[tracking] Use the config object
- right now only holds the global policy URL (as a string)
This commit is contained in:
parent
a69d47c115
commit
044f5ce2b5
@ -18,6 +18,7 @@
|
||||
|
||||
#include "TrackingPage.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "ui_page_trackingstep.h"
|
||||
|
||||
#include "Branding.h"
|
||||
@ -32,13 +33,30 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QLabel>
|
||||
|
||||
TrackingPage::TrackingPage( QWidget* parent )
|
||||
TrackingPage::TrackingPage( Config* config, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::TrackingPage )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
CALAMARES_RETRANSLATE(
|
||||
QString product = Calamares::Branding::instance()->shortProductName(); ui->retranslateUi( this );
|
||||
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
|
||||
|
||||
QButtonGroup* group = new QButtonGroup( this );
|
||||
group->setExclusive( true );
|
||||
group->addButton( ui->noneRadio );
|
||||
group->addButton( ui->installRadio );
|
||||
group->addButton( ui->machineRadio );
|
||||
group->addButton( ui->userRadio );
|
||||
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 "
|
||||
@ -52,17 +70,10 @@ TrackingPage::TrackingPage( QWidget* parent )
|
||||
.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 );
|
||||
group->setExclusive( true );
|
||||
group->addButton( ui->noneRadio );
|
||||
group->addButton( ui->installRadio );
|
||||
group->addButton( ui->machineRadio );
|
||||
group->addButton( ui->userRadio );
|
||||
ui->noneRadio->setChecked( true );
|
||||
.arg( product ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TrackingPage::enableTrackingOption( TrackingType t, bool enabled )
|
||||
{
|
||||
@ -154,7 +165,7 @@ TrackingPage::setTrackingPolicy( TrackingType t, QString url )
|
||||
}
|
||||
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;
|
||||
}
|
||||
else
|
||||
@ -175,7 +186,7 @@ TrackingPage::setGeneralPolicy( QString url )
|
||||
ui->generalPolicyLabel->show();
|
||||
ui->generalPolicyLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
|
||||
ui->generalPolicyLabel->show();
|
||||
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [ url ] { QDesktopServices::openUrl( url ); } );
|
||||
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [url] { QDesktopServices::openUrl( url ); } );
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +195,7 @@ TrackingPage::setTrackingLevel( TrackingType t )
|
||||
{
|
||||
QRadioButton* button = nullptr;
|
||||
|
||||
switch( t )
|
||||
switch ( t )
|
||||
{
|
||||
case TrackingType::NoTracking:
|
||||
button = ui->noneRadio;
|
||||
|
@ -29,11 +29,13 @@ namespace Ui
|
||||
class TrackingPage;
|
||||
}
|
||||
|
||||
class Config;
|
||||
|
||||
class TrackingPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrackingPage( QWidget* parent = nullptr );
|
||||
explicit TrackingPage( Config* config, QWidget* parent = nullptr );
|
||||
|
||||
/** @brief Set initial state for each option
|
||||
*
|
||||
@ -54,11 +56,15 @@ public:
|
||||
|
||||
///@brief Set URL for given level @p t
|
||||
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
|
||||
void setTrackingLevel( TrackingType t );
|
||||
|
||||
public Q_SLOTS:
|
||||
///@brief Set URL for the global link
|
||||
void setGeneralPolicy( QString url );
|
||||
|
||||
void retranslate();
|
||||
|
||||
private:
|
||||
Ui::TrackingPage* ui;
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "TrackingViewStep.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "TrackingJobs.h"
|
||||
#include "TrackingPage.h"
|
||||
|
||||
@ -43,7 +44,8 @@ isValidStyle( const QString& s )
|
||||
|
||||
TrackingViewStep::TrackingViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_widget( new TrackingPage )
|
||||
, m_config( new Config( this ) )
|
||||
, m_widget( new TrackingPage( m_config ) )
|
||||
{
|
||||
emit nextStatusChanged( false );
|
||||
}
|
||||
@ -186,9 +188,10 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
|
||||
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
||||
|
||||
m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) );
|
||||
m_config->setConfigurationMap( configurationMap );
|
||||
|
||||
bool ok;
|
||||
m_widget->setTrackingLevel( trackingNames().find(CalamaresUtils::getString( configurationMap, "default" ), ok ) );
|
||||
m_widget->setTrackingLevel( trackingNames().find( CalamaresUtils::getString( configurationMap, "default" ), ok ) );
|
||||
if ( !ok )
|
||||
{
|
||||
cWarning() << "Default tracking level unknown:" << CalamaresUtils::getString( configurationMap, "default" );
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QUrl>
|
||||
#include <QVariantMap>
|
||||
|
||||
class Config;
|
||||
class TrackingPage;
|
||||
|
||||
class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep
|
||||
@ -58,6 +59,7 @@ public:
|
||||
private:
|
||||
QVariantMap setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t );
|
||||
|
||||
Config* m_config;
|
||||
TrackingPage* m_widget;
|
||||
QString m_installTrackingUrl;
|
||||
QString m_machineTrackingStyle;
|
||||
|
Loading…
Reference in New Issue
Block a user