[welcome] Re-use widget creation code
- for the list, the code can be the same as for the dialog, only the predicate is different. - while here, implement retranslate() since there's no text on the list widgets otherwise.
This commit is contained in:
parent
38d58e5b16
commit
39534325e6
@ -110,9 +110,9 @@ ResultsListDialog::ResultsListDialog( QWidget* parent, const Calamares::Requirem
|
|||||||
|
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE_SLOT( &ResultsListDialog::retranslate )
|
|
||||||
|
|
||||||
connect( buttonBox, &QDialogButtonBox::clicked, this, &QDialog::close );
|
connect( buttonBox, &QDialogButtonBox::clicked, this, &QDialog::close );
|
||||||
|
|
||||||
|
CALAMARES_RETRANSLATE_SLOT( &ResultsListDialog::retranslate )
|
||||||
retranslate(); // Do it now to fill in the texts
|
retranslate(); // Do it now to fill in the texts
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,24 +171,7 @@ ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::Requirem
|
|||||||
const bool requirementsSatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isUnSatisfied );
|
const bool requirementsSatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isUnSatisfied );
|
||||||
const bool mandatorySatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isMandatoryAndUnSatisfied );
|
const bool mandatorySatisfied = std::none_of( checkEntries.begin(), checkEntries.end(), isMandatoryAndUnSatisfied );
|
||||||
|
|
||||||
for ( const auto& entry : checkEntries )
|
createResultWidgets( entriesLayout, m_resultWidgets, checkEntries, isUnSatisfied );
|
||||||
{
|
|
||||||
if ( !entry.satisfied )
|
|
||||||
{
|
|
||||||
ResultWidget* ciw = new ResultWidget( entry.satisfied, entry.mandatory );
|
|
||||||
CALAMARES_RETRANSLATE( ciw->setText( entry.negatedText() ); )
|
|
||||||
entriesLayout->addWidget( ciw );
|
|
||||||
ciw->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
||||||
ciw->setAutoFillBackground( true );
|
|
||||||
QPalette pal( ciw->palette() );
|
|
||||||
QColor bgColor = pal.window().color();
|
|
||||||
int bgHue = ( entry.satisfied ) ? bgColor.hue() : ( entry.mandatory ) ? 0 : 60;
|
|
||||||
bgColor.setHsv( bgHue, 64, bgColor.value() );
|
|
||||||
pal.setColor( QPalette::Window, bgColor );
|
|
||||||
ciw->setPalette( pal );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ( !requirementsSatisfied )
|
if ( !requirementsSatisfied )
|
||||||
{
|
{
|
||||||
@ -258,6 +241,9 @@ ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::Requirem
|
|||||||
{
|
{
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate )
|
||||||
|
retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -271,3 +257,18 @@ ResultsListWidget::linkClicked( const QString& link )
|
|||||||
dialog->deleteLater();
|
dialog->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ResultsListWidget::retranslate()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
for ( const auto& entry : m_entries )
|
||||||
|
{
|
||||||
|
if ( entry.satisfied )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
m_resultWidgets[ i ]->setText( entry.negatedText() );
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
#ifndef CHECKER_RESULTSLISTWIDGET_H
|
#ifndef CHECKER_RESULTSLISTWIDGET_H
|
||||||
#define CHECKER_RESULTSLISTWIDGET_H
|
#define CHECKER_RESULTSLISTWIDGET_H
|
||||||
|
|
||||||
|
#include "ResultWidget.h"
|
||||||
|
|
||||||
#include "modulesystem/Requirement.h"
|
#include "modulesystem/Requirement.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@ -39,6 +41,7 @@ private:
|
|||||||
|
|
||||||
QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link
|
QLabel* m_explanation = nullptr; ///< Explanatory text above the list, with link
|
||||||
const Calamares::RequirementsList& m_entries;
|
const Calamares::RequirementsList& m_entries;
|
||||||
|
QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHECKER_RESULTSLISTWIDGET_H
|
#endif // CHECKER_RESULTSLISTWIDGET_H
|
||||||
|
Loading…
Reference in New Issue
Block a user