2017-08-29 14:00:37 +02:00
/* === 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/>.
*/
# include "TrackingPage.h"
# include "ui_page_trackingstep.h"
2017-11-08 10:25:36 +01:00
# include "Branding.h"
2017-08-29 14:00:37 +02:00
# include "JobQueue.h"
# include "GlobalStorage.h"
# include "utils/Logger.h"
# include "utils/CalamaresUtilsGui.h"
# include "utils/Retranslator.h"
# include "ViewManager.h"
# include <QApplication>
# include <QBoxLayout>
# include <QDesktopServices>
# include <QFocusEvent>
# include <QLabel>
# include <QComboBox>
# include <QMessageBox>
TrackingPage : : TrackingPage ( QWidget * parent )
: QWidget ( parent )
, ui ( new Ui : : TrackingPage )
{
2017-11-08 10:25:36 +01:00
using StringEntry = Calamares : : Branding : : StringEntry ;
2017-08-29 14:00:37 +02:00
ui - > setupUi ( this ) ;
2017-11-08 10:25:36 +01:00
CALAMARES_RETRANSLATE (
2017-11-08 13:46:33 +01:00
ui - > retranslateUi ( this ) ;
2017-11-08 10:25:36 +01:00
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 ) ) ;
)
2017-08-29 14:00:37 +02:00
}
2017-11-08 10:25:36 +01:00
void TrackingPage : : setTrackingOption ( TrackingType t , bool setting , bool user )
2017-11-06 16:12:41 +01:00
{
2017-11-08 10:25:36 +01:00
QGroupBox * group = nullptr ;
QCheckBox * check = nullptr ;
2017-11-06 16:12:41 +01:00
switch ( t )
{
case TrackingType : : InstallTracking :
group = ui - > installTrackingBox ;
2017-11-08 10:25:36 +01:00
check = ui - > installCheckBox ;
2017-11-06 16:12:41 +01:00
break ;
case TrackingType : : MachineTracking :
group = ui - > machineTrackingBox ;
2017-11-08 10:25:36 +01:00
check = ui - > machineCheckBox ;
2017-11-06 16:12:41 +01:00
break ;
case TrackingType : : UserTracking :
2017-11-08 10:25:36 +01:00
group = ui - > userTrackingBox ;
check = ui - > userCheckBox ;
2017-11-06 16:12:41 +01:00
break ;
}
2017-11-08 10:25:36 +01:00
if ( ( group ! = nullptr ) & & ( check ! = nullptr ) )
{
if ( setting )
2017-11-06 16:12:41 +01:00
group - > show ( ) ;
else
group - > hide ( ) ;
2017-11-08 10:25:36 +01:00
check - > setChecked ( user ) ;
}
2017-11-06 16:12:41 +01:00
else
2017-11-08 13:46:33 +01:00
cDebug ( ) < < " WARNING: unknown tracking option " < < int ( t ) ;
2017-11-06 16:12:41 +01:00
}
2017-11-08 10:25:36 +01:00
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 ( ) ;
}
2017-11-08 13:46:33 +01:00
void TrackingPage : : setTrackingPolicy ( TrackingType t , QString url )
{
QToolButton * button = nullptr ;
switch ( t )
{
case TrackingType : : InstallTracking :
button = ui - > installPolicyButton ;
break ;
case TrackingType : : MachineTracking :
button = ui - > machinePolicyButton ;
break ;
case TrackingType : : UserTracking :
button = ui - > userPolicyButton ;
break ;
}
if ( button ! = nullptr )
if ( url . isEmpty ( ) )
button - > hide ( ) ;
else
{
connect ( button , & QToolButton : : clicked , [ url ] { QDesktopServices : : openUrl ( url ) ; } ) ;
cDebug ( ) < < " Tracking policy " < < int ( t ) < < " set to " < < url ;
}
else
cDebug ( ) < < " WARNING: unknown tracking option " < < int ( t ) ;
}