[tracking] Switch out Radio for CheckBox

- The Radio's are replaced by CheckBoxes and some logic, so
  that different tracking styles can be enabled independently.
  None of the settings end up in the Config yet, though.
This commit is contained in:
Adriaan de Groot 2020-05-25 10:32:56 -04:00
parent fab3ff2c41
commit 60e12174fd
3 changed files with 55 additions and 37 deletions

View File

@ -40,13 +40,15 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
ui->setupUi( this );
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
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 );
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() );
@ -85,30 +87,35 @@ TrackingPage::retranslate()
.arg( product ) );
}
void
TrackingPage::setTrackingLevel( TrackingType t )
void TrackingPage::noneChecked(int state)
{
QRadioButton* button = nullptr;
switch ( t )
if ( state )
{
case TrackingType::NoTracking:
button = ui->noneRadio;
break;
case TrackingType::InstallTracking:
button = ui->installRadio;
break;
case TrackingType::MachineTracking:
button = ui->machineRadio;
break;
case TrackingType::UserTracking:
button = ui->userRadio;
break;
}
if ( button != nullptr )
{
button->setChecked( true );
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 );
}
}
}

View File

@ -37,12 +37,23 @@ class TrackingPage : public QWidget
public:
explicit TrackingPage( Config* config, QWidget* parent = nullptr );
///@brief Select one of the four levels by name
void setTrackingLevel( TrackingType t );
public Q_SLOTS:
void retranslate();
/** @brief When the *no tracking* checkbox is changed
*
* @p state will be non-zero when the box is checked; this
* **unchecks** all the other boxes.
*/
void noneChecked( int state );
/** @brief Some other checkbox changed
*
* This may check the *none* button if all the others are
* now unchecked.
*/
void otherChecked( int state );
private:
Ui::TrackingPage* ui;
};

View File

@ -32,7 +32,7 @@ margin-left: 2em;</string>
<widget class="QWidget" name="noneGroup" native="true">
<layout class="QHBoxLayout" name="noneLayout">
<item>
<widget class="QRadioButton" name="noneRadio">
<widget class="QCheckBox" name="noneCheckBox">
<property name="text">
<string/>
</property>
@ -83,7 +83,7 @@ margin-left: 2em;</string>
<widget class="QWidget" name="installGroup" native="true">
<layout class="QHBoxLayout" name="installLayout">
<item>
<widget class="QRadioButton" name="installRadio">
<widget class="QCheckBox" name="installCheckBox">
<property name="text">
<string/>
</property>
@ -145,7 +145,7 @@ margin-left: 2em;</string>
<widget class="QWidget" name="machineGroup" native="true">
<layout class="QHBoxLayout" name="machineLayout">
<item>
<widget class="QRadioButton" name="machineRadio">
<widget class="QCheckBox" name="machineCheckBox">
<property name="text">
<string/>
</property>
@ -207,7 +207,7 @@ margin-left: 2em;</string>
<widget class="QWidget" name="userGroup" native="true">
<layout class="QHBoxLayout" name="userLayout">
<item>
<widget class="QRadioButton" name="userRadio">
<widget class="QCheckBox" name="userCheckBox">
<property name="text">
<string/>
</property>