From c339ac8cfc8ef0c4af1c3ad0a9e0da705bdbfff0 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Tue, 8 Jul 2014 18:24:39 +0200 Subject: [PATCH] Add status info to Summary page. Still needs work to make it nice. Also added onActivate/onLeave to ViewStep and ViewManager. --- src/libcalamaresui/ViewManager.cpp | 4 +++ src/libcalamaresui/viewpages/ViewStep.cpp | 18 +++++++++++++ src/libcalamaresui/viewpages/ViewStep.h | 15 +++++++++++ src/modules/summary/SummaryPage.cpp | 33 ++++++++++++++++++++++- src/modules/summary/SummaryPage.h | 6 +++++ src/modules/summary/SummaryViewStep.cpp | 7 +++++ src/modules/summary/SummaryViewStep.h | 2 ++ 7 files changed, 84 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 23e7abed3..6701b68a4 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -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() ) diff --git a/src/libcalamaresui/viewpages/ViewStep.cpp b/src/libcalamaresui/viewpages/ViewStep.cpp index beedfb3bd..4ee07594d 100644 --- a/src/libcalamaresui/viewpages/ViewStep.cpp +++ b/src/libcalamaresui/viewpages/ViewStep.cpp @@ -25,7 +25,25 @@ ViewStep::ViewStep( QObject* parent ) : QObject( parent ) {} + ViewStep::~ViewStep() {} + +QString +ViewStep::prettyStatus() const +{ + return QString(); +} + + +void +ViewStep::onActivate() +{} + + +void +ViewStep::onLeave() +{} + } diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index 0b464a51a..b146f9a3a 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -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: diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 4144a868a..8ef08e40b 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -18,6 +18,9 @@ #include "SummaryPage.h" +#include "ViewManager.h" +#include "viewpages/ViewStep.h" + #include #include @@ -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 += "

"; + + text += "

" + step->prettyName() + + "


" + step->prettyStatus(); + } + } + m_label->setText( text ); } diff --git a/src/modules/summary/SummaryPage.h b/src/modules/summary/SummaryPage.h index bfd105c07..86afe6958 100644 --- a/src/modules/summary/SummaryPage.h +++ b/src/modules/summary/SummaryPage.h @@ -21,12 +21,18 @@ #include +class QLabel; + class SummaryPage : public QWidget { Q_OBJECT public: explicit SummaryPage( QWidget* parent = nullptr ); + void onActivate(); + +private: + QLabel* m_label; }; #endif // SUMMARYPAGE_H diff --git a/src/modules/summary/SummaryViewStep.cpp b/src/modules/summary/SummaryViewStep.cpp index d7afca518..b70c2844d 100644 --- a/src/modules/summary/SummaryViewStep.cpp +++ b/src/modules/summary/SummaryViewStep.cpp @@ -88,3 +88,10 @@ SummaryViewStep::jobs() const return QList< Calamares::job_ptr >(); } + +void +SummaryViewStep::onActivate() +{ + m_widget->onActivate(); +} + diff --git a/src/modules/summary/SummaryViewStep.h b/src/modules/summary/SummaryViewStep.h index 832a06aec..e175c15fc 100644 --- a/src/modules/summary/SummaryViewStep.h +++ b/src/modules/summary/SummaryViewStep.h @@ -51,6 +51,8 @@ public: QList< Calamares::job_ptr > jobs() const override; + void onActivate() override; + private: SummaryPage* m_widget; };