[tracking] Simplify policy display

- Don't need an own slot for this, just connect to signals from Config
  and the label, neither of which need any state.
main
Adriaan de Groot 5 years ago
parent a7c4e2d203
commit 935f443a4d

@ -48,7 +48,20 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
group->addButton( ui->userRadio );
ui->noneRadio->setChecked( true );
connect( config, &Config::generalPolicyChanged, this, &TrackingPage::setGeneralPolicy );
// TODO: move to .ui file
ui->generalPolicyLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
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();
}
@ -76,22 +89,6 @@ TrackingPage::retranslate()
}
void
TrackingPage::setGeneralPolicy( QString url )
{
if ( url.isEmpty() )
{
ui->generalPolicyLabel->hide();
}
else
{
ui->generalPolicyLabel->show();
ui->generalPolicyLabel->setTextInteractionFlags( Qt::TextBrowserInteraction );
ui->generalPolicyLabel->show();
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [ url ] { QDesktopServices::openUrl( url ); } );
}
}
void
TrackingPage::setTrackingLevel( TrackingType t )
{

@ -41,9 +41,6 @@ public:
void setTrackingLevel( TrackingType t );
public Q_SLOTS:
///@brief Set URL for the global link
void setGeneralPolicy( QString url );
void retranslate();
private:

Loading…
Cancel
Save