From 935f443a4db7085e27c44c2c061d4a5cf5881ca5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 25 May 2020 05:24:20 -0400 Subject: [PATCH] [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. --- src/modules/tracking/TrackingPage.cpp | 31 ++++++++++++--------------- src/modules/tracking/TrackingPage.h | 3 --- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 82e0d99c5..000ea2002 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -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 ) { diff --git a/src/modules/tracking/TrackingPage.h b/src/modules/tracking/TrackingPage.h index ce8b87729..f63f7375c 100644 --- a/src/modules/tracking/TrackingPage.h +++ b/src/modules/tracking/TrackingPage.h @@ -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: