Merge branch 'issue-1340'

FIXES #1340
This commit is contained in:
Adriaan de Groot 2020-03-30 14:28:46 +02:00
commit 04c084e831
4 changed files with 11 additions and 38 deletions

View File

@ -26,7 +26,8 @@ Repeater {
color: "black" color: "black"
Text { Text {
color: completed ? "green" : "yellow" anchors.centerIn: parent
color: index == ViewManager.currentStepIndex ? "green" : "yellow"
text: display text: display
} }
} }

View File

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2019-2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -19,10 +19,10 @@
#include "ProgressTreeDelegate.h" #include "ProgressTreeDelegate.h"
#include "Branding.h"
#include "CalamaresApplication.h" #include "CalamaresApplication.h"
#include "CalamaresWindow.h" #include "CalamaresWindow.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "Branding.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
#include <QPainter> #include <QPainter>
@ -85,10 +85,7 @@ ProgressTreeDelegate::paintViewStep( QPainter* painter,
font.setBold( false ); font.setBold( false );
painter->setFont( font ); painter->setFont( font );
bool isCurrent = false; if ( index.row() == index.data( Calamares::ViewManager::ProgressTreeItemCurrentIndex ).toInt() )
isCurrent = index.data( Calamares::ViewManager::ProgressTreeItemCurrentRole ).toBool();
if ( isCurrent )
{ {
painter->setPen( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarTextSelect ) ); painter->setPen( Calamares::Branding::instance()->styleString( Calamares::Branding::SidebarTextSelect ) );
QString textHighlight QString textHighlight

View File

@ -3,7 +3,7 @@
* Copyright 2019, Dominic Hayes <ferenosdev@outlook.com> * Copyright 2019, Dominic Hayes <ferenosdev@outlook.com>
* Copyright 2019, Gabriel Craciunescu <crazy@frugalware.org> * Copyright 2019, Gabriel Craciunescu <crazy@frugalware.org>
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * 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(); return QVariant();
} }
case ProgressTreeItemCurrentRole: case ProgressTreeItemCurrentIndex:
return currentStep() == step; return m_currentStep;
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;
default: default:
return QVariant(); return QVariant();
} }
@ -592,13 +577,4 @@ ViewManager::rowCount( const QModelIndex& parent ) const
return m_steps.length(); 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 } // namespace Calamares

View File

@ -37,6 +37,8 @@ namespace Calamares
class UIDLLEXPORT ViewManager : public QAbstractListModel class UIDLLEXPORT ViewManager : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY( int currentStepIndex READ currentStepIndex NOTIFY currentStepChanged FINAL )
public: public:
/** /**
* @brief instance access to the ViewManager singleton. * @brief instance access to the ViewManager singleton.
@ -151,14 +153,11 @@ public:
*/ */
enum Role enum Role
{ {
ProgressTreeItemCurrentRole = Qt::UserRole + 11, ///< Is this the *current* step? ProgressTreeItemCurrentIndex = Qt::UserRole + 13 ///< Index (row) of the current step
ProgressTreeItemCompletedRole = Qt::UserRole + 12 ///< Are we past this one?
}; };
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
int rowCount( const QModelIndex& parent = QModelIndex() ) const override; int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
QHash< int, QByteArray > roleNames() const override;
}; };
} // namespace Calamares } // namespace Calamares