From 15b4660d3e60393e06b186e19e22634e9d3c1d03 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 20 Apr 2022 12:51:12 +0200 Subject: [PATCH] [welcome] Rip out rest of ResultWidget - this breaks the dialog showing details, but we'll switch that to the delegate as well. --- src/modules/welcome/CMakeLists.txt | 1 - src/modules/welcome/checker/ResultWidget.cpp | 60 ----------- src/modules/welcome/checker/ResultWidget.h | 42 -------- .../welcome/checker/ResultsListWidget.cpp | 101 +----------------- .../welcome/checker/ResultsListWidget.h | 10 -- 5 files changed, 1 insertion(+), 213 deletions(-) delete mode 100644 src/modules/welcome/checker/ResultWidget.cpp delete mode 100644 src/modules/welcome/checker/ResultWidget.h diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index 05f769224..0a8353084 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -22,7 +22,6 @@ calamares_add_plugin(welcome checker/CheckerContainer.cpp checker/GeneralRequirements.cpp checker/ResultDelegate.cpp - checker/ResultWidget.cpp checker/ResultsListWidget.cpp ${PARTMAN_SRC} WelcomeViewStep.cpp diff --git a/src/modules/welcome/checker/ResultWidget.cpp b/src/modules/welcome/checker/ResultWidget.cpp deleted file mode 100644 index 6e34a6c36..000000000 --- a/src/modules/welcome/checker/ResultWidget.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* === This file is part of Calamares - === - * - * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac - * SPDX-FileCopyrightText: 2017 Adriaan de Groot - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Calamares is Free Software: see the License-Identifier above. - * - */ - -#include "ResultWidget.h" - -#include "utils/CalamaresUtilsGui.h" -#include "utils/Logger.h" - -#include - -static inline void -setCondition( QLabel* label, CalamaresUtils::ImageType t ) -{ - label->setPixmap( - CalamaresUtils::defaultPixmap( t, CalamaresUtils::Original, QSize( label->height(), label->height() ) ) ); -} - -ResultWidget::ResultWidget( bool satisfied, bool required, QWidget* parent ) - : QWidget( parent ) -{ - QBoxLayout* mainLayout = new QHBoxLayout; - setLayout( mainLayout ); - - m_iconLabel = new QLabel( this ); - m_iconLabel->setFixedSize( CalamaresUtils::defaultIconSize() ); - m_iconLabel->setObjectName( "resultIcon" ); - mainLayout->addWidget( m_iconLabel ); - - m_textLabel = new QLabel( this ); - m_textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - m_textLabel->setObjectName( "resultText" ); - mainLayout->addWidget( m_textLabel ); - - if ( satisfied ) - { - setCondition( m_iconLabel, CalamaresUtils::StatusOk ); - } - else if ( required ) - { - setCondition( m_iconLabel, CalamaresUtils::StatusError ); - } - else - { - setCondition( m_iconLabel, CalamaresUtils::StatusWarning ); - } -} - - -void -ResultWidget::setText( const QString& text ) -{ - m_textLabel->setText( text ); -} diff --git a/src/modules/welcome/checker/ResultWidget.h b/src/modules/welcome/checker/ResultWidget.h deleted file mode 100644 index d77c0d9bb..000000000 --- a/src/modules/welcome/checker/ResultWidget.h +++ /dev/null @@ -1,42 +0,0 @@ -/* === This file is part of Calamares - === - * - * SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac - * SPDX-FileCopyrightText: 2017 Adriaan de Groot - * SPDX-License-Identifier: GPL-3.0-or-later - * - * Calamares is Free Software: see the License-Identifier above. - * - */ - -#ifndef CHECKER_RESULTWIDGET_H -#define CHECKER_RESULTWIDGET_H - -#include - -/** - * @brief Displays the results of a single check. - * - * Widget to insert into a ResultListWidget to display an iconic status - * (warning or failure when the check is not satisfied) along with - * descriptive test. - */ -class ResultWidget : public QWidget -{ - Q_OBJECT -public: - /** - * @brief Create widget with results of a check. - * - * Use setText() to set up the text of the widget. - */ - explicit ResultWidget( bool satisfied, bool required, QWidget* parent = nullptr ); - - /// @brief Set the displayed description of the check. - void setText( const QString& text ); - -private: - QLabel* m_textLabel; - QLabel* m_iconLabel; -}; - -#endif // CHECKER_RESULTWIDGET_H diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index 71f16e8bf..e1989e21d 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -27,54 +27,6 @@ #include #include -/** @brief Add widgets to @p layout for the list @p checkEntries - * - * The @p resultWidgets is filled with pointers to the widgets; - * for each entry in @p checkEntries that satisfies @p predicate, - * a widget is created, otherwise a nullptr is added instead. - * - * Adds all the widgets to the given @p layout. - * - * Afterwards, @p resultWidgets has a length equal to @p checkEntries. - */ -static void -createResultWidgets( QLayout* layout, - QList< ResultWidget* >& resultWidgets, - const Calamares::RequirementsModel& model, - std::function< bool( const Calamares::RequirementsModel&, QModelIndex ) > predicate ) -{ - resultWidgets.clear(); - resultWidgets.reserve( model.count() ); - for ( auto i = 0; i < model.count(); i++ ) - { - const auto& index = model.index( i ); - if ( !predicate( model, index ) ) - { - resultWidgets.append( nullptr ); - continue; - } - - const QString checkName = model.data( index, Calamares::RequirementsModel::Name ).toString(); - const bool is_satisfied = model.data( index, Calamares::RequirementsModel::Satisfied ).toBool(); - const bool is_mandatory = model.data( index, Calamares::RequirementsModel::Mandatory ).toBool(); - ResultWidget* ciw = new ResultWidget( is_satisfied, is_mandatory ); - ciw->setObjectName( checkName ); - - layout->addWidget( ciw ); - ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - - ciw->setAutoFillBackground( true ); - QPalette pal( ciw->palette() ); - QColor bgColor = pal.window().color(); - int bgHue = ( is_satisfied ) ? bgColor.hue() : ( is_mandatory ) ? 0 : 60; - bgColor.setHsv( bgHue, 64, bgColor.value() ); - pal.setColor( QPalette::Window, bgColor ); - ciw->setPalette( pal ); - - resultWidgets.append( ciw ); - } -} - /** @brief A "details" dialog for the results-list * * This displays the same RequirementsList as ResultsListWidget, @@ -96,7 +48,6 @@ public: private: QLabel* m_title; - QList< ResultWidget* > m_resultWidgets; ///< One widget for each entry with details available const Calamares::RequirementsModel& m_model; void retranslate(); @@ -112,12 +63,6 @@ ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model, m_title = new QLabel( this ); m_title->setObjectName( "resultDialogTitle" ); - createResultWidgets( entriesLayout, - m_resultWidgets, - model, - []( const Calamares::RequirementsModel& m, QModelIndex i ) - { return m.data( i, Calamares::RequirementsModel::HasDetails ).toBool(); } ); - QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this ); buttonBox->setObjectName( "resultDialogButtons" ); @@ -139,15 +84,6 @@ ResultsListDialog::retranslate() { m_title->setText( tr( "For best results, please ensure that this computer:" ) ); setWindowTitle( tr( "System requirements" ) ); - - for ( auto i = 0; i < m_model.count(); i++ ) - { - if ( m_resultWidgets[ i ] ) - { - m_resultWidgets[ i ]->setText( - m_model.data( m_model.index( i ), Calamares::RequirementsModel::Details ).toString() ); - } - } } @@ -198,8 +134,6 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent ) } } ); connect( m_explanation, &QLabel::linkActivated, this, &ResultsListWidget::linkClicked ); - - CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate ); } @@ -214,22 +148,6 @@ ResultsListWidget::linkClicked( const QString& link ) } } -void -ResultsListWidget::retranslate() -{ - const auto& model = *( m_config->requirementsModel() ); - // Retranslate the widgets that there **are**; - // these remain in-order relative to the model. - for ( auto i = 0; i < model.count() && i < m_resultWidgets.count(); i++ ) - { - if ( m_resultWidgets[ i ] ) - { - m_resultWidgets[ i ]->setText( - model.data( model.index( i ), Calamares::RequirementsModel::NegatedText ).toString() ); - } - } -} - void ResultsListWidget::requirementsChanged() { @@ -245,22 +163,7 @@ ResultsListWidget::requirementsChanged() auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) { return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); }; - - std::for_each( m_resultWidgets.begin(), - m_resultWidgets.end(), - []( QWidget* w ) - { - if ( w ) - { - w->deleteLater(); - } - } ); - - if ( !requirementsSatisfied ) - { - // createResultWidgets( m_entriesLayout, m_resultWidgets, *( m_config->requirementsModel() ), isUnSatisfied ); - } - else + if ( requirementsSatisfied ) { m_countdown->stop(); m_countdown->hide(); @@ -297,8 +200,6 @@ ResultsListWidget::requirementsChanged() } m_explanation->setAlignment( Qt::AlignCenter ); } - - retranslate(); } bool diff --git a/src/modules/welcome/checker/ResultsListWidget.h b/src/modules/welcome/checker/ResultsListWidget.h index 08dfe3f8b..a75748e3f 100644 --- a/src/modules/welcome/checker/ResultsListWidget.h +++ b/src/modules/welcome/checker/ResultsListWidget.h @@ -11,8 +11,6 @@ #ifndef CHECKER_RESULTSLISTWIDGET_H #define CHECKER_RESULTSLISTWIDGET_H -#include "ResultWidget.h" - #include "Config.h" #include @@ -34,8 +32,6 @@ private: /// @brief The model of requirements changed void requirementsChanged(); - void retranslate(); - /** @brief The model can be reset and re-filled, is it full yet? * * We count how many requirements we have seen; since the model @@ -49,12 +45,6 @@ private: */ bool isModelFilled(); - /** @brief A list of widgets, one per entry in the requirements model - * - * Unsatisfied entries have a non-null widget pointer, while requirements - * entries that **are** satisfied have no widget. - */ - QList< ResultWidget* > m_resultWidgets; Config* m_config = nullptr; // UI parts, which need updating when the model changes