Add status info to Summary page. Still needs work to make it nice.
Also added onActivate/onLeave to ViewStep and ViewManager.
This commit is contained in:
parent
49b91608e3
commit
c339ac8cfc
@ -148,6 +148,8 @@ ViewManager::next()
|
||||
{
|
||||
m_currentStep++;
|
||||
m_stack->setCurrentIndex( m_currentStep );
|
||||
step->onLeave();
|
||||
m_steps.at( m_currentStep )->onActivate();
|
||||
installing = m_steps.at( m_currentStep ) == m_installationViewStep;
|
||||
emit currentStepChanged();
|
||||
}
|
||||
@ -169,6 +171,8 @@ ViewManager::back()
|
||||
{
|
||||
m_currentStep--;
|
||||
m_stack->setCurrentIndex( m_currentStep );
|
||||
step->onLeave();
|
||||
m_steps.at( m_currentStep )->onActivate();
|
||||
emit currentStepChanged();
|
||||
}
|
||||
else if ( !step->isAtBeginning() )
|
||||
|
@ -25,7 +25,25 @@ ViewStep::ViewStep( QObject* parent )
|
||||
: QObject( parent )
|
||||
{}
|
||||
|
||||
|
||||
ViewStep::~ViewStep()
|
||||
{}
|
||||
|
||||
|
||||
QString
|
||||
ViewStep::prettyStatus() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ViewStep::onActivate()
|
||||
{}
|
||||
|
||||
|
||||
void
|
||||
ViewStep::onLeave()
|
||||
{}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
virtual ~ViewStep();
|
||||
|
||||
virtual QString prettyName() const = 0;
|
||||
virtual QString prettyStatus() const;
|
||||
|
||||
//TODO: we might want to make this a QSharedPointer
|
||||
virtual QWidget* widget() = 0;
|
||||
@ -47,6 +48,20 @@ public:
|
||||
virtual bool isAtBeginning() const = 0;
|
||||
virtual bool isAtEnd() const = 0;
|
||||
|
||||
/**
|
||||
* @brief onActivate called every time a ViewStep is shown, either by going forward
|
||||
* or backward.
|
||||
* The default implementation does nothing.
|
||||
*/
|
||||
virtual void onActivate();
|
||||
|
||||
/**
|
||||
* @brief onLeave called every time a ViewStep is hidden and control passes to
|
||||
* another ViewStep, either by going forward or backward.
|
||||
* The default implementation does nothing.
|
||||
*/
|
||||
virtual void onLeave();
|
||||
|
||||
virtual QList< Calamares::job_ptr > jobs() const = 0;
|
||||
|
||||
signals:
|
||||
|
@ -18,6 +18,9 @@
|
||||
|
||||
#include "SummaryPage.h"
|
||||
|
||||
#include "ViewManager.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
@ -25,8 +28,36 @@
|
||||
SummaryPage::SummaryPage( QWidget* parent )
|
||||
: QWidget()
|
||||
{
|
||||
QBoxLayout *mainLayout = new QHBoxLayout;
|
||||
QBoxLayout *mainLayout = new QVBoxLayout;
|
||||
setLayout( mainLayout );
|
||||
|
||||
mainLayout->addStretch();
|
||||
|
||||
m_label = new QLabel( this );
|
||||
mainLayout->addWidget( m_label );
|
||||
m_label->setWordWrap( true );
|
||||
|
||||
mainLayout->addStretch();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SummaryPage::onActivate()
|
||||
{
|
||||
QString text;
|
||||
foreach ( Calamares::ViewStep* step,
|
||||
Calamares::ViewManager::instance()->prepareSteps() )
|
||||
{
|
||||
//TODO: make it nice!
|
||||
if ( !step->prettyStatus().isEmpty() )
|
||||
{
|
||||
if ( !text.isEmpty() )
|
||||
text += "<br/><br/>";
|
||||
|
||||
text += "<h3>" + step->prettyName() +
|
||||
"</h3><br/>" + step->prettyStatus();
|
||||
}
|
||||
}
|
||||
|
||||
m_label->setText( text );
|
||||
}
|
||||
|
@ -21,12 +21,18 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
|
||||
class SummaryPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SummaryPage( QWidget* parent = nullptr );
|
||||
|
||||
void onActivate();
|
||||
|
||||
private:
|
||||
QLabel* m_label;
|
||||
};
|
||||
|
||||
#endif // SUMMARYPAGE_H
|
||||
|
@ -88,3 +88,10 @@ SummaryViewStep::jobs() const
|
||||
return QList< Calamares::job_ptr >();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SummaryViewStep::onActivate()
|
||||
{
|
||||
m_widget->onActivate();
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
|
||||
QList< Calamares::job_ptr > jobs() const override;
|
||||
|
||||
void onActivate() override;
|
||||
|
||||
private:
|
||||
SummaryPage* m_widget;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user