[tracking] Polish UI a bit

- add icons for graphical display of actions
 - extend description of tracking options
 - add debug logging
 - enable next button
 - show/hide tracking options based on configuration
This commit is contained in:
Adriaan de Groot 2017-11-06 10:12:41 -05:00
parent 806799ece4
commit 20a2465cc7
10 changed files with 228 additions and 19 deletions

View File

@ -6,6 +6,8 @@ calamares_add_plugin( tracking
TrackingPage.cpp
UI
page_trackingstep.ui
RESOURCES
page_trackingstep.qrc
LINK_PRIVATE_LIBRARIES
calamaresui
SHARED_LIB

View File

@ -42,3 +42,29 @@ TrackingPage::TrackingPage(QWidget *parent)
ui->setupUi( this );
}
void TrackingPage::showTrackingOption(TrackingType t, bool show)
{
QGroupBox *group = nullptr;
cDebug() << "Showing tracking option" << int(t) << show;
switch ( t )
{
case TrackingType::InstallTracking:
group = ui->installTrackingBox;
break;
case TrackingType::MachineTracking:
group = ui->machineTrackingBox;
break;
case TrackingType::UserTracking:
group = ui->UserTrackingBox;
break;
}
if ( group != nullptr )
if ( show )
group->show();
else
group->hide();
else
cDebug() << " .. unknown option" << int(t);
}

View File

@ -33,6 +33,15 @@ class TrackingPage : public QWidget
public:
explicit TrackingPage( QWidget* parent = nullptr );
enum class TrackingType
{
InstallTracking,
MachineTracking,
UserTracking
} ;
void showTrackingOption( TrackingType t, bool show );
private:
Ui::TrackingPage* ui;
};

View File

@ -19,6 +19,7 @@
#include "JobQueue.h"
#include "GlobalStorage.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtils.h"
#include "TrackingViewStep.h"
#include "TrackingPage.h"
@ -45,7 +46,7 @@ TrackingViewStep::~TrackingViewStep()
QString
TrackingViewStep::prettyName() const
{
return tr( "Telemetry and Tracking" );
return tr( "Telemetry" );
}
@ -71,8 +72,7 @@ TrackingViewStep::back()
bool
TrackingViewStep::isNextEnabled() const
{
// return m_widget->isNextEnabled();
return false;
return true;
}
@ -100,10 +100,38 @@ TrackingViewStep::isAtEnd() const
QList< Calamares::job_ptr >
TrackingViewStep::jobs() const
{
cDebug() << "Tracking jobs ..";
return QList< Calamares::job_ptr >();
}
static
bool getTrackingEnabled( const QVariantMap& configurationMap, const QString& key, TrackingEnabled& track )
{
cDebug() << "Tracking configuration" << key;
// Switch it off by default
track.settingEnabled = false;
track.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 );
}
cDebug() << " .. Install tracking: enabled=" <<track.settingEnabled << "default=" << track.userEnabled;
return track.settingEnabled;
}
void
TrackingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
getTrackingEnabled( configurationMap, "install", m_installTracking );
getTrackingEnabled( configurationMap, "machine", m_machineTracking );
getTrackingEnabled( configurationMap, "user", m_userTracking );
}

View File

@ -29,6 +29,12 @@
class TrackingPage;
struct TrackingEnabled
{
bool settingEnabled; // Enabled in config file
bool userEnabled; // User checked "yes"
};
class PLUGINDLLEXPORT TrackingViewStep : public Calamares::ViewStep
{
Q_OBJECT
@ -56,6 +62,8 @@ public:
private:
TrackingPage* m_widget;
TrackingEnabled m_installTracking, m_machineTracking, m_userTracking;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( TrackingViewStepFactory )

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 505 B

View File

@ -0,0 +1,8 @@
<RCC>
<qresource prefix="tracking">
<file>machine.png</file>
<file>../../../data/images/information.svgz</file>
<file>binoculars.png</file>
<file>phone.png</file>
</qresource>
</RCC>

View File

@ -25,11 +25,57 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Explanation of install-tracking.</string>
</property>
</widget>
<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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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 &lt;span style=&quot; font-weight:600;&quot;&gt;one time only&lt;/span&gt; to our servers. To see what will be sent, click on the help-icon.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<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="checkBox">
@ -52,11 +98,51 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Explanation of machine-tracking.</string>
</property>
</widget>
<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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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 &lt;span style=&quot; font-weight:600;&quot;&gt;periodically&lt;/span&gt; to our servers. For information about the kind of information being sent, click on the help icon.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_2">
<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="checkBox_2">
@ -79,11 +165,51 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Explanation of user-tracking.</string>
</property>
</widget>
<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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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 &lt;span style=&quot; font-weight:600;&quot;&gt;regularly&lt;/span&gt; to our servers. For information about the kind of information being sent and the policies that apply, click on the help icon.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_3">
<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="checkBox_3">
@ -101,6 +227,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="page_trackingstep.qrc"/>
</resources>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B