[tracking] Polish UI some more
- Enable translations, substitute ShortProductName into string, - Simplify code for enabling tracking option blocks, - Set checkboxes based on configuration, - Read checkboxes when leaving page, - Don't stretch the tracking option blocks.
This commit is contained in:
parent
20a2465cc7
commit
c7120277ca
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "ui_page_trackingstep.h"
|
#include "ui_page_trackingstep.h"
|
||||||
|
|
||||||
|
#include "Branding.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
@ -39,32 +40,66 @@ TrackingPage::TrackingPage(QWidget *parent)
|
|||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::TrackingPage )
|
, ui( new Ui::TrackingPage )
|
||||||
{
|
{
|
||||||
|
using StringEntry = Calamares::Branding::StringEntry;
|
||||||
|
|
||||||
ui->setupUi( this );
|
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 <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 ) );
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
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 )
|
switch ( t )
|
||||||
{
|
{
|
||||||
case TrackingType::InstallTracking:
|
case TrackingType::InstallTracking:
|
||||||
group = ui->installTrackingBox;
|
group = ui->installTrackingBox;
|
||||||
|
check = ui->installCheckBox;
|
||||||
break;
|
break;
|
||||||
case TrackingType::MachineTracking:
|
case TrackingType::MachineTracking:
|
||||||
group = ui->machineTrackingBox;
|
group = ui->machineTrackingBox;
|
||||||
|
check = ui->machineCheckBox;
|
||||||
break;
|
break;
|
||||||
case TrackingType::UserTracking:
|
case TrackingType::UserTracking:
|
||||||
group = ui->UserTrackingBox;
|
group = ui->userTrackingBox;
|
||||||
|
check = ui->userCheckBox;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( group != nullptr )
|
if ( (group != nullptr) && (check != nullptr))
|
||||||
if ( show )
|
{
|
||||||
|
if ( setting )
|
||||||
group->show();
|
group->show();
|
||||||
else
|
else
|
||||||
group->hide();
|
group->hide();
|
||||||
|
|
||||||
|
check->setChecked( user );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
cDebug() << " .. unknown option" << int(t);
|
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();
|
||||||
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#ifndef TRACKINGPAGE_H
|
#ifndef TRACKINGPAGE_H
|
||||||
#define TRACKINGPAGE_H
|
#define TRACKINGPAGE_H
|
||||||
|
|
||||||
|
#include "TrackingType.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
@ -33,14 +35,16 @@ class TrackingPage : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit TrackingPage( QWidget* parent = nullptr );
|
explicit TrackingPage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
enum class TrackingType
|
/**
|
||||||
{
|
* Enables or disables the tracking-option block for the given
|
||||||
InstallTracking,
|
* tracking option @p t, and sets the initial state of the
|
||||||
MachineTracking,
|
* checkbox to the @p user default.
|
||||||
UserTracking
|
*/
|
||||||
} ;
|
void setTrackingOption( TrackingType t, bool setting, bool user );
|
||||||
|
/**
|
||||||
void showTrackingOption( TrackingType t, bool show );
|
* Returns the state of the user checkbox for tracking option @p t.
|
||||||
|
*/
|
||||||
|
bool getTrackingOption( TrackingType t );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::TrackingPage* ui;
|
Ui::TrackingPage* ui;
|
||||||
|
29
src/modules/tracking/TrackingType.h
Normal file
29
src/modules/tracking/TrackingType.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TRACKINGTYPE_H
|
||||||
|
#define TRACKINGTYPE_H
|
||||||
|
|
||||||
|
enum class TrackingType
|
||||||
|
{
|
||||||
|
InstallTracking,
|
||||||
|
MachineTracking,
|
||||||
|
UserTracking
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#endif //TRACKINGTYPE_H
|
@ -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 >
|
QList< Calamares::job_ptr >
|
||||||
TrackingViewStep::jobs() const
|
TrackingViewStep::jobs() const
|
||||||
{
|
{
|
||||||
@ -105,33 +116,35 @@ TrackingViewStep::jobs() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
void TrackingViewStep::setTrackingOption(const QVariantMap& configurationMap, const QString& key, TrackingType t)
|
||||||
bool getTrackingEnabled( const QVariantMap& configurationMap, const QString& key, TrackingEnabled& track )
|
|
||||||
{
|
{
|
||||||
cDebug() << "Tracking configuration" << key;
|
cDebug() << "Tracking configuration" << key;
|
||||||
|
|
||||||
// Switch it off by default
|
bool settingEnabled = false;
|
||||||
track.settingEnabled = false;
|
bool userEnabled = false;
|
||||||
track.userEnabled = false;
|
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
auto config = CalamaresUtils::getSubMap( configurationMap, key, success );
|
auto config = CalamaresUtils::getSubMap( configurationMap, key, success );
|
||||||
|
|
||||||
if ( success )
|
if ( success )
|
||||||
{
|
{
|
||||||
track.settingEnabled = CalamaresUtils::getBool( config, "enabled", false );
|
settingEnabled = CalamaresUtils::getBool( config, "enabled", false );
|
||||||
track.userEnabled = track.settingEnabled && CalamaresUtils::getBool( config, "default", false );
|
userEnabled = settingEnabled && CalamaresUtils::getBool( config, "default", false );
|
||||||
}
|
}
|
||||||
cDebug() << " .. Install tracking: enabled=" <<track.settingEnabled << "default=" << track.userEnabled;
|
cDebug() << " .. Install tracking: enabled=" << settingEnabled << "default=" << userEnabled;
|
||||||
|
|
||||||
return track.settingEnabled;
|
auto trackingConfiguration = tracking( t );
|
||||||
|
trackingConfiguration.settingEnabled = settingEnabled;
|
||||||
|
trackingConfiguration.userEnabled = userEnabled;
|
||||||
|
|
||||||
|
m_widget->setTrackingOption(t, settingEnabled, userEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
getTrackingEnabled( configurationMap, "install", m_installTracking );
|
setTrackingOption( configurationMap, "install", TrackingType::InstallTracking );
|
||||||
getTrackingEnabled( configurationMap, "machine", m_machineTracking );
|
setTrackingOption( configurationMap, "machine", TrackingType::MachineTracking );
|
||||||
getTrackingEnabled( configurationMap, "user", m_userTracking );
|
setTrackingOption( configurationMap, "user", TrackingType::UserTracking );
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#ifndef TRACKINGVIEWSTEP_H
|
#ifndef TRACKINGVIEWSTEP_H
|
||||||
#define TRACKINGVIEWSTEP_H
|
#define TRACKINGVIEWSTEP_H
|
||||||
|
|
||||||
|
#include "TrackingType.h"
|
||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
#include <PluginDllMacro.h>
|
#include <PluginDllMacro.h>
|
||||||
@ -29,12 +31,6 @@
|
|||||||
|
|
||||||
class TrackingPage;
|
class TrackingPage;
|
||||||
|
|
||||||
struct TrackingEnabled
|
|
||||||
{
|
|
||||||
bool settingEnabled; // Enabled in config file
|
|
||||||
bool userEnabled; // User checked "yes"
|
|
||||||
};
|
|
||||||
|
|
||||||
class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep
|
class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -56,14 +52,38 @@ public:
|
|||||||
bool isAtBeginning() const override;
|
bool isAtBeginning() const override;
|
||||||
bool isAtEnd() const override;
|
bool isAtEnd() const override;
|
||||||
|
|
||||||
|
void onLeave() override;
|
||||||
|
|
||||||
QList< Calamares::job_ptr > jobs() const override;
|
QList< Calamares::job_ptr > jobs() const override;
|
||||||
|
|
||||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
private:
|
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;
|
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 )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory )
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="installTrackingBox">
|
<widget class="QGroupBox" name="installTrackingBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@ -51,7 +51,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="installExplanation">
|
<widget class="QLabel" name="installExplanation">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><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></string>
|
<string>Placeholder text</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::RichText</enum>
|
<enum>Qt::RichText</enum>
|
||||||
@ -78,7 +78,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox">
|
<widget class="QCheckBox" name="installCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable install-tracking</string>
|
<string>Enable install-tracking</string>
|
||||||
</property>
|
</property>
|
||||||
@ -124,7 +124,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="machineExplanation">
|
<widget class="QLabel" name="machineExplanation">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><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></string>
|
<string>Placeholder text</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -145,7 +145,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_2">
|
<widget class="QCheckBox" name="machineCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable machine-tracking</string>
|
<string>Enable machine-tracking</string>
|
||||||
</property>
|
</property>
|
||||||
@ -157,7 +157,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="UserTrackingBox">
|
<widget class="QGroupBox" name="userTrackingBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>User Tracking</string>
|
<string>User Tracking</string>
|
||||||
</property>
|
</property>
|
||||||
@ -191,7 +191,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="userExplanation">
|
<widget class="QLabel" name="userExplanation">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><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></string>
|
<string>Placeholder text</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -212,7 +212,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBox_3">
|
<widget class="QCheckBox" name="userCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable user-tracking</string>
|
<string>Enable user-tracking</string>
|
||||||
</property>
|
</property>
|
||||||
@ -223,6 +223,19 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user