[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.
main
Adriaan de Groot 5 years ago
parent fab3ff2c41
commit 60e12174fd

@ -40,13 +40,15 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
ui->setupUi( this ); ui->setupUi( this );
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate ); CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
QButtonGroup* group = new QButtonGroup( this ); ui->noneCheckBox->setChecked( true );
group->setExclusive( true ); connect( ui->noneCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::noneChecked );
group->addButton( ui->noneRadio ); connect( ui->installCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked );
group->addButton( ui->installRadio ); connect( ui->machineCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked );
group->addButton( ui->machineRadio ); connect( ui->userCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked );
group->addButton( ui->userRadio );
ui->noneRadio->setChecked( true ); 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 ) { connect( config, &Config::generalPolicyChanged, [ this ]( const QString& url ) {
this->ui->generalPolicyLabel->setVisible( !url.isEmpty() ); this->ui->generalPolicyLabel->setVisible( !url.isEmpty() );
@ -85,30 +87,35 @@ TrackingPage::retranslate()
.arg( product ) ); .arg( product ) );
} }
void TrackingPage::noneChecked(int state)
void
TrackingPage::setTrackingLevel( TrackingType t )
{ {
QRadioButton* button = nullptr; if ( state )
switch ( t )
{ {
case TrackingType::NoTracking: cDebug() << "Unchecking all due to none box";
button = ui->noneRadio; ui->installCheckBox->setChecked( false );
break; ui->machineCheckBox->setChecked( false );
case TrackingType::InstallTracking: ui->userCheckBox->setChecked( false );
button = ui->installRadio;
break;
case TrackingType::MachineTracking:
button = ui->machineRadio;
break;
case TrackingType::UserTracking:
button = ui->userRadio;
break;
} }
}
if ( button != nullptr ) void TrackingPage::otherChecked(int state)
{
cDebug() << "Other checked" << state;
if ( state )
{ {
button->setChecked( true ); // 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 );
}
} }
} }

@ -37,12 +37,23 @@ class TrackingPage : public QWidget
public: public:
explicit TrackingPage( Config* config, QWidget* parent = nullptr ); explicit TrackingPage( Config* config, QWidget* parent = nullptr );
///@brief Select one of the four levels by name
void setTrackingLevel( TrackingType t );
public Q_SLOTS: public Q_SLOTS:
void retranslate(); 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: private:
Ui::TrackingPage* ui; Ui::TrackingPage* ui;
}; };

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

Loading…
Cancel
Save