Merge branch 'requirements-checking-segv'

This commit is contained in:
Adriaan de Groot 2019-02-26 06:38:20 -05:00
commit d289b1bed4
9 changed files with 91 additions and 61 deletions

13
CHANGES
View File

@ -6,16 +6,29 @@ website will have to do for older versions.
# 3.2.5 (unreleased) # # 3.2.5 (unreleased) #
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- Arnaud Ferraris
- Dan Simmons
## Core ## ## Core ##
* View modules (in C++) can now perform their own requirements-checking
to see if installation makes sense. This expands upon the existing
requirements checks in the welcome module (RAM, disk space, ..).
The checks have been made asynchronous, so that responsiveness during
requirements-checking is improved and the user has better feedback.
## Modules ## ## Modules ##
* *Partition* module: it is now possible to build without libparted. Since
KPMCore may not need this library anymore, it is a dependency that will
be dropped as soon as it is feasible. Add `-DCMAKE_DISABLE_FIND_PACKAGE_LIBPARTED=ON`
to the CMake flags to do so.
* Python modules: several modules have had translations added. This is * Python modules: several modules have had translations added. This is
usually only visible when the module runs as part of the *exec* step, usually only visible when the module runs as part of the *exec* step,
when the module's *pretty name* is displayed. In addition, error when the module's *pretty name* is displayed. In addition, error
messages are now translated. messages are now translated.
# 3.2.4 (2019-02-12) # # 3.2.4 (2019-02-12) #
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):

View File

@ -45,14 +45,17 @@ struct RequirementEntry
/// @brief name of this requirement; not shown to user and used as ID /// @brief name of this requirement; not shown to user and used as ID
QString name; QString name;
/// @brief Description of this requirement, for use in user-visible lists /// @brief Detailed description of this requirement, for use in user-visible lists
TextFunction enumerationText; TextFunction enumerationText;
/// @brief User-visible string to show that the requirement is not met /// @brief User-visible string to show that the requirement is not met, short form
TextFunction negatedText; TextFunction negatedText;
bool satisfied; bool satisfied;
bool mandatory; bool mandatory;
/// @brief Convenience to check if this entry should be shown in details dialog
bool hasDetails() const { return !enumerationText().isEmpty(); }
}; };
using RequirementsList = QList< RequirementEntry >; using RequirementsList = QList< RequirementEntry >;

View File

@ -16,8 +16,8 @@ include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
set( CHECKER_SOURCES set( CHECKER_SOURCES
checker/CheckerContainer.cpp checker/CheckerContainer.cpp
checker/CheckerWidget.cpp checker/ResultWidget.cpp
checker/CheckItemWidget.cpp checker/ResultsListWidget.cpp
checker/GeneralRequirements.cpp checker/GeneralRequirements.cpp
${PARTMAN_SRC} ${PARTMAN_SRC}
) )

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org> * Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
@ -22,17 +22,17 @@
#include "CheckerContainer.h" #include "CheckerContainer.h"
#include "CheckerWidget.h" #include "ResultsListWidget.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Retranslator.h" #include "utils/Retranslator.h"
#include "widgets/WaitingWidget.h" #include "widgets/WaitingWidget.h"
CheckerContainer::CheckerContainer(QWidget* parent) CheckerContainer::CheckerContainer( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_waitingWidget( new WaitingWidget( QString() ) ) , m_waitingWidget( new WaitingWidget( QString(), this ) )
, m_checkerWidget( new CheckerWidget() ) , m_checkerWidget( nullptr )
, m_verdict( false ) , m_verdict( false )
{ {
QBoxLayout* mainLayout = new QHBoxLayout; QBoxLayout* mainLayout = new QHBoxLayout;
@ -40,7 +40,10 @@ CheckerContainer::CheckerContainer(QWidget* parent)
CalamaresUtils::unmarginLayout( mainLayout ); CalamaresUtils::unmarginLayout( mainLayout );
mainLayout->addWidget( m_waitingWidget ); mainLayout->addWidget( m_waitingWidget );
CALAMARES_RETRANSLATE( m_waitingWidget->setText( tr( "Gathering system information..." ) ); ) CALAMARES_RETRANSLATE(
if ( m_waitingWidget )
m_waitingWidget->setText( tr( "Gathering system information..." ) );
)
} }
CheckerContainer::~CheckerContainer() CheckerContainer::~CheckerContainer()
@ -51,11 +54,13 @@ CheckerContainer::~CheckerContainer()
void CheckerContainer::requirementsComplete( bool ok ) void CheckerContainer::requirementsComplete( bool ok )
{ {
m_checkerWidget->init( m_requirements );
layout()->removeWidget( m_waitingWidget ); layout()->removeWidget( m_waitingWidget );
m_waitingWidget->deleteLater(); m_waitingWidget->deleteLater();
m_waitingWidget = nullptr; // Don't delete in destructor m_waitingWidget = nullptr; // Don't delete in destructor
m_checkerWidget->setParent( this );
m_checkerWidget = new ResultsListWidget( this );
m_checkerWidget->init( m_requirements );
layout()->addWidget( m_checkerWidget ); layout()->addWidget( m_checkerWidget );
m_verdict = ok; m_verdict = ok;

View File

@ -27,7 +27,7 @@
#include "modulesystem/Requirement.h" #include "modulesystem/Requirement.h"
class CheckerWidget; class ResultsListWidget;
class WaitingWidget; class WaitingWidget;
/** /**
@ -55,7 +55,7 @@ public slots:
protected: protected:
WaitingWidget *m_waitingWidget; WaitingWidget *m_waitingWidget;
CheckerWidget *m_checkerWidget; ResultsListWidget *m_checkerWidget;
Calamares::RequirementsList m_requirements; Calamares::RequirementsList m_requirements;
bool m_verdict; bool m_verdict;

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,7 +17,7 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "CheckItemWidget.h" #include "ResultWidget.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@ -26,14 +26,15 @@
static inline void setCondition( QLabel* label, CalamaresUtils::ImageType t ) static inline void setCondition( QLabel* label, CalamaresUtils::ImageType t )
{ {
label->setPixmap( CalamaresUtils::defaultPixmap( t, label->setPixmap(
CalamaresUtils::Original, CalamaresUtils::defaultPixmap( t,
QSize( label->height(), label->height() ) ) ); CalamaresUtils::Original,
QSize( label->height(), label->height() ) ) );
} }
CheckItemWidget::CheckItemWidget( bool checked, ResultWidget::ResultWidget( bool satisfied,
bool required, bool required,
QWidget* parent ) QWidget* parent )
: QWidget( parent ) : QWidget( parent )
{ {
QBoxLayout* mainLayout = new QHBoxLayout; QBoxLayout* mainLayout = new QHBoxLayout;
@ -46,19 +47,17 @@ CheckItemWidget::CheckItemWidget( bool checked,
mainLayout->addWidget( m_textLabel ); mainLayout->addWidget( m_textLabel );
m_textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
if ( checked ) if ( satisfied )
// Condition is satisfied
setCondition( m_iconLabel, CalamaresUtils::StatusOk ); setCondition( m_iconLabel, CalamaresUtils::StatusOk );
else if ( required )
setCondition( m_iconLabel, CalamaresUtils::StatusError );
else else
if ( required ) setCondition( m_iconLabel, CalamaresUtils::StatusWarning );
setCondition( m_iconLabel, CalamaresUtils::StatusError );
else
setCondition( m_iconLabel, CalamaresUtils::StatusWarning );
} }
void void
CheckItemWidget::setText( const QString& text ) ResultWidget::setText( const QString& text )
{ {
m_textLabel->setText( text ); m_textLabel->setText( text );
} }

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,22 +17,35 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CHECKITEMWIDGET_H #ifndef CHECKER_RESULTWIDGET_H
#define CHECKITEMWIDGET_H #define CHECKER_RESULTWIDGET_H
#include <QLabel> #include <QLabel>
class CheckItemWidget : public QWidget /**
* @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 Q_OBJECT
public: public:
explicit CheckItemWidget( bool checked, bool required, /**
QWidget* parent = nullptr ); * @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 ); void setText( const QString& text );
private: private:
QLabel* m_textLabel; QLabel* m_textLabel;
QLabel* m_iconLabel; QLabel* m_iconLabel;
}; };
#endif // CHECKITEMWIDGET_H #endif // CHECKER_RESULTWIDGET_H

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,9 +17,9 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "CheckerWidget.h" #include "ResultsListWidget.h"
#include "CheckItemWidget.h" #include "ResultWidget.h"
#include "Branding.h" #include "Branding.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
@ -33,7 +33,7 @@
#include <QLabel> #include <QLabel>
CheckerWidget::CheckerWidget( QWidget* parent ) ResultsListWidget::ResultsListWidget( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
{ {
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
@ -53,7 +53,7 @@ CheckerWidget::CheckerWidget( QWidget* parent )
void void
CheckerWidget::init( const Calamares::RequirementsList& checkEntries ) ResultsListWidget::init( const Calamares::RequirementsList& checkEntries )
{ {
bool allChecked = true; bool allChecked = true;
bool requirementsSatisfied = true; bool requirementsSatisfied = true;
@ -62,16 +62,14 @@ CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
{ {
if ( !entry.satisfied ) if ( !entry.satisfied )
{ {
CheckItemWidget* ciw = new CheckItemWidget( entry.satisfied, entry.mandatory ); ResultWidget* ciw = new ResultWidget( entry.satisfied, entry.mandatory );
CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); ) CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); )
m_entriesLayout->addWidget( ciw ); m_entriesLayout->addWidget( ciw );
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
allChecked = false; allChecked = false;
if ( entry.mandatory ) if ( entry.mandatory )
{
requirementsSatisfied = false; requirementsSatisfied = false;
}
ciw->setAutoFillBackground( true ); ciw->setAutoFillBackground( true );
QPalette pal( ciw->palette() ); QPalette pal( ciw->palette() );
pal.setColor( QPalette::Background, Qt::white ); pal.setColor( QPalette::Background, Qt::white );
@ -97,7 +95,7 @@ CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
"requirements for installing %1.<br/>" "requirements for installing %1.<br/>"
"Installation cannot continue. " "Installation cannot continue. "
"<a href=\"#details\">Details...</a>" ) "<a href=\"#details\">Details...</a>" )
.arg( *Calamares::Branding::ShortVersionedName ) ); .arg( *Calamares::Branding::ShortVersionedName ) );
) )
textLabel->setOpenExternalLinks( false ); textLabel->setOpenExternalLinks( false );
connect( textLabel, &QLabel::linkActivated, connect( textLabel, &QLabel::linkActivated,
@ -114,7 +112,7 @@ CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
"recommended requirements for installing %1.<br/>" "recommended requirements for installing %1.<br/>"
"Installation can continue, but some features " "Installation can continue, but some features "
"might be disabled." ) "might be disabled." )
.arg( *Calamares::Branding::ShortVersionedName ) ); .arg( *Calamares::Branding::ShortVersionedName ) );
) )
} }
} }
@ -122,16 +120,16 @@ CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
if ( allChecked && requirementsSatisfied ) if ( allChecked && requirementsSatisfied )
{ {
if ( !Calamares::Branding::instance()-> if ( !Calamares::Branding::instance()->
imagePath( Calamares::Branding::ProductWelcome ).isEmpty() ) imagePath( Calamares::Branding::ProductWelcome ).isEmpty() )
{ {
QPixmap theImage = QPixmap( Calamares::Branding::instance()-> QPixmap theImage = QPixmap( Calamares::Branding::instance()->
imagePath( Calamares::Branding::ProductWelcome ) ); imagePath( Calamares::Branding::ProductWelcome ) );
if ( !theImage.isNull() ) if ( !theImage.isNull() )
{ {
QLabel* imageLabel; QLabel* imageLabel;
if ( Calamares::Branding::instance()->welcomeExpandingLogo() ) if ( Calamares::Branding::instance()->welcomeExpandingLogo() )
{ {
FixedAspectRatioLabel *p = new FixedAspectRatioLabel; FixedAspectRatioLabel* p = new FixedAspectRatioLabel;
p->setPixmap( theImage ); p->setPixmap( theImage );
imageLabel = p; imageLabel = p;
} }
@ -155,14 +153,12 @@ CheckerWidget::init( const Calamares::RequirementsList& checkEntries )
) )
} }
else else
{
m_mainLayout->addStretch(); m_mainLayout->addStretch();
}
} }
void void
CheckerWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntries ) ResultsListWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntries )
{ {
QDialog* detailsDialog = new QDialog( this ); QDialog* detailsDialog = new QDialog( this );
QBoxLayout* mainLayout = new QVBoxLayout; QBoxLayout* mainLayout = new QVBoxLayout;
@ -179,10 +175,10 @@ CheckerWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntrie
for ( const auto& entry : checkEntries ) for ( const auto& entry : checkEntries )
{ {
if ( entry.enumerationText().isEmpty() ) if ( !entry.hasDetails() )
continue; continue;
CheckItemWidget* ciw = new CheckItemWidget( entry.satisfied, entry.mandatory ); ResultWidget* ciw = new ResultWidget( entry.satisfied, entry.mandatory );
CALAMARES_RETRANSLATE( ciw->setText( entry.enumerationText() ); ) CALAMARES_RETRANSLATE( ciw->setText( entry.enumerationText() ); )
entriesLayout->addWidget( ciw ); entriesLayout->addWidget( ciw );
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
@ -194,8 +190,8 @@ CheckerWidget::showDetailsDialog( const Calamares::RequirementsList& checkEntrie
} }
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close,
Qt::Horizontal, Qt::Horizontal,
this ); this );
mainLayout->addWidget( buttonBox ); mainLayout->addWidget( buttonBox );
detailsDialog->setModal( true ); detailsDialog->setModal( true );

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -16,19 +17,19 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CHECKERWIDGET_H #ifndef CHECKER_RESULTSLISTWIDGET_H
#define CHECKERWIDGET_H #define CHECKER_RESULTSLISTWIDGET_H
#include "modulesystem/Requirement.h" #include "modulesystem/Requirement.h"
#include <QBoxLayout> #include <QBoxLayout>
#include <QWidget> #include <QWidget>
class CheckerWidget : public QWidget class ResultsListWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CheckerWidget( QWidget* parent = nullptr ); explicit ResultsListWidget( QWidget* parent = nullptr );
void init( const Calamares::RequirementsList& checkEntries ); void init( const Calamares::RequirementsList& checkEntries );
@ -40,4 +41,4 @@ private:
int m_paddingSize; int m_paddingSize;
}; };
#endif // CHECKERWIDGET_H #endif // CHECKER_RESULTSLISTWIDGET_H