diff --git a/src/calamares/progresstree/ProgressTreeDelegate.cpp b/src/calamares/progresstree/ProgressTreeDelegate.cpp index 5c9d472d1..20e5146da 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.cpp +++ b/src/calamares/progresstree/ProgressTreeDelegate.cpp @@ -44,19 +44,18 @@ QSize ProgressTreeDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const { - ProgressTreeModel::RowType type = - static_cast< ProgressTreeModel::RowType >( - index.data( ProgressTreeModel::ProgressTreeItemTypeRole ).toInt() ); - if ( type == ProgressTreeModel::Invalid ) + if ( !index.isValid() ) return option.rect.size(); + bool isFirstLevel = !index.parent().isValid(); + QFont font = qApp->font(); - if ( type == ProgressTreeModel::Category ) + if ( isFirstLevel ) { font.setPointSize( CAT_FONTSIZE ); } - else if ( type == ProgressTreeModel::ViewStep ) + else { font.setPointSize( VS_FONTSIZE ); } @@ -74,25 +73,21 @@ ProgressTreeDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { + bool isFirstLevel = !index.parent().isValid(); + QStyleOptionViewItemV4 opt = option; painter->save(); - ProgressTreeModel::RowType type = - static_cast< ProgressTreeModel::RowType >( - index.data( ProgressTreeModel::ProgressTreeItemTypeRole ).toInt() ); - if ( type == ProgressTreeModel::Invalid ) - return; - initStyleOption( &opt, index ); opt.text.clear(); painter->setBrush( CalamaresStyle::SIDEBAR_BACKGROUND ); painter->setPen( CalamaresStyle::SIDEBAR_TEXT ); - if ( type == ProgressTreeModel::Category ) + if ( isFirstLevel ) paintCategory( painter, opt, index ); - else if ( type == ProgressTreeModel::ViewStep ) + else paintViewStep( painter, opt, index ); painter->restore(); @@ -109,9 +104,12 @@ ProgressTreeDelegate::paintCategory( QPainter* painter, ITEM_MARGIN, ITEM_MARGIN ); + bool isCurrent = index.data( ProgressTreeModel::ProgressTreeItemCurrentRole ).toBool(); + QFont font = qApp->font(); font.setPointSize( CAT_FONTSIZE ); font.setBold( false ); + font.setUnderline( isCurrent ); // FIXME: Figure out a nicer way to highlight the current category step painter->setFont( font ); painter->drawText( textRect, index.data().toString() ); diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp index 6ac44261e..bc62d1339 100644 --- a/src/calamares/progresstree/ProgressTreeModel.cpp +++ b/src/calamares/progresstree/ProgressTreeModel.cpp @@ -136,12 +136,12 @@ ProgressTreeModel::setupModelData() CategoryItem* prepare = new CategoryItem( tr( "Prepare" ), m_rootItem ); m_rootItem->appendChild( prepare ); - foreach ( const Calamares::ViewStep* step, vm->steps() ) + foreach ( const Calamares::ViewStep* step, vm->prepareSteps() ) { prepare->appendChild( new ViewStepItem( step, prepare ) ); } - m_rootItem->appendChild( new CategoryItem( tr( "Install" ), m_rootItem ) ); + m_rootItem->appendChild( new ViewStepItem( vm->installationStep(), m_rootItem ) ); m_rootItem->appendChild( new CategoryItem( tr( "Finish" ), m_rootItem ) ); } diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index 1b2ee1430..491b41b59 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -11,6 +11,7 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES viewpages/AbstractPage.cpp viewpages/ViewStep.cpp + InstallationViewStep.cpp Settings.cpp ViewManager.cpp ) diff --git a/src/libcalamaresui/InstallationViewStep.cpp b/src/libcalamaresui/InstallationViewStep.cpp new file mode 100644 index 000000000..b6fe05437 --- /dev/null +++ b/src/libcalamaresui/InstallationViewStep.cpp @@ -0,0 +1,73 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include + +#include + +namespace Calamares +{ + +InstallationViewStep::InstallationViewStep( QObject* parent ) + : ViewStep( parent ) + , m_widget( new QLabel( "[Installation Progress]" ) ) +{ +} + +QString +InstallationViewStep::prettyName() const +{ + return tr( "Install" ); +} + +QWidget* +InstallationViewStep::widget() +{ + return m_widget; +} + + +void +InstallationViewStep::next() +{ +} + +void +InstallationViewStep::back() +{ +} + +bool +InstallationViewStep::isNextEnabled() const +{ + return false; +} + +bool +InstallationViewStep::isAtBeginning() const +{ + return false; +} + +bool +InstallationViewStep::isAtEnd() const +{ + return false; +} + +} // namespace diff --git a/src/libcalamaresui/InstallationViewStep.h b/src/libcalamaresui/InstallationViewStep.h new file mode 100644 index 000000000..cac14f53c --- /dev/null +++ b/src/libcalamaresui/InstallationViewStep.h @@ -0,0 +1,50 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef INSTALLATIONVIEWSTEP_H +#define INSTALLATIONVIEWSTEP_H + +#include + +namespace Calamares +{ + +class InstallationViewStep : public ViewStep +{ +public: + explicit InstallationViewStep( QObject* parent = nullptr ); + + QString prettyName() const override; + + QWidget* widget() override; + + void next() override; + void back() override; + + bool isNextEnabled() const override; + + bool isAtBeginning() const override; + bool isAtEnd() const override; + +private: + QWidget* m_widget; +}; + +} + +#endif /* INSTALLATIONVIEWSTEP_H */ diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 8b390149c..23e7abed3 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -19,6 +19,7 @@ #include "ViewManager.h" #include "viewpages/ViewStep.h" +#include "InstallationViewStep.h" #include #include @@ -64,6 +65,9 @@ ViewManager::ViewManager( QObject* parent ) connect( m_next, &QPushButton::clicked, this, &ViewManager::next ); connect( m_back, &QPushButton::clicked, this, &ViewManager::back ); m_back->setEnabled( false ); + + m_installationViewStep = new InstallationViewStep( this ); + insertViewStep( 0, m_installationViewStep ); } @@ -83,26 +87,41 @@ ViewManager::centralWidget() void ViewManager::addViewStep( ViewStep* step ) { - step->setParent( this ); - m_steps.append( step ); + m_prepareSteps.append( step ); + + insertViewStep( m_steps.size() - 1, step ); +} + + +void +ViewManager::insertViewStep( int before, ViewStep* step) +{ + m_steps.insert( before, step ); QLayout* layout = step->widget()->layout(); if ( layout ) { layout->setContentsMargins( 0, 0, 0, 0 ); } - m_stack->addWidget( step->widget() ); + m_stack->insertWidget( before, step->widget() ); connect( step, &ViewStep::nextStatusChanged, m_next, &QPushButton::setEnabled ); - emit currentStepChanged(); + m_stack->setCurrentIndex( 0 ); } QList< ViewStep* > -ViewManager::steps() const +ViewManager::prepareSteps() const { - return m_steps; + return m_prepareSteps; +} + + +ViewStep* +ViewManager::installationStep() const +{ + return m_installationViewStep; } @@ -124,20 +143,21 @@ void ViewManager::next() { ViewStep* step = m_steps.at( m_currentStep ); - if ( step->isAtEnd() && m_currentStep < m_steps.length() -1 ) + bool installing = false; + if ( step->isAtEnd() ) { m_currentStep++; m_stack->setCurrentIndex( m_currentStep ); + installing = m_steps.at( m_currentStep ) == m_installationViewStep; emit currentStepChanged(); } - else if ( !step->isAtEnd() ) + else { step->next(); } - else return; - m_next->setEnabled( m_steps.at( m_currentStep )->isNextEnabled() ); - m_back->setEnabled( true ); + m_next->setEnabled( !installing && m_steps.at( m_currentStep )->isNextEnabled() ); + m_back->setEnabled( !installing ); } diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index a9bd04a2c..6c47464e7 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -30,6 +30,7 @@ namespace Calamares { class ViewStep; +class InstallationViewStep; class UIDLLEXPORT ViewManager : public QObject { @@ -44,7 +45,8 @@ public: void addViewStep( ViewStep* step ); - QList< ViewStep* > steps() const; + QList< ViewStep* > prepareSteps() const; + ViewStep* installationStep() const; ViewStep* currentStep() const; int currentStepIndex() const; @@ -59,6 +61,8 @@ private: static ViewManager* s_instance; QList< ViewStep* > m_steps; + QList< ViewStep* > m_prepareSteps; + InstallationViewStep* m_installationViewStep; int m_currentStep; QWidget* m_widget; @@ -66,6 +70,8 @@ private: QPushButton* m_back; QPushButton* m_next; QPushButton* m_quit; + + void insertViewStep( int before, ViewStep* step ); }; }