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,
|
ProgressTreeDelegate::sizeHint( const QStyleOptionViewItem& option,
|
||||||
const QModelIndex& index ) const
|
const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
ProgressTreeModel::RowType type =
|
if ( !index.isValid() )
|
||||||
static_cast< ProgressTreeModel::RowType >(
|
|
||||||
index.data( ProgressTreeModel::ProgressTreeItemTypeRole ).toInt() );
|
|
||||||
if ( type == ProgressTreeModel::Invalid )
|
|
||||||
return option.rect.size();
|
return option.rect.size();
|
||||||
|
|
||||||
|
bool isFirstLevel = !index.parent().isValid();
|
||||||
|
|
||||||
QFont font = qApp->font();
|
QFont font = qApp->font();
|
||||||
|
|
||||||
if ( type == ProgressTreeModel::Category )
|
if ( isFirstLevel )
|
||||||
{
|
{
|
||||||
font.setPointSize( CAT_FONTSIZE );
|
font.setPointSize( CAT_FONTSIZE );
|
||||||
}
|
}
|
||||||
else if ( type == ProgressTreeModel::ViewStep )
|
else
|
||||||
{
|
{
|
||||||
font.setPointSize( VS_FONTSIZE );
|
font.setPointSize( VS_FONTSIZE );
|
||||||
}
|
}
|
||||||
@ -74,25 +73,21 @@ ProgressTreeDelegate::paint( QPainter* painter,
|
|||||||
const QStyleOptionViewItem& option,
|
const QStyleOptionViewItem& option,
|
||||||
const QModelIndex& index) const
|
const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
|
bool isFirstLevel = !index.parent().isValid();
|
||||||
|
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
ProgressTreeModel::RowType type =
|
|
||||||
static_cast< ProgressTreeModel::RowType >(
|
|
||||||
index.data( ProgressTreeModel::ProgressTreeItemTypeRole ).toInt() );
|
|
||||||
if ( type == ProgressTreeModel::Invalid )
|
|
||||||
return;
|
|
||||||
|
|
||||||
initStyleOption( &opt, index );
|
initStyleOption( &opt, index );
|
||||||
opt.text.clear();
|
opt.text.clear();
|
||||||
|
|
||||||
painter->setBrush( CalamaresStyle::SIDEBAR_BACKGROUND );
|
painter->setBrush( CalamaresStyle::SIDEBAR_BACKGROUND );
|
||||||
painter->setPen( CalamaresStyle::SIDEBAR_TEXT );
|
painter->setPen( CalamaresStyle::SIDEBAR_TEXT );
|
||||||
|
|
||||||
if ( type == ProgressTreeModel::Category )
|
if ( isFirstLevel )
|
||||||
paintCategory( painter, opt, index );
|
paintCategory( painter, opt, index );
|
||||||
else if ( type == ProgressTreeModel::ViewStep )
|
else
|
||||||
paintViewStep( painter, opt, index );
|
paintViewStep( painter, opt, index );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
@ -109,9 +104,12 @@ ProgressTreeDelegate::paintCategory( QPainter* painter,
|
|||||||
ITEM_MARGIN,
|
ITEM_MARGIN,
|
||||||
ITEM_MARGIN );
|
ITEM_MARGIN );
|
||||||
|
|
||||||
|
bool isCurrent = index.data( ProgressTreeModel::ProgressTreeItemCurrentRole ).toBool();
|
||||||
|
|
||||||
QFont font = qApp->font();
|
QFont font = qApp->font();
|
||||||
font.setPointSize( CAT_FONTSIZE );
|
font.setPointSize( CAT_FONTSIZE );
|
||||||
font.setBold( false );
|
font.setBold( false );
|
||||||
|
font.setUnderline( isCurrent ); // FIXME: Figure out a nicer way to highlight the current category step
|
||||||
painter->setFont( font );
|
painter->setFont( font );
|
||||||
|
|
||||||
painter->drawText( textRect, index.data().toString() );
|
painter->drawText( textRect, index.data().toString() );
|
||||||
|
@ -136,12 +136,12 @@ ProgressTreeModel::setupModelData()
|
|||||||
CategoryItem* prepare = new CategoryItem( tr( "Prepare" ), m_rootItem );
|
CategoryItem* prepare = new CategoryItem( tr( "Prepare" ), m_rootItem );
|
||||||
m_rootItem->appendChild( prepare );
|
m_rootItem->appendChild( prepare );
|
||||||
|
|
||||||
foreach ( const Calamares::ViewStep* step, vm->steps() )
|
foreach ( const Calamares::ViewStep* step, vm->prepareSteps() )
|
||||||
{
|
{
|
||||||
prepare->appendChild( new ViewStepItem( step, prepare ) );
|
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 ) );
|
m_rootItem->appendChild( new CategoryItem( tr( "Finish" ), m_rootItem ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ list( APPEND ${CALAMARESUI_LIBRARY_TARGET}_SOURCES
|
|||||||
viewpages/AbstractPage.cpp
|
viewpages/AbstractPage.cpp
|
||||||
viewpages/ViewStep.cpp
|
viewpages/ViewStep.cpp
|
||||||
|
|
||||||
|
InstallationViewStep.cpp
|
||||||
Settings.cpp
|
Settings.cpp
|
||||||
ViewManager.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 "ViewManager.h"
|
||||||
|
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
#include "InstallationViewStep.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@ -64,6 +65,9 @@ ViewManager::ViewManager( QObject* parent )
|
|||||||
connect( m_next, &QPushButton::clicked, this, &ViewManager::next );
|
connect( m_next, &QPushButton::clicked, this, &ViewManager::next );
|
||||||
connect( m_back, &QPushButton::clicked, this, &ViewManager::back );
|
connect( m_back, &QPushButton::clicked, this, &ViewManager::back );
|
||||||
m_back->setEnabled( false );
|
m_back->setEnabled( false );
|
||||||
|
|
||||||
|
m_installationViewStep = new InstallationViewStep( this );
|
||||||
|
insertViewStep( 0, m_installationViewStep );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,26 +87,41 @@ ViewManager::centralWidget()
|
|||||||
void
|
void
|
||||||
ViewManager::addViewStep( ViewStep* step )
|
ViewManager::addViewStep( ViewStep* step )
|
||||||
{
|
{
|
||||||
step->setParent( this );
|
m_prepareSteps.append( step );
|
||||||
m_steps.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();
|
QLayout* layout = step->widget()->layout();
|
||||||
if ( layout )
|
if ( layout )
|
||||||
{
|
{
|
||||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||||
}
|
}
|
||||||
m_stack->addWidget( step->widget() );
|
m_stack->insertWidget( before, step->widget() );
|
||||||
|
|
||||||
connect( step, &ViewStep::nextStatusChanged,
|
connect( step, &ViewStep::nextStatusChanged,
|
||||||
m_next, &QPushButton::setEnabled );
|
m_next, &QPushButton::setEnabled );
|
||||||
|
|
||||||
emit currentStepChanged();
|
m_stack->setCurrentIndex( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList< ViewStep* >
|
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()
|
ViewManager::next()
|
||||||
{
|
{
|
||||||
ViewStep* step = m_steps.at( m_currentStep );
|
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_currentStep++;
|
||||||
m_stack->setCurrentIndex( m_currentStep );
|
m_stack->setCurrentIndex( m_currentStep );
|
||||||
|
installing = m_steps.at( m_currentStep ) == m_installationViewStep;
|
||||||
emit currentStepChanged();
|
emit currentStepChanged();
|
||||||
}
|
}
|
||||||
else if ( !step->isAtEnd() )
|
else
|
||||||
{
|
{
|
||||||
step->next();
|
step->next();
|
||||||
}
|
}
|
||||||
else return;
|
|
||||||
|
|
||||||
m_next->setEnabled( m_steps.at( m_currentStep )->isNextEnabled() );
|
m_next->setEnabled( !installing && m_steps.at( m_currentStep )->isNextEnabled() );
|
||||||
m_back->setEnabled( true );
|
m_back->setEnabled( !installing );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ namespace Calamares
|
|||||||
{
|
{
|
||||||
|
|
||||||
class ViewStep;
|
class ViewStep;
|
||||||
|
class InstallationViewStep;
|
||||||
|
|
||||||
class UIDLLEXPORT ViewManager : public QObject
|
class UIDLLEXPORT ViewManager : public QObject
|
||||||
{
|
{
|
||||||
@ -44,7 +45,8 @@ public:
|
|||||||
|
|
||||||
void addViewStep( ViewStep* step );
|
void addViewStep( ViewStep* step );
|
||||||
|
|
||||||
QList< ViewStep* > steps() const;
|
QList< ViewStep* > prepareSteps() const;
|
||||||
|
ViewStep* installationStep() const;
|
||||||
ViewStep* currentStep() const;
|
ViewStep* currentStep() const;
|
||||||
int currentStepIndex() const;
|
int currentStepIndex() const;
|
||||||
|
|
||||||
@ -59,6 +61,8 @@ private:
|
|||||||
static ViewManager* s_instance;
|
static ViewManager* s_instance;
|
||||||
|
|
||||||
QList< ViewStep* > m_steps;
|
QList< ViewStep* > m_steps;
|
||||||
|
QList< ViewStep* > m_prepareSteps;
|
||||||
|
InstallationViewStep* m_installationViewStep;
|
||||||
int m_currentStep;
|
int m_currentStep;
|
||||||
|
|
||||||
QWidget* m_widget;
|
QWidget* m_widget;
|
||||||
@ -66,6 +70,8 @@ private:
|
|||||||
QPushButton* m_back;
|
QPushButton* m_back;
|
||||||
QPushButton* m_next;
|
QPushButton* m_next;
|
||||||
QPushButton* m_quit;
|
QPushButton* m_quit;
|
||||||
|
|
||||||
|
void insertViewStep( int before, ViewStep* step );
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user