From 1d18ea264d3dd5c611ef577dba5b00fdc271d6c3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 20 Nov 2017 08:50:15 -0500 Subject: [PATCH] [libcalamaresui] Switch to using three state icons for requirements --- .../welcome/checker/CheckItemWidget.cpp | 23 ++++++++++++------- src/modules/welcome/checker/CheckItemWidget.h | 3 ++- src/modules/welcome/checker/CheckerWidget.cpp | 4 ++-- .../welcome/checker/RequirementsChecker.h | 1 + 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/modules/welcome/checker/CheckItemWidget.cpp b/src/modules/welcome/checker/CheckItemWidget.cpp index 5c0d8ec95..c0fa80a25 100644 --- a/src/modules/welcome/checker/CheckItemWidget.cpp +++ b/src/modules/welcome/checker/CheckItemWidget.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +24,15 @@ #include +static inline void setCondition( QLabel* label, CalamaresUtils::ImageType t ) +{ + label->setPixmap( CalamaresUtils::defaultPixmap( t, + CalamaresUtils::Original, + QSize( label->height(), label->height() ) ) ); +} + CheckItemWidget::CheckItemWidget( bool checked, + bool required, QWidget* parent ) : QWidget( parent ) { @@ -38,15 +47,13 @@ CheckItemWidget::CheckItemWidget( bool checked, m_textLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); if ( checked ) - m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes, - CalamaresUtils::Original, - QSize( m_iconLabel->height(), - m_iconLabel->height() ) ) ); + // Condition is satisfied + setCondition( m_iconLabel, CalamaresUtils::StatusOk ); else - m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No, - CalamaresUtils::Original, - QSize( m_iconLabel->height(), - m_iconLabel->height() ) ) ); + if ( required ) + setCondition( m_iconLabel, CalamaresUtils::StatusError ); + else + setCondition( m_iconLabel, CalamaresUtils::StatusWarning ); } diff --git a/src/modules/welcome/checker/CheckItemWidget.h b/src/modules/welcome/checker/CheckItemWidget.h index dea24712a..31164a190 100644 --- a/src/modules/welcome/checker/CheckItemWidget.h +++ b/src/modules/welcome/checker/CheckItemWidget.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +26,7 @@ class CheckItemWidget : public QWidget { Q_OBJECT public: - explicit CheckItemWidget( bool checked, + explicit CheckItemWidget( bool checked, bool required, QWidget* parent = nullptr ); void setText( const QString& text ); diff --git a/src/modules/welcome/checker/CheckerWidget.cpp b/src/modules/welcome/checker/CheckerWidget.cpp index 500ab6f85..2476847b6 100644 --- a/src/modules/welcome/checker/CheckerWidget.cpp +++ b/src/modules/welcome/checker/CheckerWidget.cpp @@ -62,7 +62,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries ) { if ( !entry.checked ) { - CheckItemWidget* ciw = new CheckItemWidget( entry.checked ); + CheckItemWidget* ciw = new CheckItemWidget( entry.checked, entry.required ); CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); ) m_entriesLayout->addWidget( ciw ); ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); @@ -182,7 +182,7 @@ CheckerWidget::showDetailsDialog( const QList< PrepareEntry >& checkEntries ) if ( entry.enumerationText().isEmpty() ) continue; - CheckItemWidget* ciw = new CheckItemWidget( entry.checked ); + CheckItemWidget* ciw = new CheckItemWidget( entry.checked, entry.required ); CALAMARES_RETRANSLATE( ciw->setText( entry.enumerationText() ); ) entriesLayout->addWidget( ciw ); ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); diff --git a/src/modules/welcome/checker/RequirementsChecker.h b/src/modules/welcome/checker/RequirementsChecker.h index f2f63f7e0..23ee39f74 100644 --- a/src/modules/welcome/checker/RequirementsChecker.h +++ b/src/modules/welcome/checker/RequirementsChecker.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2017, Teo Mrnjavac + * Copyright 2017, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by