[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();
|
||||
|
||||
@ -70,12 +74,9 @@ Calamares::JobResult TrackingInstallJob::exec()
|
||||
|
||||
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,31 +94,35 @@ 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",
|
||||
int r = CalamaresUtils::System::instance()->targetEnvCall( "/bin/sh",
|
||||
QString(), // Working dir
|
||||
QString(
|
||||
R"x(MACHINE_ID=`cat /etc/machine-id`
|
||||
@ -130,9 +135,11 @@ true
|
||||
if ( r == 0 )
|
||||
return Calamares::JobResult::ok();
|
||||
else if ( r > 0 )
|
||||
return Calamares::JobResult::error( tr( "Error in machine feedback configuration." ),
|
||||
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." ),
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Error in machine feedback configuration." ),
|
||||
tr( "Could not configure machine feedback correctly, Calamares error %1." ).arg( r ) );
|
||||
}
|
||||
|
@ -21,12 +21,12 @@
|
||||
#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>
|
||||
@ -40,12 +40,20 @@ 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 );
|
||||
group->setExclusive( true );
|
||||
@ -56,7 +64,8 @@ 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;
|
||||
|
||||
@ -76,15 +85,22 @@ void TrackingPage::enableTrackingOption(TrackingType t, bool enabled)
|
||||
if ( group != nullptr )
|
||||
{
|
||||
if ( enabled )
|
||||
{
|
||||
group->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
group->hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "unknown tracking option" << int( t );
|
||||
}
|
||||
}
|
||||
|
||||
bool TrackingPage::getTrackingOption(TrackingType t)
|
||||
bool
|
||||
TrackingPage::getTrackingOption( TrackingType t )
|
||||
{
|
||||
bool enabled = false;
|
||||
|
||||
@ -107,7 +123,8 @@ bool TrackingPage::getTrackingOption(TrackingType t)
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void TrackingPage::setTrackingPolicy(TrackingType t, QString url)
|
||||
void
|
||||
TrackingPage::setTrackingPolicy( TrackingType t, QString url )
|
||||
{
|
||||
QToolButton* button = nullptr;
|
||||
switch ( t )
|
||||
@ -125,20 +142,27 @@ void TrackingPage::setTrackingPolicy(TrackingType t, QString url)
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "unknown tracking option" << int( t );
|
||||
}
|
||||
}
|
||||
|
||||
void TrackingPage::setGeneralPolicy( QString url )
|
||||
void
|
||||
TrackingPage::setGeneralPolicy( QString url )
|
||||
{
|
||||
if ( url.isEmpty() )
|
||||
{
|
||||
ui->generalPolicyLabel->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->generalPolicyLabel->show();
|
||||
@ -148,22 +172,35 @@ void TrackingPage::setGeneralPolicy( QString url )
|
||||
}
|
||||
}
|
||||
|
||||
void TrackingPage::setTrackingLevel(const QString& l)
|
||||
void
|
||||
TrackingPage::setTrackingLevel( const QString& l )
|
||||
{
|
||||
QString level = l.toLower();
|
||||
QRadioButton* button = nullptr;
|
||||
|
||||
if ( level.isEmpty() || level == "none" )
|
||||
{
|
||||
button = ui->noneRadio;
|
||||
}
|
||||
else if ( level == "install" )
|
||||
{
|
||||
button = ui->installRadio;
|
||||
}
|
||||
else if ( level == "machine" )
|
||||
{
|
||||
button = ui->machineRadio;
|
||||
}
|
||||
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
|
||||
{
|
||||
|
@ -21,11 +21,11 @@
|
||||
#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>
|
||||
@ -34,7 +34,8 @@
|
||||
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,8 +52,10 @@ TrackingViewStep::TrackingViewStep( QObject* parent )
|
||||
TrackingViewStep::~TrackingViewStep()
|
||||
{
|
||||
if ( m_widget && m_widget->parent() == nullptr )
|
||||
{
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
@ -97,7 +100,8 @@ 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 );
|
||||
@ -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;
|
||||
|
||||
@ -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>
|
||||
@ -70,7 +70,8 @@ private:
|
||||
TrackingEnabled()
|
||||
: settingEnabled( false )
|
||||
, userEnabled( false )
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
bool enabled() const { return settingEnabled && userEnabled; }
|
||||
};
|
||||
@ -79,12 +80,18 @@ private:
|
||||
inline TrackingEnabled& tracking( TrackingType t )
|
||||
{
|
||||
if ( t == TrackingType::UserTracking )
|
||||
{
|
||||
return m_userTracking;
|
||||
}
|
||||
else if ( t == TrackingType::MachineTracking )
|
||||
{
|
||||
return m_machineTracking;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_installTracking;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory )
|
||||
|
Loading…
Reference in New Issue
Block a user