[tracking] Improve naming

- give the on-some-checkbox-state-changed slots better names
- while here, refactor is-any-actual-tracking-option-checked
- improve other debug messages, to be a whole sentence
This commit is contained in:
Adriaan de Groot 2020-06-17 10:06:33 +02:00
parent 8c4b6e4804
commit dda4ab0b2e
2 changed files with 24 additions and 17 deletions

View File

@ -41,14 +41,14 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate ); CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
ui->noneCheckBox->setChecked( true ); ui->noneCheckBox->setChecked( true );
connect( ui->noneCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::noneChecked ); connect( ui->noneCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::buttonNoneChecked );
connect( ui->installCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked ); connect( ui->installCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::buttonChecked );
connect( ui->machineCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked ); connect( ui->machineCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::buttonChecked );
connect( ui->userCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::otherChecked ); connect( ui->userCheckBox, &QCheckBox::stateChanged, this, &TrackingPage::buttonChecked );
connect( ui->installCheckBox, &QCheckBox::stateChanged, [ this ]( int s ) { cDebug() << "Checkbox install changed" << s; } ); connect( ui->installCheckBox, &QCheckBox::stateChanged, [ this ]( int s ) { cDebug() << "Checkbox install changed" << s; } );
connect( config->installTracking(), &TrackingStyleConfig::trackingChanged, [ config ]() { cDebug() << connect( config->installTracking(), &TrackingStyleConfig::trackingChanged, [ config ]() { cDebug() <<
"Install tracking changed" << config->installTracking()->isEnabled(); } ) ; "Install tracking configuration changed to " << 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() );
@ -87,20 +87,25 @@ TrackingPage::retranslate()
.arg( product ) ); .arg( product ) );
} }
void TrackingPage::noneChecked(int state) bool TrackingPage::anyOtherChecked() const
{
return ui->installCheckBox->isChecked() || ui->machineCheckBox->isChecked() || ui->userCheckBox->isChecked();
}
void TrackingPage::buttonNoneChecked(int state)
{ {
if ( state ) if ( state )
{ {
cDebug() << "Unchecking all due to none box"; cDebug() << "Unchecking all other buttons because 'None' was checked";
ui->installCheckBox->setChecked( false ); ui->installCheckBox->setChecked( false );
ui->machineCheckBox->setChecked( false ); ui->machineCheckBox->setChecked( false );
ui->userCheckBox->setChecked( false ); ui->userCheckBox->setChecked( false );
} }
} }
void TrackingPage::otherChecked(int state) void TrackingPage::buttonChecked(int state)
{ {
cDebug() << "Other checked" << state;
if ( state ) if ( state )
{ {
// Can't have none checked, if another one is // Can't have none checked, if another one is
@ -108,12 +113,7 @@ void TrackingPage::otherChecked(int state)
} }
else else
{ {
if ( ui->installCheckBox->isChecked() || ui->machineCheckBox->isChecked() || ui->userCheckBox->isChecked() ) if ( !anyOtherChecked() )
{
// One of them is still checked, leave *none* alone
;
}
else
{ {
ui->noneCheckBox->setChecked( true ); ui->noneCheckBox->setChecked( true );
} }

View File

@ -37,6 +37,13 @@ class TrackingPage : public QWidget
public: public:
explicit TrackingPage( Config* config, QWidget* parent = nullptr ); explicit TrackingPage( Config* config, QWidget* parent = nullptr );
/** @brief is any of the enable-tracking buttons checked?
*
* Returns true if any one or more of install, machine or user
* tracking is enabled.
*/
bool anyOtherChecked() const;
public Q_SLOTS: public Q_SLOTS:
void retranslate(); void retranslate();
@ -45,14 +52,14 @@ public Q_SLOTS:
* @p state will be non-zero when the box is checked; this * @p state will be non-zero when the box is checked; this
* **unchecks** all the other boxes. * **unchecks** all the other boxes.
*/ */
void noneChecked( int state ); void buttonNoneChecked( int state );
/** @brief Some other checkbox changed /** @brief Some other checkbox changed
* *
* This may check the *none* button if all the others are * This may check the *none* button if all the others are
* now unchecked. * now unchecked.
*/ */
void otherChecked( int state ); void buttonChecked( int state );
private: private:
Ui::TrackingPage* ui; Ui::TrackingPage* ui;