From b476e4b38662a8fc40e18d2471dd8c83e32ad437 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 28 Jan 2020 13:24:01 +0100 Subject: [PATCH] [welcome] Refactor link-clicking - remove intermediate lambda - rename dialog slot to one handling links in general (which now **only** does the dialog link) --- .../welcome/checker/ResultsListWidget.cpp | 26 +++++++++---------- .../welcome/checker/ResultsListWidget.h | 4 ++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index 3567ec2b0..7f68d22ff 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -159,10 +159,10 @@ ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::Requirem // Check that all are satisfied (gives warnings if not) and // all *mandatory* entries are satisfied (gives errors if not). - auto isUnSatisfied = [](const Calamares::RequirementEntry& e){ return !e.satisfied; }; - auto isMandatoryAndUnSatisfied = [](const Calamares::RequirementEntry& e){ return e.mandatory && !e.satisfied; }; - const bool requirementsSatisfied = std::none_of(checkEntries.begin(), checkEntries.end(), isUnSatisfied); - const bool mandatorySatisfied = std::none_of(checkEntries.begin(), checkEntries.end(), isMandatoryAndUnSatisfied); + auto isUnSatisfied = []( const Calamares::RequirementEntry& e ) { return !e.satisfied; }; + auto isMandatoryAndUnSatisfied = []( const Calamares::RequirementEntry& e ) { return e.mandatory && !e.satisfied; }; + const bool requirementsSatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isUnSatisfied ); + const bool mandatorySatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isMandatoryAndUnSatisfied ); for ( const auto& entry : checkEntries ) { @@ -205,12 +205,7 @@ ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::Requirem "Details..." ); textLabel->setText( message.arg( *Calamares::Branding::ShortVersionedName ) ); ) textLabel->setOpenExternalLinks( false ); - connect( textLabel, &QLabel::linkActivated, this, [this, checkEntries]( const QString& link ) { - if ( link == "#details" ) - { - showDetailsDialog( checkEntries ); - } - } ); + connect( textLabel, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked ); } else { @@ -267,9 +262,12 @@ ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::Requirem void -ResultsListWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntries ) +ResultsListWidget::linkClicked( const QString& link ) { - auto* dialog = new ResultsListDialog( this, checkEntries ); - dialog->exec(); - dialog->deleteLater(); + if ( link == "#details" ) + { + auto* dialog = new ResultsListDialog( this, m_entries ); + dialog->exec(); + dialog->deleteLater(); + } } diff --git a/src/modules/welcome/checker/ResultsListWidget.h b/src/modules/welcome/checker/ResultsListWidget.h index 8d0dcb155..4685ded9b 100644 --- a/src/modules/welcome/checker/ResultsListWidget.h +++ b/src/modules/welcome/checker/ResultsListWidget.h @@ -32,7 +32,9 @@ public: explicit ResultsListWidget( QWidget* parent, const Calamares::RequirementsList& checkEntries ); private: - void showDetailsDialog( const Calamares::RequirementsList& checkEntries ); + /// @brief A link in the explanatory text has been clicked + void linkClicked( const QString& link ); + void retranslate(); const Calamares::RequirementsList& m_entries; };