diff --git a/src/calamares/calamares-sidebar.qml b/src/calamares/calamares-sidebar.qml index a486bdb17..aa794e94a 100644 --- a/src/calamares/calamares-sidebar.qml +++ b/src/calamares/calamares-sidebar.qml @@ -26,7 +26,8 @@ Repeater { color: "black" Text { - color: completed ? "green" : "yellow" + anchors.centerIn: parent + color: index == ViewManager.currentStepIndex ? "green" : "yellow" text: display } } diff --git a/src/calamares/progresstree/ProgressTreeDelegate.cpp b/src/calamares/progresstree/ProgressTreeDelegate.cpp index e7041d1b9..7b7101f5d 100644 --- a/src/calamares/progresstree/ProgressTreeDelegate.cpp +++ b/src/calamares/progresstree/ProgressTreeDelegate.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017, 2019, Adriaan de Groot + * Copyright 2017, 2019-2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ #include "ProgressTreeDelegate.h" +#include "Branding.h" #include "CalamaresApplication.h" #include "CalamaresWindow.h" #include "ViewManager.h" -#include "Branding.h" #include "utils/CalamaresUtilsGui.h" #include @@ -85,10 +85,7 @@ ProgressTreeDelegate::paintViewStep( QPainter* painter, font.setBold( false ); painter->setFont( font ); - bool isCurrent = false; - isCurrent = index.data( Calamares::ViewManager::ProgressTreeItemCurrentRole ).toBool(); - - if ( isCurrent ) + if ( index.row() == index.data( Calamares::ViewManager::ProgressTreeItemCurrentIndex ).toInt() ) { painter->setPen( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarTextSelect ) ); QString textHighlight diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index 9972c3af9..93f23bd2f 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -3,7 +3,7 @@ * Copyright 2019, Dominic Hayes * Copyright 2019, Gabriel Craciunescu * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017-2018, Adriaan de Groot + * Copyright 2017-2018, 2020, Adriaan de Groot * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -559,23 +559,8 @@ ViewManager::data( const QModelIndex& index, int role ) const { return QVariant(); } - case ProgressTreeItemCurrentRole: - return currentStep() == step; - case ProgressTreeItemCompletedRole: - // Every step *before* the current step is considered "complete" - for ( const auto* otherstep : m_steps ) - { - if ( otherstep == currentStep() ) - { - break; - } - if ( otherstep == step ) - { - return true; - } - } - // .. and the others (including current) are not. - return false; + case ProgressTreeItemCurrentIndex: + return m_currentStep; default: return QVariant(); } @@ -592,13 +577,4 @@ ViewManager::rowCount( const QModelIndex& parent ) const return m_steps.length(); } -QHash< int, QByteArray > -ViewManager::roleNames() const -{ - auto h = QAbstractListModel::roleNames(); - h.insert( ProgressTreeItemCurrentRole, "current" ); - h.insert( ProgressTreeItemCompletedRole, "completed" ); - return h; -} - } // namespace Calamares diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index a4bedd7bc..f16419dcd 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -37,6 +37,8 @@ namespace Calamares class UIDLLEXPORT ViewManager : public QAbstractListModel { Q_OBJECT + Q_PROPERTY( int currentStepIndex READ currentStepIndex NOTIFY currentStepChanged FINAL ) + public: /** * @brief instance access to the ViewManager singleton. @@ -151,14 +153,11 @@ public: */ enum Role { - ProgressTreeItemCurrentRole = Qt::UserRole + 11, ///< Is this the *current* step? - ProgressTreeItemCompletedRole = Qt::UserRole + 12 ///< Are we past this one? + ProgressTreeItemCurrentIndex = Qt::UserRole + 13 ///< Index (row) of the current step }; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override; - - QHash< int, QByteArray > roleNames() const override; }; } // namespace Calamares