2021-07-06 19:09:20 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
|
|
|
*
|
|
|
|
* SPDX-FileCopyrightText: 2020, Camilo Higuita <milo.h@aol.com>
|
|
|
|
* SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*
|
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Config.h"
|
|
|
|
#include "SummaryQmlViewStep.h"
|
|
|
|
|
|
|
|
#include "Branding.h"
|
|
|
|
#include "Settings.h"
|
|
|
|
#include "ViewManager.h"
|
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/Retranslator.h"
|
|
|
|
#include "viewpages/ExecutionViewStep.h"
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
SummaryModel::SummaryModel( QObject* parent )
|
|
|
|
: QAbstractListModel( parent )
|
|
|
|
{
|
|
|
|
}
|
2021-07-06 19:09:20 +02:00
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
QHash< int, QByteArray >
|
|
|
|
SummaryModel::roleNames() const
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
return { { Qt::DisplayRole, "title" }, { Qt::UserRole, "message" } };
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
QVariant
|
|
|
|
SummaryModel::data( const QModelIndex& index, int role ) const
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
if ( !index.isValid() )
|
|
|
|
{
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
const auto item = m_summary.at( index.row() );
|
2021-07-13 11:02:24 +02:00
|
|
|
return role == Qt::DisplayRole ? item.title : item.message;
|
2021-07-06 19:09:20 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
int
|
|
|
|
SummaryModel::rowCount( const QModelIndex& ) const
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
return m_summary.count();
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
void
|
2021-07-13 11:02:24 +02:00
|
|
|
SummaryModel::setSummary( const Calamares::ViewStepList& steps, bool withWidgets )
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
Q_EMIT beginResetModel();
|
2021-07-13 11:02:24 +02:00
|
|
|
m_summary.clear();
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
for ( Calamares::ViewStep* step : steps )
|
|
|
|
{
|
|
|
|
QString text = step->prettyStatus();
|
2021-07-13 11:02:24 +02:00
|
|
|
QWidget* widget = withWidgets ? step->createSummaryWidget() : nullptr;
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
if ( text.isEmpty() && !widget )
|
2021-07-13 10:36:05 +02:00
|
|
|
{
|
2021-07-06 19:09:20 +02:00
|
|
|
continue;
|
2021-07-13 10:36:05 +02:00
|
|
|
}
|
2021-07-06 19:09:20 +02:00
|
|
|
|
2021-07-13 11:02:24 +02:00
|
|
|
m_summary << StepSummary { step->prettyName(), text, widget };
|
2021-07-06 19:09:20 +02:00
|
|
|
}
|
|
|
|
Q_EMIT endResetModel();
|
|
|
|
}
|
|
|
|
|
2021-07-13 21:25:57 +02:00
|
|
|
Config::Config( Calamares::ViewStep* parent )
|
2021-07-13 10:36:05 +02:00
|
|
|
: QObject( parent )
|
|
|
|
, m_thisViewStep( static_cast< SummaryQmlViewStep* >( parent ) )
|
|
|
|
, m_summary( new SummaryModel( this ) )
|
2021-07-13 20:42:19 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate );
|
|
|
|
retranslate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Config::retranslate()
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
m_title = m_thisViewStep->prettyName();
|
|
|
|
|
|
|
|
if ( Calamares::Settings::instance()->isSetupMode() )
|
2021-07-13 20:42:19 +02:00
|
|
|
{
|
2021-07-13 10:36:05 +02:00
|
|
|
m_message = ( tr( "This is an overview of what will happen once you start "
|
|
|
|
"the setup procedure." ) );
|
2021-07-13 20:42:19 +02:00
|
|
|
}
|
2021-07-06 19:09:20 +02:00
|
|
|
else
|
2021-07-13 20:42:19 +02:00
|
|
|
{
|
2021-07-06 19:09:20 +02:00
|
|
|
m_message = ( tr( "This is an overview of what will happen once you start "
|
2021-07-13 10:36:05 +02:00
|
|
|
"the install procedure." ) );
|
2021-07-13 20:42:19 +02:00
|
|
|
}
|
|
|
|
Q_EMIT titleChanged();
|
|
|
|
Q_EMIT messageChanged();
|
2021-07-06 19:09:20 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
void
|
|
|
|
Config::componentComplete()
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
void
|
|
|
|
Config::refresh()
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
2021-07-13 10:36:05 +02:00
|
|
|
m_summary->setSummary( stepsForSummary( Calamares::ViewManager::instance()->viewSteps() ) );
|
2021-07-06 19:09:20 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
void
|
|
|
|
Config::init()
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
|
2021-07-13 10:36:05 +02:00
|
|
|
Calamares::ViewStepList
|
|
|
|
Config::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
|
2021-07-06 19:09:20 +02:00
|
|
|
{
|
|
|
|
Calamares::ViewStepList steps;
|
|
|
|
for ( Calamares::ViewStep* step : allSteps )
|
|
|
|
{
|
|
|
|
if ( qobject_cast< Calamares::ExecutionViewStep* >( step ) )
|
|
|
|
{
|
|
|
|
steps.clear();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_thisViewStep == step )
|
2021-07-13 10:36:05 +02:00
|
|
|
{
|
2021-07-06 19:09:20 +02:00
|
|
|
break;
|
2021-07-13 10:36:05 +02:00
|
|
|
}
|
2021-07-06 19:09:20 +02:00
|
|
|
|
|
|
|
steps.append( step );
|
|
|
|
}
|
|
|
|
|
|
|
|
return steps;
|
|
|
|
}
|