2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2014-06-27 17:25:39 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2014-2017 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2018-2019 2020, Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2019 Collabora Ltd <arnaud.ferraris@collabora.com>
|
|
|
|
* SPDX-FileCopyrightText: 2020 Anke Boersma <demm@kaosx.us
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2014-06-27 17:25:39 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2014-06-27 17:25:39 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "gui/PartitionViewStep.h"
|
2014-06-27 18:14:39 +02:00
|
|
|
|
2020-05-18 13:07:12 +02:00
|
|
|
#include "core/Config.h"
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "core/DeviceModel.h"
|
2015-09-18 15:41:07 +02:00
|
|
|
#include "core/KPMHelpers.h"
|
|
|
|
#include "core/OsproberEntry.h"
|
|
|
|
#include "core/PartUtils.h"
|
2020-03-24 22:21:56 +01:00
|
|
|
#include "core/PartitionActions.h"
|
|
|
|
#include "core/PartitionCoreModule.h"
|
|
|
|
#include "core/PartitionModel.h"
|
2015-07-02 13:49:21 +02:00
|
|
|
#include "gui/ChoicePage.h"
|
2015-12-03 17:19:02 +01:00
|
|
|
#include "gui/PartitionBarsView.h"
|
2015-12-03 19:40:06 +01:00
|
|
|
#include "gui/PartitionLabelsView.h"
|
2020-03-24 22:21:56 +01:00
|
|
|
#include "gui/PartitionPage.h"
|
2014-07-30 14:15:29 +02:00
|
|
|
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "Branding.h"
|
2014-09-03 18:09:37 +02:00
|
|
|
#include "CalamaresVersion.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "Job.h"
|
|
|
|
#include "JobQueue.h"
|
2014-09-03 18:09:37 +02:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
|
|
#include "utils/Logger.h"
|
2019-01-11 14:32:45 +01:00
|
|
|
#include "utils/NamedEnum.h"
|
2020-10-24 12:49:56 +02:00
|
|
|
#include "utils/QtCompat.h"
|
2014-11-11 17:09:33 +01:00
|
|
|
#include "utils/Retranslator.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
#include "utils/Variant.h"
|
2014-09-03 18:09:37 +02:00
|
|
|
#include "widgets/WaitingWidget.h"
|
2019-04-29 11:51:27 +02:00
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-07-02 13:49:21 +02:00
|
|
|
#include <kpmcore/core/device.h>
|
|
|
|
#include <kpmcore/core/partition.h>
|
2016-06-10 15:07:43 +02:00
|
|
|
#include <kpmcore/fs/filesystem.h>
|
2015-07-02 13:49:21 +02:00
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
#include <QApplication>
|
2016-03-09 12:54:59 +01:00
|
|
|
#include <QDir>
|
2014-07-30 14:15:29 +02:00
|
|
|
#include <QFormLayout>
|
2020-03-24 22:21:56 +01:00
|
|
|
#include <QFutureWatcher>
|
2014-07-30 14:15:29 +02:00
|
|
|
#include <QLabel>
|
2016-03-09 12:54:59 +01:00
|
|
|
#include <QMessageBox>
|
2014-09-03 18:09:37 +02:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QStackedWidget>
|
|
|
|
#include <QTimer>
|
2016-05-26 15:35:24 +02:00
|
|
|
#include <QtConcurrent/QtConcurrent>
|
2014-06-27 17:25:39 +02:00
|
|
|
|
2014-06-30 13:24:59 +02:00
|
|
|
PartitionViewStep::PartitionViewStep( QObject* parent )
|
2014-06-27 18:14:39 +02:00
|
|
|
: Calamares::ViewStep( parent )
|
2020-05-18 13:07:12 +02:00
|
|
|
, m_config( new Config( this ) )
|
2016-05-26 15:08:37 +02:00
|
|
|
, m_core( nullptr )
|
2016-07-19 13:00:54 +02:00
|
|
|
, m_widget( new QStackedWidget() )
|
2015-10-06 18:40:31 +02:00
|
|
|
, m_choicePage( nullptr )
|
2016-05-26 15:08:37 +02:00
|
|
|
, m_manualPartitionPage( nullptr )
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
|
|
|
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
|
|
|
|
2015-10-06 18:40:31 +02:00
|
|
|
m_waitingWidget = new WaitingWidget( QString() );
|
|
|
|
m_widget->addWidget( m_waitingWidget );
|
2019-06-07 21:06:46 +02:00
|
|
|
CALAMARES_RETRANSLATE( m_waitingWidget->setText( tr( "Gathering system information..." ) ); )
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2020-03-24 22:21:56 +01:00
|
|
|
m_core = new PartitionCoreModule( this ); // Unusable before init is complete!
|
2015-10-06 18:40:31 +02:00
|
|
|
// We're not done loading, but we need the configuration map first.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2016-05-26 15:35:24 +02:00
|
|
|
PartitionViewStep::initPartitionCoreModule()
|
2015-10-06 18:40:31 +02:00
|
|
|
{
|
2016-07-19 13:00:54 +02:00
|
|
|
Q_ASSERT( m_core );
|
|
|
|
m_core->init();
|
2016-05-26 15:35:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PartitionViewStep::continueLoading()
|
|
|
|
{
|
2015-10-06 18:40:31 +02:00
|
|
|
Q_ASSERT( !m_choicePage );
|
2020-07-30 10:44:10 +02:00
|
|
|
m_choicePage = new ChoicePage( m_config );
|
2015-12-15 14:00:34 +01:00
|
|
|
m_choicePage->init( m_core );
|
2015-10-06 18:40:31 +02:00
|
|
|
m_widget->addWidget( m_choicePage );
|
2019-04-02 11:32:32 +02:00
|
|
|
|
|
|
|
// Instantiate the manual partitioning page as needed.
|
|
|
|
//
|
|
|
|
Q_ASSERT( !m_manualPartitionPage );
|
|
|
|
// m_manualPartitionPage = new PartitionPage( m_core );
|
|
|
|
// m_widget->addWidget( m_manualPartitionPage );
|
|
|
|
|
2015-10-06 18:40:31 +02:00
|
|
|
m_widget->removeWidget( m_waitingWidget );
|
|
|
|
m_waitingWidget->deleteLater();
|
|
|
|
m_waitingWidget = nullptr;
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2020-07-29 14:13:43 +02:00
|
|
|
connect( m_core, &PartitionCoreModule::hasRootMountPointChanged, this, &PartitionViewStep::nextPossiblyChanged );
|
|
|
|
connect( m_choicePage, &ChoicePage::nextStatusChanged, this, &PartitionViewStep::nextPossiblyChanged );
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PartitionViewStep::~PartitionViewStep()
|
2014-06-27 17:25:39 +02:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
if ( m_choicePage && m_choicePage->parent() == nullptr )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
m_choicePage->deleteLater();
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2014-09-03 18:09:37 +02:00
|
|
|
if ( m_manualPartitionPage && m_manualPartitionPage->parent() == nullptr )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
m_manualPartitionPage->deleteLater();
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2020-07-08 11:12:27 +02:00
|
|
|
delete m_core;
|
2014-06-27 17:25:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
2014-07-01 11:49:09 +02:00
|
|
|
PartitionViewStep::prettyName() const
|
2014-06-27 17:25:39 +02:00
|
|
|
{
|
2014-06-27 18:14:39 +02:00
|
|
|
return tr( "Partitions" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
2014-06-30 13:24:59 +02:00
|
|
|
PartitionViewStep::widget()
|
2014-06-27 18:14:39 +02:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
return m_widget;
|
2014-06-27 18:14:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-30 14:15:29 +02:00
|
|
|
QWidget*
|
|
|
|
PartitionViewStep::createSummaryWidget() const
|
|
|
|
{
|
|
|
|
QWidget* widget = new QWidget;
|
2015-04-09 15:05:04 +02:00
|
|
|
QVBoxLayout* mainLayout = new QVBoxLayout;
|
|
|
|
widget->setLayout( mainLayout );
|
|
|
|
mainLayout->setMargin( 0 );
|
2015-04-15 15:36:49 +02:00
|
|
|
|
2020-10-02 12:08:42 +02:00
|
|
|
Config::InstallChoice choice = m_config->installChoice();
|
2015-04-15 15:36:49 +02:00
|
|
|
|
2015-04-09 15:05:04 +02:00
|
|
|
QFormLayout* formLayout = new QFormLayout( widget );
|
2015-04-09 17:49:00 +02:00
|
|
|
const int MARGIN = CalamaresUtils::defaultFontHeight() / 2;
|
|
|
|
formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN );
|
2015-04-09 15:05:04 +02:00
|
|
|
mainLayout->addLayout( formLayout );
|
2014-07-30 14:15:29 +02:00
|
|
|
|
2020-05-04 12:48:11 +02:00
|
|
|
const auto* branding = Calamares::Branding::instance();
|
2014-07-30 14:15:29 +02:00
|
|
|
QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
|
2020-03-24 22:21:56 +01:00
|
|
|
if ( list.length() > 1 ) // There are changes on more than one disk
|
2015-04-15 15:36:49 +02:00
|
|
|
{
|
|
|
|
//NOTE: all of this should only happen when Manual partitioning is active.
|
|
|
|
// Any other choice should result in a list.length() == 1.
|
|
|
|
QLabel* modeLabel = new QLabel;
|
|
|
|
formLayout->addRow( modeLabel );
|
|
|
|
QString modeText;
|
|
|
|
switch ( choice )
|
|
|
|
{
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::Alongside:
|
2015-04-15 15:36:49 +02:00
|
|
|
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
|
2020-05-04 12:48:11 +02:00
|
|
|
.arg( branding->shortVersionedName() );
|
2015-04-15 15:36:49 +02:00
|
|
|
break;
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::Erase:
|
2020-08-22 01:19:58 +02:00
|
|
|
modeText = tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
|
2015-04-15 15:36:49 +02:00
|
|
|
break;
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::Replace:
|
2020-08-22 01:19:58 +02:00
|
|
|
modeText = tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
|
2015-04-15 15:36:49 +02:00
|
|
|
break;
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::NoChoice:
|
|
|
|
case Config::InstallChoice::Manual:
|
2015-04-15 15:36:49 +02:00
|
|
|
modeText = tr( "<strong>Manual</strong> partitioning." );
|
|
|
|
}
|
|
|
|
modeLabel->setText( modeText );
|
|
|
|
}
|
2014-07-30 14:15:29 +02:00
|
|
|
for ( const auto& info : list )
|
|
|
|
{
|
2015-04-15 15:36:49 +02:00
|
|
|
QLabel* diskInfoLabel = new QLabel;
|
2020-03-24 22:21:56 +01:00
|
|
|
if ( list.length() == 1 ) // this is the only disk preview
|
2015-04-15 15:36:49 +02:00
|
|
|
{
|
|
|
|
QString modeText;
|
|
|
|
switch ( choice )
|
|
|
|
{
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::Alongside:
|
2020-03-24 22:21:56 +01:00
|
|
|
modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk "
|
|
|
|
"<strong>%2</strong> (%3)." )
|
2020-05-04 12:48:11 +02:00
|
|
|
.arg( branding->shortVersionedName() )
|
2020-03-24 22:21:56 +01:00
|
|
|
.arg( info.deviceNode )
|
|
|
|
.arg( info.deviceName );
|
2015-04-15 15:36:49 +02:00
|
|
|
break;
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::Erase:
|
2015-04-15 15:36:49 +02:00
|
|
|
modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." )
|
2020-05-04 12:48:11 +02:00
|
|
|
.arg( branding->shortVersionedName() )
|
2020-03-24 22:21:56 +01:00
|
|
|
.arg( info.deviceNode )
|
|
|
|
.arg( info.deviceName );
|
2015-04-15 15:36:49 +02:00
|
|
|
break;
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::Replace:
|
2015-04-15 15:36:49 +02:00
|
|
|
modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." )
|
2020-05-04 12:48:11 +02:00
|
|
|
.arg( branding->shortVersionedName() )
|
2020-03-24 22:21:56 +01:00
|
|
|
.arg( info.deviceNode )
|
|
|
|
.arg( info.deviceName );
|
2015-04-15 15:36:49 +02:00
|
|
|
break;
|
2020-10-02 12:08:42 +02:00
|
|
|
case Config::InstallChoice::NoChoice:
|
|
|
|
case Config::InstallChoice::Manual:
|
2015-04-15 15:36:49 +02:00
|
|
|
modeText = tr( "<strong>Manual</strong> partitioning on disk <strong>%1</strong> (%2)." )
|
2020-03-24 22:21:56 +01:00
|
|
|
.arg( info.deviceNode )
|
|
|
|
.arg( info.deviceName );
|
2015-04-15 15:36:49 +02:00
|
|
|
}
|
|
|
|
diskInfoLabel->setText( modeText );
|
|
|
|
}
|
2020-03-24 22:21:56 +01:00
|
|
|
else // multiple disk previews!
|
2015-04-15 15:36:49 +02:00
|
|
|
{
|
2020-03-24 22:21:56 +01:00
|
|
|
diskInfoLabel->setText(
|
|
|
|
tr( "Disk <strong>%1</strong> (%2)" ).arg( info.deviceNode ).arg( info.deviceName ) );
|
2015-04-15 15:36:49 +02:00
|
|
|
}
|
2015-04-09 17:49:00 +02:00
|
|
|
formLayout->addRow( diskInfoLabel );
|
2014-07-30 14:15:29 +02:00
|
|
|
|
2015-12-03 17:19:02 +01:00
|
|
|
PartitionBarsView* preview;
|
2015-12-03 19:40:06 +01:00
|
|
|
PartitionLabelsView* previewLabels;
|
|
|
|
QVBoxLayout* field;
|
2014-07-30 14:15:29 +02:00
|
|
|
|
2020-03-24 22:21:56 +01:00
|
|
|
PartitionBarsView::NestedPartitionsMode mode
|
|
|
|
= Calamares::JobQueue::instance()->globalStorage()->value( "drawNestedPartitions" ).toBool()
|
|
|
|
? PartitionBarsView::DrawNestedPartitions
|
|
|
|
: PartitionBarsView::NoNestedPartitions;
|
2015-12-03 17:19:02 +01:00
|
|
|
preview = new PartitionBarsView;
|
2016-02-10 14:58:53 +01:00
|
|
|
preview->setNestedPartitionsMode( mode );
|
2015-12-03 19:40:06 +01:00
|
|
|
previewLabels = new PartitionLabelsView;
|
2016-02-11 16:00:49 +01:00
|
|
|
previewLabels->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
2014-07-30 14:15:29 +02:00
|
|
|
preview->setModel( info.partitionModelBefore );
|
2015-12-03 19:40:06 +01:00
|
|
|
previewLabels->setModel( info.partitionModelBefore );
|
2016-01-13 18:09:20 +01:00
|
|
|
preview->setSelectionMode( QAbstractItemView::NoSelection );
|
|
|
|
previewLabels->setSelectionMode( QAbstractItemView::NoSelection );
|
2014-07-30 14:15:29 +02:00
|
|
|
info.partitionModelBefore->setParent( widget );
|
2015-12-03 19:40:06 +01:00
|
|
|
field = new QVBoxLayout;
|
|
|
|
CalamaresUtils::unmarginLayout( field );
|
|
|
|
field->setSpacing( 6 );
|
|
|
|
field->addWidget( preview );
|
|
|
|
field->addWidget( previewLabels );
|
2016-01-25 16:58:54 +01:00
|
|
|
formLayout->addRow( tr( "Current:" ), field );
|
2014-07-30 14:15:29 +02:00
|
|
|
|
2015-12-03 17:19:02 +01:00
|
|
|
preview = new PartitionBarsView;
|
2016-02-10 14:58:53 +01:00
|
|
|
preview->setNestedPartitionsMode( mode );
|
2015-12-03 19:40:06 +01:00
|
|
|
previewLabels = new PartitionLabelsView;
|
2016-02-11 16:00:49 +01:00
|
|
|
previewLabels->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
2014-07-30 14:15:29 +02:00
|
|
|
preview->setModel( info.partitionModelAfter );
|
2015-12-03 19:40:06 +01:00
|
|
|
previewLabels->setModel( info.partitionModelAfter );
|
2016-01-13 18:09:20 +01:00
|
|
|
preview->setSelectionMode( QAbstractItemView::NoSelection );
|
|
|
|
previewLabels->setSelectionMode( QAbstractItemView::NoSelection );
|
2020-08-22 01:19:58 +02:00
|
|
|
previewLabels->setCustomNewRootLabel(
|
|
|
|
Calamares::Branding::instance()->string( Calamares::Branding::BootloaderEntryName ) );
|
2014-07-30 14:15:29 +02:00
|
|
|
info.partitionModelAfter->setParent( widget );
|
2015-12-03 19:40:06 +01:00
|
|
|
field = new QVBoxLayout;
|
|
|
|
CalamaresUtils::unmarginLayout( field );
|
|
|
|
field->setSpacing( 6 );
|
|
|
|
field->addWidget( preview );
|
|
|
|
field->addWidget( previewLabels );
|
2016-01-13 18:09:20 +01:00
|
|
|
formLayout->addRow( tr( "After:" ), field );
|
2014-07-30 14:15:29 +02:00
|
|
|
}
|
2015-04-09 15:05:04 +02:00
|
|
|
QStringList jobsLines;
|
|
|
|
foreach ( const Calamares::job_ptr& job, jobs() )
|
|
|
|
{
|
|
|
|
if ( !job->prettyDescription().isEmpty() )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2017-12-02 17:43:20 +01:00
|
|
|
jobsLines.append( job->prettyDescription() );
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2015-04-09 15:05:04 +02:00
|
|
|
}
|
2015-04-10 12:55:08 +02:00
|
|
|
if ( !jobsLines.isEmpty() )
|
|
|
|
{
|
|
|
|
QLabel* jobsLabel = new QLabel( widget );
|
|
|
|
mainLayout->addWidget( jobsLabel );
|
|
|
|
jobsLabel->setText( jobsLines.join( "<br/>" ) );
|
|
|
|
jobsLabel->setMargin( CalamaresUtils::defaultFontHeight() / 2 );
|
|
|
|
QPalette pal;
|
2020-10-24 12:49:56 +02:00
|
|
|
pal.setColor( WindowBackground, pal.window().color().lighter( 108 ) );
|
2015-04-10 12:55:08 +02:00
|
|
|
jobsLabel->setAutoFillBackground( true );
|
|
|
|
jobsLabel->setPalette( pal );
|
|
|
|
}
|
2014-07-30 14:15:29 +02:00
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2014-06-27 18:14:39 +02:00
|
|
|
void
|
2014-06-30 13:24:59 +02:00
|
|
|
PartitionViewStep::next()
|
2014-06-27 18:14:39 +02:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
if ( m_choicePage == m_widget->currentWidget() )
|
|
|
|
{
|
2020-10-02 12:08:42 +02:00
|
|
|
if ( m_config->installChoice() == Config::InstallChoice::Manual )
|
2015-12-29 12:33:24 +01:00
|
|
|
{
|
2019-04-02 11:32:32 +02:00
|
|
|
if ( !m_manualPartitionPage )
|
|
|
|
{
|
|
|
|
m_manualPartitionPage = new PartitionPage( m_core );
|
|
|
|
m_widget->addWidget( m_manualPartitionPage );
|
|
|
|
}
|
|
|
|
|
2014-09-04 19:37:30 +02:00
|
|
|
m_widget->setCurrentWidget( m_manualPartitionPage );
|
2019-01-10 16:28:05 +01:00
|
|
|
m_manualPartitionPage->selectDeviceByIndex( m_choicePage->lastSelectedDeviceIndex() );
|
2015-12-29 12:33:24 +01:00
|
|
|
if ( m_core->isDirty() )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2015-12-29 12:33:24 +01:00
|
|
|
m_manualPartitionPage->onRevertClicked();
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2015-12-29 12:33:24 +01:00
|
|
|
}
|
2020-09-29 14:00:49 +02:00
|
|
|
cDebug() << "Choice applied: " << m_config->installChoice();
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
2014-06-27 18:14:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2014-06-30 13:24:59 +02:00
|
|
|
PartitionViewStep::back()
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
|
|
|
if ( m_widget->currentWidget() != m_choicePage )
|
2019-01-10 16:28:05 +01:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
m_widget->setCurrentWidget( m_choicePage );
|
2019-01-10 16:28:05 +01:00
|
|
|
m_choicePage->setLastSelectedDeviceIndex( m_manualPartitionPage->selectedDeviceIndex() );
|
2019-04-02 11:32:32 +02:00
|
|
|
|
|
|
|
if ( m_manualPartitionPage )
|
|
|
|
{
|
|
|
|
m_manualPartitionPage->deleteLater();
|
|
|
|
m_manualPartitionPage = nullptr;
|
|
|
|
}
|
2019-01-10 16:28:05 +01:00
|
|
|
}
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
2014-06-27 18:14:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
bool
|
2014-07-01 11:49:09 +02:00
|
|
|
PartitionViewStep::isNextEnabled() const
|
2014-06-27 18:14:39 +02:00
|
|
|
{
|
2019-04-02 11:30:22 +02:00
|
|
|
if ( m_choicePage && m_widget->currentWidget() == m_choicePage )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
return m_choicePage->isNextEnabled();
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2019-04-02 11:30:22 +02:00
|
|
|
if ( m_manualPartitionPage && m_widget->currentWidget() == m_manualPartitionPage )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2014-09-16 18:13:05 +02:00
|
|
|
return m_core->hasRootMountPoint();
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2014-09-04 19:37:30 +02:00
|
|
|
|
2014-09-16 18:13:05 +02:00
|
|
|
return false;
|
2014-06-27 18:14:39 +02:00
|
|
|
}
|
|
|
|
|
2020-07-29 14:13:43 +02:00
|
|
|
void
|
2020-08-22 01:19:58 +02:00
|
|
|
PartitionViewStep::nextPossiblyChanged( bool )
|
2020-07-29 14:13:43 +02:00
|
|
|
{
|
|
|
|
emit nextStatusChanged( isNextEnabled() );
|
|
|
|
}
|
2014-06-27 18:14:39 +02:00
|
|
|
|
2015-01-29 20:24:09 +01:00
|
|
|
bool
|
|
|
|
PartitionViewStep::isBackEnabled() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-27 18:14:39 +02:00
|
|
|
bool
|
2014-07-01 11:49:09 +02:00
|
|
|
PartitionViewStep::isAtBeginning() const
|
2014-06-27 18:14:39 +02:00
|
|
|
{
|
2019-04-02 11:30:22 +02:00
|
|
|
if ( m_widget->currentWidget() != m_choicePage )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2014-09-03 18:09:37 +02:00
|
|
|
return false;
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2014-06-27 18:14:39 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2014-07-01 11:49:09 +02:00
|
|
|
PartitionViewStep::isAtEnd() const
|
2014-06-27 18:14:39 +02:00
|
|
|
{
|
2019-04-02 11:30:22 +02:00
|
|
|
if ( m_widget->currentWidget() == m_choicePage )
|
2015-10-30 13:41:37 +01:00
|
|
|
{
|
2020-09-29 14:00:49 +02:00
|
|
|
auto choice = m_config->installChoice();
|
2020-10-02 12:08:42 +02:00
|
|
|
if ( Config::InstallChoice::Erase == choice || Config::InstallChoice::Replace == choice
|
|
|
|
|| Config::InstallChoice::Alongside == choice )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2015-10-30 13:41:37 +01:00
|
|
|
return true;
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2014-09-03 18:09:37 +02:00
|
|
|
return false;
|
2015-10-30 13:41:37 +01:00
|
|
|
}
|
2014-06-27 18:14:39 +02:00
|
|
|
return true;
|
2014-06-27 17:25:39 +02:00
|
|
|
}
|
2014-07-08 14:02:21 +02:00
|
|
|
|
|
|
|
|
2015-04-29 18:16:18 +02:00
|
|
|
void
|
|
|
|
PartitionViewStep::onActivate()
|
|
|
|
{
|
2020-05-18 13:07:12 +02:00
|
|
|
m_config->updateGlobalStorage();
|
2019-06-08 14:12:28 +02:00
|
|
|
|
2015-04-29 18:16:18 +02:00
|
|
|
// if we're coming back to PVS from the next VS
|
2020-10-02 12:08:42 +02:00
|
|
|
if ( m_widget->currentWidget() == m_choicePage && m_config->installChoice() == Config::InstallChoice::Alongside )
|
2015-04-29 18:16:18 +02:00
|
|
|
{
|
2020-10-02 12:08:42 +02:00
|
|
|
m_choicePage->applyActionChoice( Config::InstallChoice::Alongside );
|
2020-03-24 22:21:56 +01:00
|
|
|
// m_choicePage->reset();
|
2015-11-20 14:49:21 +01:00
|
|
|
//FIXME: ReplaceWidget should be reset maybe?
|
2015-04-29 18:16:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-06 18:30:23 +02:00
|
|
|
void
|
|
|
|
PartitionViewStep::onLeave()
|
|
|
|
{
|
2016-02-19 16:33:19 +01:00
|
|
|
if ( m_widget->currentWidget() == m_choicePage )
|
2016-03-09 13:21:07 +01:00
|
|
|
{
|
2016-02-19 16:33:19 +01:00
|
|
|
m_choicePage->onLeave();
|
2016-03-09 13:21:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-05-04 12:48:11 +02:00
|
|
|
const auto* branding = Calamares::Branding::instance();
|
2016-03-09 13:21:07 +01:00
|
|
|
if ( m_widget->currentWidget() == m_manualPartitionPage )
|
|
|
|
{
|
2017-08-28 11:36:21 +02:00
|
|
|
if ( PartUtils::isEfiSystem() )
|
2016-03-09 13:21:07 +01:00
|
|
|
{
|
2020-03-24 22:21:56 +01:00
|
|
|
QString espMountPoint
|
|
|
|
= Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
|
2020-04-23 13:53:30 +02:00
|
|
|
#ifdef WITH_KPMCORE4API
|
|
|
|
auto espFlag = PartitionTable::Flag::Boot;
|
|
|
|
#else
|
|
|
|
auto espFlag = PartitionTable::FlagEsp;
|
|
|
|
#endif
|
|
|
|
QString espFlagName = PartitionTable::flagName( espFlag );
|
2016-03-09 13:21:07 +01:00
|
|
|
Partition* esp = m_core->findPartitionByMountPoint( espMountPoint );
|
|
|
|
|
|
|
|
QString message;
|
|
|
|
QString description;
|
|
|
|
if ( !esp )
|
|
|
|
{
|
|
|
|
message = tr( "No EFI system partition configured" );
|
2016-03-09 13:34:20 +01:00
|
|
|
description = tr( "An EFI system partition is necessary to start %1."
|
|
|
|
"<br/><br/>"
|
2016-03-09 13:21:07 +01:00
|
|
|
"To configure an EFI system partition, go back and "
|
|
|
|
"select or create a FAT32 filesystem with the "
|
2020-04-23 13:53:30 +02:00
|
|
|
"<strong>%3</strong> flag enabled and mount point "
|
2016-03-09 13:34:20 +01:00
|
|
|
"<strong>%2</strong>.<br/><br/>"
|
2016-03-09 13:21:07 +01:00
|
|
|
"You can continue without setting up an EFI system "
|
|
|
|
"partition but your system may fail to start." )
|
2020-05-04 12:48:11 +02:00
|
|
|
.arg( branding->shortProductName() )
|
2020-04-23 13:53:30 +02:00
|
|
|
.arg( espMountPoint, espFlagName );
|
2016-03-09 13:21:07 +01:00
|
|
|
}
|
2018-01-09 17:15:30 +01:00
|
|
|
else if ( esp && !PartUtils::isEfiBootable( esp ) )
|
2016-03-09 13:21:07 +01:00
|
|
|
{
|
|
|
|
message = tr( "EFI system partition flag not set" );
|
2016-03-09 13:34:20 +01:00
|
|
|
description = tr( "An EFI system partition is necessary to start %1."
|
|
|
|
"<br/><br/>"
|
2016-03-09 13:21:07 +01:00
|
|
|
"A partition was configured with mount point "
|
2020-04-23 13:53:30 +02:00
|
|
|
"<strong>%2</strong> but its <strong>%3</strong> "
|
2016-03-09 13:34:20 +01:00
|
|
|
"flag is not set.<br/>"
|
|
|
|
"To set the flag, go back and edit the partition."
|
|
|
|
"<br/><br/>"
|
2016-03-09 13:21:07 +01:00
|
|
|
"You can continue without setting the flag but your "
|
|
|
|
"system may fail to start." )
|
2020-05-04 12:48:11 +02:00
|
|
|
.arg( branding->shortProductName() )
|
2020-04-23 13:53:30 +02:00
|
|
|
.arg( espMountPoint, espFlagName );
|
2016-03-09 13:21:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !message.isEmpty() )
|
|
|
|
{
|
2018-02-13 11:07:12 +01:00
|
|
|
cWarning() << message;
|
2020-03-24 22:21:56 +01:00
|
|
|
QMessageBox::warning( m_manualPartitionPage, message, description );
|
2016-03-09 13:21:07 +01:00
|
|
|
}
|
|
|
|
}
|
2020-03-24 22:32:49 +01:00
|
|
|
else
|
2020-03-24 16:59:31 +01:00
|
|
|
{
|
2020-03-24 22:21:56 +01:00
|
|
|
|
2020-03-24 16:59:31 +01:00
|
|
|
cDebug() << "device: BIOS";
|
2020-03-24 22:32:49 +01:00
|
|
|
// TODO: this *always* warns, which might be annoying, so it'd be
|
|
|
|
// best to find a way to detect that bios_grub partition.
|
2020-03-24 22:21:56 +01:00
|
|
|
|
2020-03-24 22:32:49 +01:00
|
|
|
QString message = tr( "Option to use GPT on BIOS" );
|
|
|
|
QString description = tr( "A GPT partition table is the best option for all "
|
2020-08-22 01:19:58 +02:00
|
|
|
"systems. This installer supports such a setup for "
|
|
|
|
"BIOS systems too."
|
|
|
|
"<br/><br/>"
|
|
|
|
"To configure a GPT partition table on BIOS, "
|
|
|
|
"(if not done so already) go back "
|
|
|
|
"and set the partition table to GPT, next create a 8 MB "
|
|
|
|
"unformatted partition with the "
|
|
|
|
"<strong>bios_grub</strong> flag enabled.<br/><br/>"
|
|
|
|
"An unformatted 8 MB partition is necessary "
|
|
|
|
"to start %1 on a BIOS system with GPT." )
|
|
|
|
.arg( branding->shortProductName() );
|
2020-03-24 22:21:56 +01:00
|
|
|
|
2020-03-24 22:32:49 +01:00
|
|
|
QMessageBox::information( m_manualPartitionPage, message, description );
|
2020-03-24 16:59:31 +01:00
|
|
|
}
|
2020-03-24 22:21:56 +01:00
|
|
|
|
2016-11-17 18:15:14 +01:00
|
|
|
Partition* root_p = m_core->findPartitionByMountPoint( "/" );
|
|
|
|
Partition* boot_p = m_core->findPartitionByMountPoint( "/boot" );
|
|
|
|
|
|
|
|
if ( root_p and boot_p )
|
|
|
|
{
|
|
|
|
QString message;
|
|
|
|
QString description;
|
|
|
|
|
|
|
|
// If the root partition is encrypted, and there's a separate boot
|
|
|
|
// partition which is not encrypted
|
2020-03-24 22:21:56 +01:00
|
|
|
if ( root_p->fileSystem().type() == FileSystem::Luks && boot_p->fileSystem().type() != FileSystem::Luks )
|
2016-11-17 18:15:14 +01:00
|
|
|
{
|
|
|
|
message = tr( "Boot partition not encrypted" );
|
|
|
|
description = tr( "A separate boot partition was set up together with "
|
|
|
|
"an encrypted root partition, but the boot partition "
|
|
|
|
"is not encrypted."
|
|
|
|
"<br/><br/>"
|
|
|
|
"There are security concerns with this kind of "
|
|
|
|
"setup, because important system files are kept "
|
|
|
|
"on an unencrypted partition.<br/>"
|
|
|
|
"You may continue if you wish, but filesystem "
|
|
|
|
"unlocking will happen later during system startup."
|
|
|
|
"<br/>To encrypt the boot partition, go back and "
|
|
|
|
"recreate it, selecting <strong>Encrypt</strong> "
|
|
|
|
"in the partition creation window." );
|
2016-11-17 19:03:24 +01:00
|
|
|
|
2020-03-24 22:21:56 +01:00
|
|
|
QMessageBox::warning( m_manualPartitionPage, message, description );
|
2016-11-17 18:28:58 +01:00
|
|
|
}
|
2016-11-17 18:15:14 +01:00
|
|
|
}
|
2016-03-09 13:21:07 +01:00
|
|
|
}
|
2014-10-06 18:30:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-14 22:53:00 +01:00
|
|
|
void
|
|
|
|
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
2020-05-18 13:07:12 +02:00
|
|
|
m_config->setConfigurationMap( configurationMap );
|
|
|
|
|
2015-02-14 22:53:00 +01:00
|
|
|
// Copy the efiSystemPartition setting to the global storage. It is needed not only in
|
|
|
|
// the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader).
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
2020-09-28 14:52:18 +02:00
|
|
|
QString efiSP = CalamaresUtils::getString( configurationMap, "efiSystemPartition", QStringLiteral( "/boot/efi" ) );
|
2018-10-09 11:46:12 +02:00
|
|
|
gs->insert( "efiSystemPartition", efiSP );
|
2015-06-26 15:48:12 +02:00
|
|
|
|
2019-03-11 22:50:27 +01:00
|
|
|
// Set up firmwareType global storage entry. This is used, e.g. by the bootloader module.
|
|
|
|
QString firmwareType( PartUtils::isEfiSystem() ? QStringLiteral( "efi" ) : QStringLiteral( "bios" ) );
|
|
|
|
cDebug() << "Setting firmwareType to" << firmwareType;
|
|
|
|
gs->insert( "firmwareType", firmwareType );
|
|
|
|
|
2019-02-28 13:46:25 +01:00
|
|
|
// Read and parse key efiSystemPartitionSize
|
|
|
|
if ( configurationMap.contains( "efiSystemPartitionSize" ) )
|
|
|
|
{
|
|
|
|
gs->insert( "efiSystemPartitionSize", CalamaresUtils::getString( configurationMap, "efiSystemPartitionSize" ) );
|
|
|
|
}
|
|
|
|
|
2020-04-22 00:11:16 +02:00
|
|
|
// Read and parse key efiSystemPartitionName
|
|
|
|
if ( configurationMap.contains( "efiSystemPartitionName" ) )
|
|
|
|
{
|
|
|
|
gs->insert( "efiSystemPartitionName", CalamaresUtils::getString( configurationMap, "efiSystemPartitionName" ) );
|
|
|
|
}
|
|
|
|
|
2018-10-09 11:46:12 +02:00
|
|
|
// OTHER SETTINGS
|
|
|
|
//
|
|
|
|
gs->insert( "drawNestedPartitions", CalamaresUtils::getBool( configurationMap, "drawNestedPartitions", false ) );
|
2020-03-24 22:21:56 +01:00
|
|
|
gs->insert( "alwaysShowPartitionLabels",
|
|
|
|
CalamaresUtils::getBool( configurationMap, "alwaysShowPartitionLabels", true ) );
|
|
|
|
gs->insert( "enableLuksAutomatedPartitioning",
|
|
|
|
CalamaresUtils::getBool( configurationMap, "enableLuksAutomatedPartitioning", true ) );
|
2019-02-22 18:42:16 +01:00
|
|
|
|
|
|
|
// The defaultFileSystemType setting needs a bit more processing,
|
|
|
|
// as we want to cover various cases (such as different cases)
|
|
|
|
QString fsName = CalamaresUtils::getString( configurationMap, "defaultFileSystemType" );
|
|
|
|
FileSystem::Type fsType;
|
|
|
|
if ( fsName.isEmpty() )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *defaultFileSystemType* is missing, will use ext4";
|
|
|
|
}
|
2019-02-22 18:42:16 +01:00
|
|
|
QString fsRealName = PartUtils::findFS( fsName, &fsType );
|
|
|
|
if ( fsRealName == fsName )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2019-02-22 18:42:16 +01:00
|
|
|
cDebug() << "Partition-module setting *defaultFileSystemType*" << fsRealName;
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2019-02-22 18:42:16 +01:00
|
|
|
else if ( fsType != FileSystem::Unknown )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2019-02-22 18:42:16 +01:00
|
|
|
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << fsRealName;
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2019-02-22 18:42:16 +01:00
|
|
|
else
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName << ") using" << fsRealName
|
|
|
|
<< "instead.";
|
|
|
|
}
|
2019-02-22 18:42:16 +01:00
|
|
|
gs->insert( "defaultFileSystemType", fsRealName );
|
2016-09-26 13:14:54 +02:00
|
|
|
|
2020-05-20 17:22:37 +02:00
|
|
|
QString partitionTableName = CalamaresUtils::getString( configurationMap, "defaultPartitionTableType" );
|
|
|
|
if ( partitionTableName.isEmpty() )
|
|
|
|
{
|
|
|
|
cWarning() << "Partition-module setting *defaultPartitionTableType* is unset, "
|
|
|
|
"will use gpt for efi or msdos for bios";
|
|
|
|
}
|
|
|
|
gs->insert( "defaultPartitionTableType", partitionTableName );
|
2016-06-10 15:07:43 +02:00
|
|
|
|
2016-05-26 15:35:24 +02:00
|
|
|
// Now that we have the config, we load the PartitionCoreModule in the background
|
|
|
|
// because it could take a while. Then when it's done, we can set up the widgets
|
|
|
|
// and remove the spinner.
|
2017-12-02 18:11:56 +01:00
|
|
|
m_future = new QFutureWatcher< void >();
|
2020-10-12 14:27:01 +02:00
|
|
|
connect( m_future, &QFutureWatcher< void >::finished, this, [this] {
|
2016-05-26 15:35:24 +02:00
|
|
|
continueLoading();
|
2017-12-02 18:11:56 +01:00
|
|
|
this->m_future->deleteLater();
|
|
|
|
this->m_future = nullptr;
|
2016-05-26 15:35:24 +02:00
|
|
|
} );
|
|
|
|
|
2020-03-24 22:21:56 +01:00
|
|
|
QFuture< void > future = QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
2017-12-02 18:11:56 +01:00
|
|
|
m_future->setFuture( future );
|
2019-01-07 17:25:39 +01:00
|
|
|
|
|
|
|
if ( configurationMap.contains( "partitionLayout" ) )
|
|
|
|
{
|
2020-09-28 14:48:55 +02:00
|
|
|
m_core->initLayout( configurationMap.value( "partitionLayout" ).toList() );
|
2019-01-07 17:25:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_core->initLayout();
|
|
|
|
}
|
2015-02-14 22:53:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-28 16:39:00 +02:00
|
|
|
Calamares::JobList
|
2014-07-08 14:02:21 +02:00
|
|
|
PartitionViewStep::jobs() const
|
|
|
|
{
|
2020-10-02 12:08:42 +02:00
|
|
|
return m_core->jobs( m_config );
|
2014-07-08 14:02:21 +02:00
|
|
|
}
|
2014-09-23 17:42:11 +02:00
|
|
|
|
2019-02-25 12:45:17 +01:00
|
|
|
Calamares::RequirementsList
|
|
|
|
PartitionViewStep::checkRequirements()
|
2017-12-02 17:42:56 +01:00
|
|
|
{
|
2019-02-25 12:45:17 +01:00
|
|
|
if ( m_future )
|
2020-03-24 22:21:56 +01:00
|
|
|
{
|
2017-12-02 18:11:56 +01:00
|
|
|
m_future->waitForFinished();
|
2020-03-24 22:21:56 +01:00
|
|
|
}
|
2017-12-02 18:11:56 +01:00
|
|
|
|
2017-12-02 17:42:56 +01:00
|
|
|
Calamares::RequirementsList l;
|
2020-03-24 22:21:56 +01:00
|
|
|
l.append( {
|
2019-09-08 22:20:13 +02:00
|
|
|
QLatin1String( "partitions" ),
|
2020-03-24 22:21:56 +01:00
|
|
|
[] { return tr( "has at least one disk device available." ); },
|
|
|
|
[] { return tr( "There are no partitions to install on." ); },
|
2017-12-02 18:11:56 +01:00
|
|
|
m_core->deviceModel()->rowCount() > 0, // satisfied
|
2019-05-28 16:29:45 +02:00
|
|
|
#ifdef DEBUG_PARTITION_UNSAFE
|
2020-03-24 22:21:56 +01:00
|
|
|
false // optional
|
2019-05-28 16:29:45 +02:00
|
|
|
#else
|
2020-03-24 22:21:56 +01:00
|
|
|
true // required
|
2019-05-28 16:29:45 +02:00
|
|
|
#endif
|
2017-12-02 17:43:20 +01:00
|
|
|
} );
|
2017-12-02 17:42:56 +01:00
|
|
|
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2014-09-23 17:42:11 +02:00
|
|
|
|
2020-03-24 22:21:56 +01:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( PartitionViewStepFactory, registerPlugin< PartitionViewStep >(); )
|