mirror of https://github.com/cutefishos/calamares
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.4 KiB
C++
122 lines
4.4 KiB
C++
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
*
|
|
* Copyright 2017-2018, 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 "Config.h"
|
|
#include "ui_page_trackingstep.h"
|
|
|
|
#include "Branding.h"
|
|
#include "GlobalStorage.h"
|
|
#include "JobQueue.h"
|
|
#include "ViewManager.h"
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
#include "utils/Logger.h"
|
|
#include "utils/Retranslator.h"
|
|
|
|
#include <QButtonGroup>
|
|
#include <QDesktopServices>
|
|
#include <QLabel>
|
|
|
|
TrackingPage::TrackingPage( Config* config, QWidget* parent )
|
|
: QWidget( parent )
|
|
, ui( new Ui::TrackingPage )
|
|
{
|
|
ui->setupUi( this );
|
|
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
|
|
|
|
ui->noneCheckBox->setChecked( true );
|
|
connect( ui->noneCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::noneChecked );
|
|
connect( ui->installCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked );
|
|
connect( ui->machineCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked );
|
|
connect( ui->userCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked );
|
|
|
|
connect( ui->installCheckBox, &QCheckBox::stateChanged, [ this ]( int s ) { cDebug() << "Checkbox install changed" << s; } );
|
|
connect( config->installTracking(), &TrackingStyleConfig::trackingChanged, [ config ]() { cDebug() <<
|
|
"Install tracking changed" << config->installTracking()->isEnabled(); } ) ;
|
|
|
|
connect( config, &Config::generalPolicyChanged, [ this ]( const QString& url ) {
|
|
this->ui->generalPolicyLabel->setVisible( !url.isEmpty() );
|
|
} );
|
|
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [ config ] {
|
|
QString url( config->generalPolicy() );
|
|
if ( !url.isEmpty() )
|
|
{
|
|
QDesktopServices::openUrl( url );
|
|
}
|
|
} );
|
|
|
|
retranslate();
|
|
}
|
|
|
|
void
|
|
TrackingPage::retranslate()
|
|
{
|
|
QString product = Calamares::Branding::instance()->shortProductName();
|
|
ui->retranslateUi( this );
|
|
ui->generalExplanation->setText(
|
|
tr( "Tracking helps %1 to see how often it is installed, what hardware it is installed on and "
|
|
"which applications are used. To see what "
|
|
"will be sent, please click the help icon next to each area." )
|
|
.arg( product ) );
|
|
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 machine installation, "
|
|
"hardware and applications, to %1." )
|
|
.arg( product ) );
|
|
ui->userExplanation->setText(
|
|
tr( "By selecting this you will <b>regularly</b> send information about your "
|
|
"user installation, hardware, applications and application usage patterns, to %1." )
|
|
.arg( product ) );
|
|
}
|
|
|
|
void TrackingPage::noneChecked(int state)
|
|
{
|
|
if ( state )
|
|
{
|
|
cDebug() << "Unchecking all due to none box";
|
|
ui->installCheckBox->setChecked( false );
|
|
ui->machineCheckBox->setChecked( false );
|
|
ui->userCheckBox->setChecked( false );
|
|
}
|
|
}
|
|
|
|
void TrackingPage::otherChecked(int state)
|
|
{
|
|
cDebug() << "Other checked" << state;
|
|
if ( state )
|
|
{
|
|
// Can't have none checked, if another one is
|
|
ui->noneCheckBox->setChecked( false );
|
|
}
|
|
else
|
|
{
|
|
if ( ui->installCheckBox->isChecked() || ui->machineCheckBox->isChecked() || ui->userCheckBox->isChecked() )
|
|
{
|
|
// One of them is still checked, leave *none* alone
|
|
;
|
|
}
|
|
else
|
|
{
|
|
ui->noneCheckBox->setChecked( true );
|
|
}
|
|
}
|
|
}
|