[welcome] Refactor ResultsListWidget
- no point in having init() called immediately after the constructor, if it only makes sense to have one call to init() ever to create the widget. - while here, give it the same kind of structure as the dialog, holding on to a reference to the list.
This commit is contained in:
parent
320dcac946
commit
bede280f91
@ -40,10 +40,7 @@ CheckerContainer::CheckerContainer( QWidget* parent )
|
|||||||
CalamaresUtils::unmarginLayout( mainLayout );
|
CalamaresUtils::unmarginLayout( mainLayout );
|
||||||
|
|
||||||
mainLayout->addWidget( m_waitingWidget );
|
mainLayout->addWidget( m_waitingWidget );
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE( if ( m_waitingWidget ) m_waitingWidget->setText( tr( "Gathering system information..." ) ); )
|
||||||
if ( m_waitingWidget )
|
|
||||||
m_waitingWidget->setText( tr( "Gathering system information..." ) );
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckerContainer::~CheckerContainer()
|
CheckerContainer::~CheckerContainer()
|
||||||
@ -52,32 +49,37 @@ CheckerContainer::~CheckerContainer()
|
|||||||
delete m_checkerWidget;
|
delete m_checkerWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckerContainer::requirementsComplete( bool ok )
|
void
|
||||||
|
CheckerContainer::requirementsComplete( bool ok )
|
||||||
{
|
{
|
||||||
|
|
||||||
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 = new ResultsListWidget( this );
|
m_checkerWidget = new ResultsListWidget( this, m_requirements );
|
||||||
m_checkerWidget->init( m_requirements );
|
|
||||||
layout()->addWidget( m_checkerWidget );
|
layout()->addWidget( m_checkerWidget );
|
||||||
|
|
||||||
m_verdict = ok;
|
m_verdict = ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckerContainer::requirementsChecked(const Calamares::RequirementsList& l)
|
void
|
||||||
|
CheckerContainer::requirementsChecked( const Calamares::RequirementsList& l )
|
||||||
{
|
{
|
||||||
m_requirements.append( l );
|
m_requirements.append( l );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckerContainer::requirementsProgress(const QString& message)
|
void
|
||||||
|
CheckerContainer::requirementsProgress( const QString& message )
|
||||||
{
|
{
|
||||||
if ( m_waitingWidget )
|
if ( m_waitingWidget )
|
||||||
|
{
|
||||||
m_waitingWidget->setText( message );
|
m_waitingWidget->setText( message );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckerContainer::verdict() const
|
bool
|
||||||
|
CheckerContainer::verdict() const
|
||||||
{
|
{
|
||||||
return m_verdict;
|
return m_verdict;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,9 @@ ResultsListDialog::retranslate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ResultsListWidget::ResultsListWidget( QWidget* parent )
|
ResultsListWidget::ResultsListWidget( QWidget* parent, const Calamares::RequirementsList& checkEntries )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
|
, m_entries( checkEntries )
|
||||||
{
|
{
|
||||||
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||||
|
|
||||||
@ -143,12 +144,7 @@ ResultsListWidget::ResultsListWidget( QWidget* parent )
|
|||||||
spacerLayout->addLayout( m_entriesLayout );
|
spacerLayout->addLayout( m_entriesLayout );
|
||||||
spacerLayout->addSpacing( paddingSize );
|
spacerLayout->addSpacing( paddingSize );
|
||||||
CalamaresUtils::unmarginLayout( spacerLayout );
|
CalamaresUtils::unmarginLayout( spacerLayout );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ResultsListWidget::init( const Calamares::RequirementsList& checkEntries )
|
|
||||||
{
|
|
||||||
bool allChecked = true;
|
bool allChecked = true;
|
||||||
bool requirementsSatisfied = true;
|
bool requirementsSatisfied = true;
|
||||||
|
|
||||||
|
@ -29,15 +29,14 @@ class ResultsListWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ResultsListWidget( QWidget* parent = nullptr );
|
explicit ResultsListWidget( QWidget* parent, const Calamares::RequirementsList& checkEntries );
|
||||||
|
|
||||||
void init( const Calamares::RequirementsList& checkEntries );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showDetailsDialog( const Calamares::RequirementsList& checkEntries );
|
void showDetailsDialog( const Calamares::RequirementsList& checkEntries );
|
||||||
|
|
||||||
QBoxLayout* m_mainLayout;
|
QBoxLayout* m_mainLayout;
|
||||||
QBoxLayout* m_entriesLayout;
|
QBoxLayout* m_entriesLayout;
|
||||||
|
const Calamares::RequirementsList& m_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHECKER_RESULTSLISTWIDGET_H
|
#endif // CHECKER_RESULTSLISTWIDGET_H
|
||||||
|
Loading…
Reference in New Issue
Block a user