Show an InstallationStep at the end of the preparation process
This commit is contained in:
parent
023ed99aca
commit
cb6a25c2ce
@ -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() );
|
||||
|
@ -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 ) );
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES
|
||||
viewpages/AbstractPage.cpp
|
||||
viewpages/ViewStep.cpp
|
||||
|
||||
InstallationViewStep.cpp
|
||||
Settings.cpp
|
||||
ViewManager.cpp
|
||||
)
|
||||
|
73
src/libcalamaresui/InstallationViewStep.cpp
Normal file
73
src/libcalamaresui/InstallationViewStep.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <InstallationViewStep.h>
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
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
|
50
src/libcalamaresui/InstallationViewStep.h
Normal file
50
src/libcalamaresui/InstallationViewStep.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INSTALLATIONVIEWSTEP_H
|
||||
#define INSTALLATIONVIEWSTEP_H
|
||||
|
||||
#include <viewpages/ViewStep.h>
|
||||
|
||||
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 */
|
@ -19,6 +19,7 @@
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "InstallationViewStep.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 );
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user