diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt
index 4d11469de..b618c6418 100644
--- a/src/calamares/CMakeLists.txt
+++ b/src/calamares/CMakeLists.txt
@@ -11,11 +11,11 @@ set( calamaresSources
CalamaresApplication.cpp
CalamaresWindow.cpp
- progresstree/CategoryItem.cpp
progresstree/ProgressTreeDelegate.cpp
progresstree/ProgressTreeItem.cpp
progresstree/ProgressTreeModel.cpp
progresstree/ProgressTreeView.cpp
+ progresstree/TextTreeItem.cpp
progresstree/ViewStepItem.cpp
)
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/ProgressTreeItem.cpp b/src/calamares/progresstree/ProgressTreeItem.cpp
index 5d0dd9789..9ab84d1e5 100644
--- a/src/calamares/progresstree/ProgressTreeItem.cpp
+++ b/src/calamares/progresstree/ProgressTreeItem.cpp
@@ -86,8 +86,6 @@ ProgressTreeRoot::ProgressTreeRoot()
QVariant
ProgressTreeRoot::data( int role ) const
{
- if ( role == ProgressTreeModel::ProgressTreeItemTypeRole )
- return ProgressTreeModel::Invalid;
if ( role == ProgressTreeModel::ProgressTreeItemRole )
return this;
return QVariant();
diff --git a/src/calamares/progresstree/ProgressTreeModel.cpp b/src/calamares/progresstree/ProgressTreeModel.cpp
index 6ac44261e..bece777bb 100644
--- a/src/calamares/progresstree/ProgressTreeModel.cpp
+++ b/src/calamares/progresstree/ProgressTreeModel.cpp
@@ -18,7 +18,7 @@
#include "ProgressTreeModel.h"
-#include "progresstree/CategoryItem.h"
+#include "progresstree/TextTreeItem.h"
#include "progresstree/ViewStepItem.h"
#include "ViewManager.h"
@@ -133,16 +133,16 @@ ProgressTreeModel::setupModelData()
m_rootItem = new ProgressTreeRoot();
const Calamares::ViewManager* vm = Calamares::ViewManager::instance();
- CategoryItem* prepare = new CategoryItem( tr( "Prepare" ), m_rootItem );
+ TextTreeItem* prepare = new TextTreeItem( 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 CategoryItem( tr( "Finish" ), m_rootItem ) );
+ m_rootItem->appendChild( new ViewStepItem( vm->installationStep(), m_rootItem ) );
+ m_rootItem->appendChild( new TextTreeItem( tr( "Finish" ), m_rootItem ) );
}
diff --git a/src/calamares/progresstree/ProgressTreeModel.h b/src/calamares/progresstree/ProgressTreeModel.h
index fade29de3..e37242220 100644
--- a/src/calamares/progresstree/ProgressTreeModel.h
+++ b/src/calamares/progresstree/ProgressTreeModel.h
@@ -28,18 +28,10 @@ class ProgressTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
- enum RowType
- {
- Invalid = -1,
- Category = 0,
- ViewStep = 1
- };
-
enum Role
{
ProgressTreeItemRole = Qt::UserRole + 10,
- ProgressTreeItemTypeRole = Qt::UserRole + 11,
- ProgressTreeItemCurrentRole = Qt::UserRole + 12
+ ProgressTreeItemCurrentRole = Qt::UserRole + 11
};
explicit ProgressTreeModel( QObject* parent = nullptr );
diff --git a/src/calamares/progresstree/CategoryItem.cpp b/src/calamares/progresstree/TextTreeItem.cpp
similarity index 82%
rename from src/calamares/progresstree/CategoryItem.cpp
rename to src/calamares/progresstree/TextTreeItem.cpp
index 396849815..16a7a41eb 100644
--- a/src/calamares/progresstree/CategoryItem.cpp
+++ b/src/calamares/progresstree/TextTreeItem.cpp
@@ -16,21 +16,19 @@
* along with Calamares. If not, see .
*/
-#include "CategoryItem.h"
+#include "TextTreeItem.h"
#include "ProgressTreeModel.h"
-CategoryItem::CategoryItem( const QString& text, ProgressTreeItem* parent )
+TextTreeItem::TextTreeItem( const QString& text, ProgressTreeItem* parent )
: ProgressTreeItem( parent )
, m_text( text )
{}
QVariant
-CategoryItem::data( int role ) const
+TextTreeItem::data( int role ) const
{
- if ( role == ProgressTreeModel::ProgressTreeItemTypeRole )
- return ProgressTreeModel::Category;
if ( role == ProgressTreeModel::ProgressTreeItemRole )
return this;
if ( role == Qt::DisplayRole )
diff --git a/src/calamares/progresstree/CategoryItem.h b/src/calamares/progresstree/TextTreeItem.h
similarity index 83%
rename from src/calamares/progresstree/CategoryItem.h
rename to src/calamares/progresstree/TextTreeItem.h
index d15e55d02..ba69b34b2 100644
--- a/src/calamares/progresstree/CategoryItem.h
+++ b/src/calamares/progresstree/TextTreeItem.h
@@ -16,16 +16,16 @@
* along with Calamares. If not, see .
*/
-#ifndef CATEGORYITEM_H
-#define CATEGORYITEM_H
+#ifndef TEXTTREEITEM_H
+#define TEXTTREEITEM_H
#include "ProgressTreeItem.h"
-class CategoryItem : public ProgressTreeItem
+class TextTreeItem : public ProgressTreeItem
{
public:
- explicit CategoryItem( const QString& text, ProgressTreeItem* parent = nullptr );
+ explicit TextTreeItem( const QString& text, ProgressTreeItem* parent = nullptr );
virtual QVariant data( int role ) const override;
@@ -33,4 +33,4 @@ private:
QString m_text;
};
-#endif // CATEGORYITEM_H
+#endif // TEXTTREEITEM_H
diff --git a/src/calamares/progresstree/ViewStepItem.cpp b/src/calamares/progresstree/ViewStepItem.cpp
index 6310e8589..b056cdaa5 100644
--- a/src/calamares/progresstree/ViewStepItem.cpp
+++ b/src/calamares/progresstree/ViewStepItem.cpp
@@ -40,8 +40,6 @@ ViewStepItem::appendChild( ProgressTreeItem* item )
QVariant
ViewStepItem::data( int role ) const
{
- if ( role == ProgressTreeModel::ProgressTreeItemTypeRole )
- return ProgressTreeModel::ViewStep;
if ( role == ProgressTreeModel::ProgressTreeItemRole )
return this;
if ( role == Qt::DisplayRole )
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..851218423
--- /dev/null
+++ b/src/libcalamaresui/InstallationViewStep.cpp
@@ -0,0 +1,79 @@
+/* === 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;
+}
+
+QList< Calamares::job_ptr >
+InstallationViewStep::jobs() const
+{
+ return QList< Calamares::job_ptr >();
+}
+
+} // namespace
diff --git a/src/libcalamaresui/InstallationViewStep.h b/src/libcalamaresui/InstallationViewStep.h
new file mode 100644
index 000000000..74381b1d1
--- /dev/null
+++ b/src/libcalamaresui/InstallationViewStep.h
@@ -0,0 +1,52 @@
+/* === 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;
+
+ QList< Calamares::job_ptr > jobs() 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 );
};
}