diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 93c7697b4..e6f06c3ed 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -20,6 +20,7 @@ #include "ui_page_trackingstep.h" +#include "Branding.h" #include "JobQueue.h" #include "GlobalStorage.h" #include "utils/Logger.h" @@ -39,32 +40,66 @@ TrackingPage::TrackingPage(QWidget *parent) : QWidget( parent ) , ui( new Ui::TrackingPage ) { + using StringEntry = Calamares::Branding::StringEntry; + ui->setupUi( this ); + CALAMARES_RETRANSLATE( + ui->installExplanation->setText( tr( "Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent one time only to our servers. To see what will be sent, click on the help-icon." ).arg( *StringEntry::ShortProductName ) ); + ui->machineExplanation->setText( tr( "Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software periodically to our servers. For information about the kind of information being sent, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); + ui->userExplanation->setText( tr( "User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software regularly to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon." ).arg( *StringEntry::ShortProductName ) ); + ) } -void TrackingPage::showTrackingOption(TrackingType t, bool show) +void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) { - QGroupBox *group = nullptr; + QGroupBox* group = nullptr; + QCheckBox* check = nullptr; - cDebug() << "Showing tracking option" << int(t) << show; switch ( t ) { case TrackingType::InstallTracking: group = ui->installTrackingBox; + check = ui->installCheckBox; break; case TrackingType::MachineTracking: group = ui->machineTrackingBox; + check = ui->machineCheckBox; break; case TrackingType::UserTracking: - group = ui->UserTrackingBox; + group = ui->userTrackingBox; + check = ui->userCheckBox; break; } - if ( group != nullptr ) - if ( show ) + if ( (group != nullptr) && (check != nullptr)) + { + if ( setting ) group->show(); else group->hide(); + + check->setChecked( user ); + } else cDebug() << " .. unknown option" << int(t); } + +bool TrackingPage::getTrackingOption(TrackingType t) +{ + QCheckBox* check = nullptr; + + switch ( t ) + { + case TrackingType::InstallTracking: + check = ui->installCheckBox; + break; + case TrackingType::MachineTracking: + check = ui->machineCheckBox; + break; + case TrackingType::UserTracking: + check = ui->userCheckBox; + break; + } + + return (check != nullptr) && check->isChecked(); +} diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index 791f1039d..86800c897 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -19,6 +19,8 @@ #ifndef TRACKINGPAGE_H #define TRACKINGPAGE_H +#include "TrackingType.h" + #include #include @@ -33,14 +35,16 @@ class TrackingPage : public QWidget public: explicit TrackingPage( QWidget* parent = nullptr ); - enum class TrackingType - { - InstallTracking, - MachineTracking, - UserTracking - } ; - - void showTrackingOption( TrackingType t, bool show ); + /** + * 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. + */ + void setTrackingOption( TrackingType t, bool setting, bool user ); + /** + * Returns the state of the user checkbox for tracking option @p t. + */ + bool getTrackingOption( TrackingType t ); private: Ui::TrackingPage* ui; diff --git a/src/modules/tracking/TrackingType.h b/src/modules/tracking/TrackingType.h new file mode 100644 index 000000000..01997d4d5 --- /dev/null +++ b/src/modules/tracking/TrackingType.h @@ -0,0 +1,29 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef TRACKINGTYPE_H +#define TRACKINGTYPE_H + +enum class TrackingType +{ + InstallTracking, + MachineTracking, + UserTracking +} ; + +#endif //TRACKINGTYPE_H diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 108b113c6..54ecf9e6a 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -97,6 +97,17 @@ TrackingViewStep::isAtEnd() const } +void TrackingViewStep::onLeave() +{ + cDebug() << "Install tracking:" << + (tracking( TrackingType::InstallTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::InstallTracking )); + cDebug() << "Machine tracking:" << + (tracking( TrackingType::MachineTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::MachineTracking )); + cDebug() << " User tracking:" << + (tracking( TrackingType::UserTracking ).userEnabled = m_widget->getTrackingOption( TrackingType::UserTracking )); +} + + QList< Calamares::job_ptr > TrackingViewStep::jobs() const { @@ -105,33 +116,35 @@ TrackingViewStep::jobs() const } -static -bool getTrackingEnabled( const QVariantMap& configurationMap, const QString& key, TrackingEnabled& track ) +void TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t) { cDebug() << "Tracking configuration" << key; - // Switch it off by default - track.settingEnabled = false; - track.userEnabled = false; + bool settingEnabled = false; + bool userEnabled = false; bool success = false; auto config = CalamaresUtils::getSubMap( configurationMap, key, success ); if ( success ) { - track.settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); - track.userEnabled = track.settingEnabled && CalamaresUtils::getBool( config, "default", false ); + settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); + userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false ); } - cDebug() << " .. Install tracking: enabled=" < #include #include @@ -29,12 +31,6 @@ class TrackingPage; -struct TrackingEnabled -{ - bool settingEnabled; // Enabled in config file - bool userEnabled; // User checked "yes" -}; - class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep { Q_OBJECT @@ -56,14 +52,38 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; + void onLeave() override; + QList< Calamares::job_ptr > jobs() const override; void setConfigurationMap( const QVariantMap& configurationMap ) override; private: + void setTrackingOption( const QVariantMap& configurationMap, const QString& key, TrackingType t ); + + struct TrackingEnabled + { + bool settingEnabled; // Enabled in config file + bool userEnabled; // User checked "yes" + + TrackingEnabled() + : settingEnabled( false ) + , userEnabled( false ) + {} + }; + TrackingEnabled m_installTracking, m_machineTracking, m_userTracking; + TrackingPage* m_widget; - TrackingEnabled m_installTracking, m_machineTracking, m_userTracking; + 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 ) diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index d27ff0570..9dd5aae2b 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -15,7 +15,7 @@ - + @@ -51,7 +51,7 @@ - <html><head/><body><p>Installation tracking helps %1 count how many people use it. If you enable install-tracking, at the end of the installation, information about your hardware will be sent <span style=" font-weight:600;">one time only</span> to our servers. To see what will be sent, click on the help-icon.</p></body></html> + Placeholder text Qt::RichText @@ -78,7 +78,7 @@ - + Enable install-tracking @@ -124,7 +124,7 @@ - <html><head/><body><p>Machine tracking helps %1 count how many people use it on an ongoing basis. If you enable machine-tracking, the system will send limited information about your hardware and installed software <span style=" font-weight:600;">periodically</span> to our servers. For information about the kind of information being sent, click on the help icon.</p></body></html> + Placeholder text true @@ -145,7 +145,7 @@ - + Enable machine-tracking @@ -157,7 +157,7 @@ - + User Tracking @@ -191,7 +191,7 @@ - <html><head/><body><p>User tracking helps %1 understand how people use the system and the applications. If you enable user-tracking, the system will send information about your use of the installed software <span style=" font-weight:600;">regularly</span> to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon.</p></body></html> + Placeholder text true @@ -212,7 +212,7 @@ - + Enable user-tracking @@ -223,6 +223,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + +