[welcome] Rip out rest of ResultWidget
- this breaks the dialog showing details, but we'll switch that to the delegate as well.
This commit is contained in:
parent
e457d099d8
commit
15b4660d3e
@ -22,7 +22,6 @@ calamares_add_plugin(welcome
|
|||||||
checker/CheckerContainer.cpp
|
checker/CheckerContainer.cpp
|
||||||
checker/GeneralRequirements.cpp
|
checker/GeneralRequirements.cpp
|
||||||
checker/ResultDelegate.cpp
|
checker/ResultDelegate.cpp
|
||||||
checker/ResultWidget.cpp
|
|
||||||
checker/ResultsListWidget.cpp
|
checker/ResultsListWidget.cpp
|
||||||
${PARTMAN_SRC}
|
${PARTMAN_SRC}
|
||||||
WelcomeViewStep.cpp
|
WelcomeViewStep.cpp
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
|
||||||
*
|
|
||||||
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
|
|
||||||
* SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
|
||||||
* 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 <QBoxLayout>
|
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
|
||||||
*
|
|
||||||
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
|
|
||||||
* SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
|
|
||||||
* 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 <QLabel>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
@ -27,54 +27,6 @@
|
|||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
/** @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
|
/** @brief A "details" dialog for the results-list
|
||||||
*
|
*
|
||||||
* This displays the same RequirementsList as ResultsListWidget,
|
* This displays the same RequirementsList as ResultsListWidget,
|
||||||
@ -96,7 +48,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel* m_title;
|
QLabel* m_title;
|
||||||
QList< ResultWidget* > m_resultWidgets; ///< One widget for each entry with details available
|
|
||||||
const Calamares::RequirementsModel& m_model;
|
const Calamares::RequirementsModel& m_model;
|
||||||
|
|
||||||
void retranslate();
|
void retranslate();
|
||||||
@ -112,12 +63,6 @@ ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model,
|
|||||||
m_title = new QLabel( this );
|
m_title = new QLabel( this );
|
||||||
m_title->setObjectName( "resultDialogTitle" );
|
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 );
|
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this );
|
||||||
buttonBox->setObjectName( "resultDialogButtons" );
|
buttonBox->setObjectName( "resultDialogButtons" );
|
||||||
|
|
||||||
@ -139,15 +84,6 @@ ResultsListDialog::retranslate()
|
|||||||
{
|
{
|
||||||
m_title->setText( tr( "For best results, please ensure that this computer:" ) );
|
m_title->setText( tr( "For best results, please ensure that this computer:" ) );
|
||||||
setWindowTitle( tr( "System requirements" ) );
|
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 );
|
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
|
void
|
||||||
ResultsListWidget::requirementsChanged()
|
ResultsListWidget::requirementsChanged()
|
||||||
{
|
{
|
||||||
@ -245,22 +163,7 @@ ResultsListWidget::requirementsChanged()
|
|||||||
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i )
|
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i )
|
||||||
{ return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); };
|
{ return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); };
|
||||||
|
|
||||||
|
if ( requirementsSatisfied )
|
||||||
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
|
|
||||||
{
|
{
|
||||||
m_countdown->stop();
|
m_countdown->stop();
|
||||||
m_countdown->hide();
|
m_countdown->hide();
|
||||||
@ -297,8 +200,6 @@ ResultsListWidget::requirementsChanged()
|
|||||||
}
|
}
|
||||||
m_explanation->setAlignment( Qt::AlignCenter );
|
m_explanation->setAlignment( Qt::AlignCenter );
|
||||||
}
|
}
|
||||||
|
|
||||||
retranslate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#ifndef CHECKER_RESULTSLISTWIDGET_H
|
#ifndef CHECKER_RESULTSLISTWIDGET_H
|
||||||
#define CHECKER_RESULTSLISTWIDGET_H
|
#define CHECKER_RESULTSLISTWIDGET_H
|
||||||
|
|
||||||
#include "ResultWidget.h"
|
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@ -34,8 +32,6 @@ private:
|
|||||||
/// @brief The model of requirements changed
|
/// @brief The model of requirements changed
|
||||||
void requirementsChanged();
|
void requirementsChanged();
|
||||||
|
|
||||||
void retranslate();
|
|
||||||
|
|
||||||
/** @brief The model can be reset and re-filled, is it full yet?
|
/** @brief The model can be reset and re-filled, is it full yet?
|
||||||
*
|
*
|
||||||
* We count how many requirements we have seen; since the model
|
* We count how many requirements we have seen; since the model
|
||||||
@ -49,12 +45,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool isModelFilled();
|
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;
|
Config* m_config = nullptr;
|
||||||
|
|
||||||
// UI parts, which need updating when the model changes
|
// UI parts, which need updating when the model changes
|
||||||
|
Loading…
Reference in New Issue
Block a user