[tracking] Switch UI to use radio buttons

Following KDE Pholio M116, switch to using a radio button; instead
of 4 individually toggle-able settings, use a "level" indicator
to select none, install, machine, user .. each of which implies
the previous levels. Each level is individually enable-able from
the distro side.
main
Adriaan de Groot 7 years ago
parent 188050a77c
commit 93052311aa

@ -28,13 +28,9 @@
#include "utils/Retranslator.h"
#include "ViewManager.h"
#include <QApplication>
#include <QBoxLayout>
#include <QButtonGroup>
#include <QDesktopServices>
#include <QFocusEvent>
#include <QLabel>
#include <QComboBox>
#include <QMessageBox>
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 <b>one time only</b> 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 <b>periodically</b> 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 <b>regularly</b> 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 <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 );
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;
}

@ -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;

@ -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" ) );
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

@ -1,5 +1,6 @@
<RCC>
<qresource prefix="tracking">
<file>none.png</file>
<file>machine.png</file>
<file>../../../data/images/information.svgz</file>
<file>binoculars.png</file>

@ -13,230 +13,289 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0,0">
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
<item>
<widget class="QGroupBox" name="installTrackingBox">
<property name="title">
<string>Install Tracking</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="installActionIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/phone.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="installExplanation">
<property name="text">
<string>Placeholder text</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="installPolicyButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="page_trackingstep.qrc">
<normaloff>:/tracking/data/images/information.svgz</normaloff>:/tracking/data/images/information.svgz</iconset>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="installCheckBox">
<property name="text">
<string>Enable install-tracking</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="machineTrackingBox">
<property name="title">
<string>Machine Tracking</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="machineActionIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/machine.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="machineExplanation">
<property name="text">
<string>Placeholder text</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="machinePolicyButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="page_trackingstep.qrc">
<normaloff>:/tracking/data/images/information.svgz</normaloff>:/tracking/data/images/information.svgz</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="machineCheckBox">
<property name="text">
<string>Enable machine-tracking</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="userTrackingBox">
<property name="title">
<string>User Tracking</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="userActionIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/binoculars.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="userExplanation">
<property name="text">
<string>Placeholder text</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="userPolicyButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="page_trackingstep.qrc">
<normaloff>:/tracking/data/images/information.svgz</normaloff>:/tracking/data/images/information.svgz</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="userCheckBox">
<property name="text">
<string>Enable user-tracking</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:16pt;&quot;&gt;Install Tracking&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="generalExplanation">
<property name="text">
<string>Placeholder</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="noneGroup" native="true">
<layout class="QHBoxLayout" name="noneLayout">
<item>
<widget class="QRadioButton" name="noneRadio">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="noneIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/none.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="noneExplanation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;By selecting this, you will send &lt;span style=&quot; font-weight:600;&quot;&gt;no information at all&lt;/span&gt; about your installation.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="installGroup" native="true">
<layout class="QHBoxLayout" name="installLayout">
<item>
<widget class="QRadioButton" name="installRadio">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="installIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/phone.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="installExplanation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="installPolicyButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="page_trackingstep.qrc">
<normaloff>:/tracking/data/images/information.svgz</normaloff>:/tracking/data/images/information.svgz</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="machineGroup" native="true">
<layout class="QHBoxLayout" name="machineLayout">
<item>
<widget class="QRadioButton" name="machineRadio">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="machineIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/machine.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="machineExplanation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="machinePolicyButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="page_trackingstep.qrc">
<normaloff>:/tracking/data/images/information.svgz</normaloff>:/tracking/data/images/information.svgz</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="userGroup" native="true">
<layout class="QHBoxLayout" name="userLayout">
<item>
<widget class="QRadioButton" name="userRadio">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="userIcon">
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="baseSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="page_trackingstep.qrc">:/tracking/binoculars.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="userExplanation">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="userPolicyButton">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="page_trackingstep.qrc">
<normaloff>:/tracking/data/images/information.svgz</normaloff>:/tracking/data/images/information.svgz</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="generalPolicyLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;placeholder&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#2980b9;&quot;&gt;Click here for more information about Install Tracking&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="openExternalLinks">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>

@ -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

Loading…
Cancel
Save