diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 1ad4a26db..3f3d7c718 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -28,13 +28,9 @@ #include "utils/Retranslator.h" #include "ViewManager.h" -#include -#include +#include #include -#include #include -#include -#include TrackingPage::TrackingPage(QWidget *parent) : QWidget( parent ) @@ -45,41 +41,44 @@ TrackingPage::TrackingPage(QWidget *parent) ui->setupUi( this ); CALAMARES_RETRANSLATE( ui->retranslateUi( this ); - 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 ) ); + 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 only be sent once after the installation finishes." ) ); + ui->machineExplanation->setText( tr( "By selecting this you will periodically send information about your installation, hardware and applications, to %1." ).arg( *StringEntry::ShortProductName ) ); + ui->userExplanation->setText( tr( "By selecting this you will regularly send information about your installation, hardware, applications and usage patterns, to %1." ).arg( *StringEntry::ShortProductName ) ); ) + + 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 ); } -void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) +void TrackingPage::enableTrackingOption(TrackingType t, bool enabled) { - QGroupBox* group = nullptr; - QCheckBox* check = nullptr; + QWidget* group = nullptr; switch ( t ) { case TrackingType::InstallTracking: - group = ui->installTrackingBox; - check = ui->installCheckBox; + group = ui->installGroup; break; case TrackingType::MachineTracking: - group = ui->machineTrackingBox; - check = ui->machineCheckBox; + group = ui->machineGroup; break; case TrackingType::UserTracking: - group = ui->userTrackingBox; - check = ui->userCheckBox; + group = ui->userGroup; break; } - if ( (group != nullptr) && (check != nullptr)) + if ( group != nullptr ) { - if ( setting ) + if ( enabled ) group->show(); else group->hide(); - - check->setChecked( user ); } else cDebug() << "WARNING: unknown tracking option" << int(t); @@ -87,22 +86,22 @@ void TrackingPage::setTrackingOption(TrackingType t, bool setting, bool user) bool TrackingPage::getTrackingOption(TrackingType t) { - QCheckBox* check = nullptr; + bool enabled = false; + // A tracking type is enabled if it is checked, or + // any higher level is checked. switch ( t ) { case TrackingType::InstallTracking: - check = ui->installCheckBox; - break; + enabled |= ui->installRadio->isChecked(); + // FALLTHRU case TrackingType::MachineTracking: - check = ui->machineCheckBox; - break; + enabled |= ui->machineRadio->isChecked(); + // FALLTHRU case TrackingType::UserTracking: - check = ui->userCheckBox; - break; + enabled |= ui->userRadio->isChecked(); } - - return (check != nullptr) && check->isChecked(); + return enabled; } void TrackingPage::setTrackingPolicy(TrackingType t, QString url) @@ -132,3 +131,36 @@ void TrackingPage::setTrackingPolicy(TrackingType t, QString url) else cDebug() << "WARNING: 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 ); } ); + } +} + +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 + cDebug() << "WARNING: unknown default tracking level" << l; +} diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index 8839b8598..281102897 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -39,14 +39,23 @@ public: * 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. + * + * Call this in ascending order of tracking type. */ - void setTrackingOption( TrackingType t, bool setting, bool user ); + void enableTrackingOption( TrackingType t, bool enabled ); /** - * Returns the state of the user checkbox for tracking option @p t. + * Returns whether tracking type @p is selected by the user + * (i.e. is the radio button for that level, or for a higher + * tracking level, enabled). */ bool getTrackingOption( TrackingType t ); + /* URL for given level @p t */ void setTrackingPolicy( TrackingType t, QString url ); + /* URL for the global link */ + void setGeneralPolicy( QString url ); + /* Select one of the four levels by name */ + void setTrackingLevel( const QString& level ); private: Ui::TrackingPage* ui; diff --git a/src/modules/tracking/TrackingViewStep.cpp b/src/modules/tracking/TrackingViewStep.cpp index 18a42f776..79cb69903 100644 --- a/src/modules/tracking/TrackingViewStep.cpp +++ b/src/modules/tracking/TrackingViewStep.cpp @@ -102,12 +102,12 @@ 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 )); + 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(); } @@ -141,10 +141,7 @@ TrackingViewStep::jobs() const QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t) { - cDebug() << "Tracking configuration" << key; - bool settingEnabled = false; - bool userEnabled = false; bool success = false; auto config = CalamaresUtils::getSubMap( configurationMap, key, success ); @@ -152,15 +149,13 @@ QVariantMap TrackingViewStep::setTrackingOption(const QVariantMap& configuration if ( success ) { settingEnabled = CalamaresUtils::getBool( config, "enabled", false ); - userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false ); } - cDebug() << " .. settable=" << settingEnabled << "default=" << userEnabled; TrackingEnabled& trackingConfiguration = tracking( t ); trackingConfiguration.settingEnabled = settingEnabled; - trackingConfiguration.userEnabled = userEnabled; + trackingConfiguration.userEnabled = false; - m_widget->setTrackingOption(t, settingEnabled, userEnabled); + m_widget->enableTrackingOption(t, settingEnabled); m_widget->setTrackingPolicy(t, CalamaresUtils::getString( config, "policy" ) ); return config; @@ -177,4 +172,7 @@ TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap ) setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking ); setTrackingOption( configurationMap, "user", TrackingType::UserTracking ); + + m_widget->setGeneralPolicy( CalamaresUtils::getString( configurationMap, "policy" ) ); + m_widget->setTrackingLevel( CalamaresUtils::getString( configurationMap, "default" ) ); } diff --git a/src/modules/tracking/none.png b/src/modules/tracking/none.png new file mode 100644 index 000000000..f3f2fa6bf Binary files /dev/null and b/src/modules/tracking/none.png differ diff --git a/src/modules/tracking/page_trackingstep.qrc b/src/modules/tracking/page_trackingstep.qrc index 2d430b3ae..ead294772 100644 --- a/src/modules/tracking/page_trackingstep.qrc +++ b/src/modules/tracking/page_trackingstep.qrc @@ -1,5 +1,6 @@ + none.png machine.png ../../../data/images/information.svgz binoculars.png diff --git a/src/modules/tracking/page_trackingstep.ui b/src/modules/tracking/page_trackingstep.ui index fdbbefce0..9598d4bde 100644 --- a/src/modules/tracking/page_trackingstep.ui +++ b/src/modules/tracking/page_trackingstep.ui @@ -13,230 +13,289 @@ Form - + - - - - - Install Tracking - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/tracking/phone.png - - - - - - - Placeholder text - - - Qt::RichText - - - true - - - - - - - ... - - - - :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz - - - Qt::NoArrow - - - - - - - - - Enable install-tracking - - - - - - - - - - - - Machine Tracking - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/tracking/machine.png - - - - - - - Placeholder text - - - true - - - - - - - ... - - - - :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz - - - - - - - - - Enable machine-tracking - - - - - - - - - - - - User Tracking - - - - - - - - - - - 64 - 64 - - - - - 64 - 64 - - - - - - - :/tracking/binoculars.png - - - - - - - Placeholder text - - - true - - - - - - - ... - - - - :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz - - - - - - - - - Enable user-tracking - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + + + <html><head/><body><p><span style=" font-size:16pt;">Install Tracking</span></p></body></html> + + + + + + + Placeholder + + + true + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/none.png + + + + + + + + 0 + 0 + + + + <html><head/><body><p>By selecting this, you will send <span style=" font-weight:600;">no information at all</span> about your installation.</p></body></html> + + + true + + + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/phone.png + + + + + + + + 0 + 0 + + + + TextLabel + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/machine.png + + + + + + + + 0 + 0 + + + + TextLabel + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + :/tracking/binoculars.png + + + + + + + + 0 + 0 + + + + TextLabel + + + true + + + + + + + ... + + + + :/tracking/data/images/information.svgz:/tracking/data/images/information.svgz + + + + + + + + + + <html><head/><body><p><a href="placeholder"><span style=" text-decoration: underline; color:#2980b9;">Click here for more information about Install Tracking</span></a></p></body></html> + + + Qt::RichText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + Qt::Vertical + + + + 20 + 40 + + + diff --git a/src/modules/tracking/tracking.conf b/src/modules/tracking/tracking.conf index aabb90177..84c3f553f 100644 --- a/src/modules/tracking/tracking.conf +++ b/src/modules/tracking/tracking.conf @@ -27,11 +27,9 @@ # with the appropriate framework, and the KDE User Telemetry # policy applies. # -# Each area has a key *enabled*, and a key *default*. If the area -# is enabled, it is shown to the user with a checkbox to enable -# or disable that piece of user-tracking. The default state of that -# checkbox is set to the value of *default*. Both keys default to -# "off", disabling all tracking-configuration through Calamares. +# Each area has a key *enabled*. If the area is enabled, it is shown to +# the user. This defaults to off, which means no tracking would be +# configured or enabled by Calamares. # # Each area has a key *policy*, which is a Url to be opened when # the user clicks on the corresponding Help button for an explanation @@ -41,7 +39,22 @@ # # Each area may have other configuration keys, depending on the # area and how it needs to be configured. +# +# Globally, there are two other keys: +# +# policy: (optional) url about tracking settings for this distro. +# default: (optional) level to enable by default +# --- +# This is the global policy; it is displayed as a link on the page. +# If blank or commented out, no link is displayed on the tracking +# page. It is recommended to either provide policy URLs for each +# area, *or* one general link, and not to mix them. +policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking" + +# This is the default level to enable for tracking. If commented out, +# empty, or otherwise invalid, "none" is used, so no tracking by default. +default: user # The install area has one specific configuration key: # url: this URL (remember to include the protocol, and prefer https) @@ -58,7 +71,6 @@ # module then. install: enabled: false - default: false policy: "https://github.com/calamares/calamares/wiki/Users-Guide#installation-tracking" # url: "https://example.com/install.php?c=$CPU&m=$MEMORY" @@ -69,10 +81,8 @@ install: # system to enable system-tracking. machine: enabled: false - default: false style: neon # The user area is not yet implemented, and has no specific configuration. user: enabled: false - default: false