[tracking] Apply current coding style
This commit is contained in:
parent
e3ecb083a0
commit
5183200515
@ -38,22 +38,26 @@ TrackingInstallJob::~TrackingInstallJob()
|
||||
delete m_networkManager;
|
||||
}
|
||||
|
||||
QString TrackingInstallJob::prettyName() const
|
||||
QString
|
||||
TrackingInstallJob::prettyName() const
|
||||
{
|
||||
return tr( "Installation feedback" );
|
||||
}
|
||||
|
||||
QString TrackingInstallJob::prettyDescription() const
|
||||
QString
|
||||
TrackingInstallJob::prettyDescription() const
|
||||
{
|
||||
return prettyName();
|
||||
}
|
||||
|
||||
QString TrackingInstallJob::prettyStatusMessage() const
|
||||
QString
|
||||
TrackingInstallJob::prettyStatusMessage() const
|
||||
{
|
||||
return tr( "Sending installation feedback." );
|
||||
}
|
||||
|
||||
Calamares::JobResult TrackingInstallJob::exec()
|
||||
Calamares::JobResult
|
||||
TrackingInstallJob::exec()
|
||||
{
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
|
||||
@ -66,16 +70,13 @@ Calamares::JobResult TrackingInstallJob::exec()
|
||||
request.setRawHeader( "User-Agent", "Mozilla/5.0 (compatible; Calamares)" );
|
||||
|
||||
QTimer timeout;
|
||||
timeout.setSingleShot(true);
|
||||
timeout.setSingleShot( true );
|
||||
|
||||
QEventLoop loop;
|
||||
|
||||
connect( m_networkManager, &QNetworkAccessManager::finished,
|
||||
this, &TrackingInstallJob::dataIsHere );
|
||||
connect( m_networkManager, &QNetworkAccessManager::finished,
|
||||
&loop, &QEventLoop::quit );
|
||||
connect( &timeout, &QTimer::timeout,
|
||||
&loop, &QEventLoop::quit );
|
||||
connect( m_networkManager, &QNetworkAccessManager::finished, this, &TrackingInstallJob::dataIsHere );
|
||||
connect( m_networkManager, &QNetworkAccessManager::finished, &loop, &QEventLoop::quit );
|
||||
connect( &timeout, &QTimer::timeout, &loop, &QEventLoop::quit );
|
||||
|
||||
m_networkManager->get( request ); // The semaphore is released when data is received
|
||||
timeout.start( 5000 /* ms */ );
|
||||
@ -93,46 +94,52 @@ Calamares::JobResult TrackingInstallJob::exec()
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
void TrackingInstallJob::dataIsHere( QNetworkReply* reply )
|
||||
void
|
||||
TrackingInstallJob::dataIsHere( QNetworkReply* reply )
|
||||
{
|
||||
cDebug() << "Installation feedback request OK";
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
QString TrackingMachineNeonJob::prettyName() const
|
||||
QString
|
||||
TrackingMachineNeonJob::prettyName() const
|
||||
{
|
||||
return tr( "Machine feedback" );
|
||||
}
|
||||
|
||||
QString TrackingMachineNeonJob::prettyDescription() const
|
||||
QString
|
||||
TrackingMachineNeonJob::prettyDescription() const
|
||||
{
|
||||
return prettyName();
|
||||
}
|
||||
|
||||
QString TrackingMachineNeonJob::prettyStatusMessage() const
|
||||
QString
|
||||
TrackingMachineNeonJob::prettyStatusMessage() const
|
||||
{
|
||||
return tr( "Configuring machine feedback." );
|
||||
}
|
||||
|
||||
Calamares::JobResult TrackingMachineNeonJob::exec()
|
||||
Calamares::JobResult
|
||||
TrackingMachineNeonJob::exec()
|
||||
{
|
||||
int r = CalamaresUtils::System::instance()->targetEnvCall(
|
||||
"/bin/sh",
|
||||
QString(), // Working dir
|
||||
QString(
|
||||
R"x(MACHINE_ID=`cat /etc/machine-id`
|
||||
int r = CalamaresUtils::System::instance()->targetEnvCall( "/bin/sh",
|
||||
QString(), // Working dir
|
||||
QString(
|
||||
R"x(MACHINE_ID=`cat /etc/machine-id`
|
||||
sed -i "s,URI =.*,URI = http://releases.neon.kde.org/meta-release/${MACHINE_ID}," /etc/update-manager/meta-release
|
||||
sed -i "s,URI_LTS =.*,URI_LTS = http://releases.neon.kde.org/meta-release-lts/${MACHINE_ID}," /etc/update-manager/meta-release
|
||||
true
|
||||
)x"),
|
||||
std::chrono::seconds( 1 ) );
|
||||
)x" ),
|
||||
std::chrono::seconds( 1 ) );
|
||||
|
||||
if ( r == 0 )
|
||||
return Calamares::JobResult::ok();
|
||||
else if ( r > 0 )
|
||||
return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ),
|
||||
tr( "Could not configure machine feedback correctly, script error %1." ).arg( r ) );
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Error in machine feedback configuration." ),
|
||||
tr( "Could not configure machine feedback correctly, script error %1." ).arg( r ) );
|
||||
else
|
||||
return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ),
|
||||
tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) );
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Error in machine feedback configuration." ),
|
||||
tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) );
|
||||
}
|
||||
|
@ -21,18 +21,18 @@
|
||||
#include "ui_page_trackingstep.h"
|
||||
|
||||
#include "Branding.h"
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "JobQueue.h"
|
||||
#include "ViewManager.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QDesktopServices>
|
||||
#include <QLabel>
|
||||
|
||||
TrackingPage::TrackingPage(QWidget *parent)
|
||||
TrackingPage::TrackingPage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::TrackingPage )
|
||||
{
|
||||
@ -40,14 +40,22 @@ TrackingPage::TrackingPage(QWidget *parent)
|
||||
|
||||
ui->setupUi( this );
|
||||
CALAMARES_RETRANSLATE(
|
||||
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( *StringEntry::ShortProductName ) );
|
||||
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( *StringEntry::ShortProductName ) );
|
||||
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( *StringEntry::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( *StringEntry::ShortProductName ) );
|
||||
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( *StringEntry::ShortProductName ) );
|
||||
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( *StringEntry::ShortProductName ) ); )
|
||||
|
||||
QButtonGroup *group = new QButtonGroup( this );
|
||||
QButtonGroup* group = new QButtonGroup( this );
|
||||
group->setExclusive( true );
|
||||
group->addButton( ui->noneRadio );
|
||||
group->addButton( ui->installRadio );
|
||||
@ -56,114 +64,143 @@ TrackingPage::TrackingPage(QWidget *parent)
|
||||
ui->noneRadio->setChecked( true );
|
||||
}
|
||||
|
||||
void TrackingPage::enableTrackingOption(TrackingType t, bool enabled)
|
||||
void
|
||||
TrackingPage::enableTrackingOption( TrackingType t, bool enabled )
|
||||
{
|
||||
QWidget* group = nullptr;
|
||||
|
||||
switch ( t )
|
||||
{
|
||||
case TrackingType::InstallTracking:
|
||||
group = ui->installGroup;
|
||||
break;
|
||||
case TrackingType::MachineTracking:
|
||||
group = ui->machineGroup;
|
||||
break;
|
||||
case TrackingType::UserTracking:
|
||||
group = ui->userGroup;
|
||||
break;
|
||||
case TrackingType::InstallTracking:
|
||||
group = ui->installGroup;
|
||||
break;
|
||||
case TrackingType::MachineTracking:
|
||||
group = ui->machineGroup;
|
||||
break;
|
||||
case TrackingType::UserTracking:
|
||||
group = ui->userGroup;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( group != nullptr )
|
||||
{
|
||||
if ( enabled )
|
||||
{
|
||||
group->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
group->hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
cWarning() << "unknown tracking option" << int(t);
|
||||
{
|
||||
cWarning() << "unknown tracking option" << int( t );
|
||||
}
|
||||
}
|
||||
|
||||
bool TrackingPage::getTrackingOption(TrackingType t)
|
||||
bool
|
||||
TrackingPage::getTrackingOption( TrackingType t )
|
||||
{
|
||||
bool enabled = false;
|
||||
|
||||
// A tracking type is enabled if it is checked, or
|
||||
// any higher level is checked.
|
||||
#define ch(x) ui->x->isChecked()
|
||||
#define ch( x ) ui->x->isChecked()
|
||||
switch ( t )
|
||||
{
|
||||
case TrackingType::InstallTracking:
|
||||
enabled = ch(installRadio) || ch(machineRadio) || ch(userRadio);
|
||||
break;
|
||||
case TrackingType::MachineTracking:
|
||||
enabled = ch(machineRadio) || ch(userRadio);
|
||||
break;
|
||||
case TrackingType::UserTracking:
|
||||
enabled = ch(userRadio);
|
||||
break;
|
||||
case TrackingType::InstallTracking:
|
||||
enabled = ch( installRadio ) || ch( machineRadio ) || ch( userRadio );
|
||||
break;
|
||||
case TrackingType::MachineTracking:
|
||||
enabled = ch( machineRadio ) || ch( userRadio );
|
||||
break;
|
||||
case TrackingType::UserTracking:
|
||||
enabled = ch( userRadio );
|
||||
break;
|
||||
}
|
||||
#undef ch
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void TrackingPage::setTrackingPolicy(TrackingType t, QString url)
|
||||
void
|
||||
TrackingPage::setTrackingPolicy( TrackingType t, QString url )
|
||||
{
|
||||
QToolButton *button = nullptr;
|
||||
switch( t )
|
||||
QToolButton* button = nullptr;
|
||||
switch ( t )
|
||||
{
|
||||
case TrackingType::InstallTracking:
|
||||
button = ui->installPolicyButton;
|
||||
break;
|
||||
case TrackingType::MachineTracking:
|
||||
button = ui->machinePolicyButton;
|
||||
break;
|
||||
case TrackingType::UserTracking:
|
||||
button = ui->userPolicyButton;
|
||||
break;
|
||||
case TrackingType::InstallTracking:
|
||||
button = ui->installPolicyButton;
|
||||
break;
|
||||
case TrackingType::MachineTracking:
|
||||
button = ui->machinePolicyButton;
|
||||
break;
|
||||
case TrackingType::UserTracking:
|
||||
button = ui->userPolicyButton;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( button != nullptr )
|
||||
if ( url.isEmpty() )
|
||||
{
|
||||
button->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
connect( button, &QToolButton::clicked, [url]{ QDesktopServices::openUrl( url ); } );
|
||||
cDebug() << "Tracking policy" << int(t) << "set to" << url;
|
||||
connect( button, &QToolButton::clicked, [url] { QDesktopServices::openUrl( url ); } );
|
||||
cDebug() << "Tracking policy" << int( t ) << "set to" << url;
|
||||
}
|
||||
else
|
||||
cWarning() << "unknown tracking option" << int(t);
|
||||
}
|
||||
|
||||
void TrackingPage::setGeneralPolicy( QString url )
|
||||
{
|
||||
if ( url.isEmpty() )
|
||||
ui->generalPolicyLabel->hide();
|
||||
else
|
||||
{
|
||||
ui->generalPolicyLabel->show();
|
||||
ui->generalPolicyLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
ui->generalPolicyLabel->show();
|
||||
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [url]{ QDesktopServices::openUrl( url ); } );
|
||||
cWarning() << "unknown tracking option" << int( t );
|
||||
}
|
||||
}
|
||||
|
||||
void TrackingPage::setTrackingLevel(const QString& l)
|
||||
void
|
||||
TrackingPage::setGeneralPolicy( QString url )
|
||||
{
|
||||
if ( url.isEmpty() )
|
||||
{
|
||||
ui->generalPolicyLabel->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->generalPolicyLabel->show();
|
||||
ui->generalPolicyLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
|
||||
ui->generalPolicyLabel->show();
|
||||
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [url] { QDesktopServices::openUrl( url ); } );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TrackingPage::setTrackingLevel( const QString& l )
|
||||
{
|
||||
QString level = l.toLower();
|
||||
QRadioButton* button = nullptr;
|
||||
|
||||
if (level.isEmpty() || level == "none")
|
||||
if ( level.isEmpty() || level == "none" )
|
||||
{
|
||||
button = ui->noneRadio;
|
||||
else if (level == "install")
|
||||
}
|
||||
else if ( level == "install" )
|
||||
{
|
||||
button = ui->installRadio;
|
||||
else if (level == "machine")
|
||||
}
|
||||
else if ( level == "machine" )
|
||||
{
|
||||
button = ui->machineRadio;
|
||||
else if (level == "user")
|
||||
}
|
||||
else if ( level == "user" )
|
||||
{
|
||||
button = ui->userRadio;
|
||||
}
|
||||
|
||||
if ( button != nullptr )
|
||||
{
|
||||
button->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "unknown default tracking level" << l;
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
#include "TrackingType.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@ -61,4 +61,4 @@ private:
|
||||
Ui::TrackingPage* ui;
|
||||
};
|
||||
|
||||
#endif //TRACKINGPAGE_H
|
||||
#endif //TRACKINGPAGE_H
|
||||
|
@ -24,6 +24,6 @@ enum class TrackingType
|
||||
InstallTracking,
|
||||
MachineTracking,
|
||||
UserTracking
|
||||
} ;
|
||||
};
|
||||
|
||||
#endif //TRACKINGTYPE_H
|
||||
#endif //TRACKINGTYPE_H
|
||||
|
@ -21,20 +21,21 @@
|
||||
#include "TrackingJobs.h"
|
||||
#include "TrackingPage.h"
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QVariantMap>
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin<TrackingViewStep>(); )
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( TrackingViewStepFactory, registerPlugin< TrackingViewStep >(); )
|
||||
|
||||
/** @brief Is @p s a valid machine-tracking style. */
|
||||
static bool isValidStyle( const QString& s )
|
||||
static bool
|
||||
isValidStyle( const QString& s )
|
||||
{
|
||||
static QStringList knownStyles { "neon" };
|
||||
return knownStyles.contains( s );
|
||||
@ -51,7 +52,9 @@ TrackingViewStep::TrackingViewStep( QObject* parent )
|
||||
TrackingViewStep::~TrackingViewStep()
|
||||
{
|
||||
if ( m_widget && m_widget->parent() == nullptr )
|
||||
{
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -97,11 +100,12 @@ TrackingViewStep::isAtEnd() const
|
||||
}
|
||||
|
||||
|
||||
void TrackingViewStep::onLeave()
|
||||
void
|
||||
TrackingViewStep::onLeave()
|
||||
{
|
||||
m_installTracking.userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking );
|
||||
m_machineTracking.userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking );
|
||||
m_userTracking.userEnabled = m_widget->getTrackingOption( TrackingType::UserTracking );
|
||||
m_installTracking.userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking );
|
||||
m_machineTracking.userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking );
|
||||
m_userTracking.userEnabled = m_widget->getTrackingOption( TrackingType::UserTracking );
|
||||
cDebug() << "Install tracking:" << m_installTracking.enabled();
|
||||
cDebug() << "Machine tracking:" << m_machineTracking.enabled();
|
||||
cDebug() << " User tracking:" << m_userTracking.enabled();
|
||||
@ -123,10 +127,7 @@ TrackingViewStep::jobs() const
|
||||
memory.setNum( s->getTotalMemoryB().first );
|
||||
disk.setNum( s->getTotalDiskB() );
|
||||
|
||||
installUrl
|
||||
.replace( "$CPU", s->getCpuDescription() )
|
||||
.replace( "$MEMORY", memory )
|
||||
.replace( "$DISK", disk );
|
||||
installUrl.replace( "$CPU", s->getCpuDescription() ).replace( "$MEMORY", memory ).replace( "$DISK", disk );
|
||||
|
||||
cDebug() << Logger::SubEntry << "install-tracking URL" << installUrl;
|
||||
|
||||
@ -137,13 +138,16 @@ TrackingViewStep::jobs() const
|
||||
{
|
||||
Q_ASSERT( isValidStyle( m_machineTrackingStyle ) );
|
||||
if ( m_machineTrackingStyle == "neon" )
|
||||
{
|
||||
l.append( Calamares::job_ptr( new TrackingMachineNeonJob() ) );
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t)
|
||||
QVariantMap
|
||||
TrackingViewStep::setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t )
|
||||
{
|
||||
bool settingEnabled = false;
|
||||
|
||||
@ -159,8 +163,8 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration
|
||||
trackingConfiguration.settingEnabled = settingEnabled;
|
||||
trackingConfiguration.userEnabled = false;
|
||||
|
||||
m_widget->enableTrackingOption(t, settingEnabled);
|
||||
m_widget->setTrackingPolicy(t, CalamaresUtils::getString( config, "policy" ) );
|
||||
m_widget->enableTrackingOption( t, settingEnabled );
|
||||
m_widget->setTrackingPolicy( t, CalamaresUtils::getString( config, "policy" ) );
|
||||
|
||||
return config;
|
||||
}
|
||||
@ -176,7 +180,9 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
config = setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking );
|
||||
auto s = CalamaresUtils::getString( config, "style" );
|
||||
if ( isValidStyle( s ) )
|
||||
{
|
||||
m_machineTrackingStyle = s;
|
||||
}
|
||||
|
||||
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
#include "TrackingType.h"
|
||||
|
||||
#include <PluginDllMacro.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include <PluginDllMacro.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
@ -65,12 +65,13 @@ private:
|
||||
struct TrackingEnabled
|
||||
{
|
||||
bool settingEnabled; // Enabled in config file
|
||||
bool userEnabled; // User checked "yes"
|
||||
bool userEnabled; // User checked "yes"
|
||||
|
||||
TrackingEnabled()
|
||||
: settingEnabled( false )
|
||||
, userEnabled( false )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
bool enabled() const { return settingEnabled && userEnabled; }
|
||||
};
|
||||
@ -78,15 +79,21 @@ private:
|
||||
|
||||
inline TrackingEnabled& tracking( TrackingType t )
|
||||
{
|
||||
if (t == TrackingType::UserTracking)
|
||||
if ( t == TrackingType::UserTracking )
|
||||
{
|
||||
return m_userTracking;
|
||||
else if (t == TrackingType::MachineTracking)
|
||||
}
|
||||
else if ( t == TrackingType::MachineTracking )
|
||||
{
|
||||
return m_machineTracking;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_installTracking;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory )
|
||||
|
||||
#endif // TRACKINGVIEWSTEP_H
|
||||
#endif // TRACKINGVIEWSTEP_H
|
||||
|
Loading…
Reference in New Issue
Block a user