2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-09-03 18:09:37 +02:00
|
|
|
*
|
2017-01-12 13:27:46 +01:00
|
|
|
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
2017-07-04 00:07:18 +02:00
|
|
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
2014-09-03 18:09:37 +02:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ChoicePage.h"
|
|
|
|
|
2015-11-06 17:57:05 +01:00
|
|
|
#include "core/BootLoaderModel.h"
|
2015-10-29 17:34:59 +01:00
|
|
|
#include "core/PartitionActions.h"
|
2014-09-19 16:27:39 +02:00
|
|
|
#include "core/PartitionCoreModule.h"
|
|
|
|
#include "core/DeviceModel.h"
|
|
|
|
#include "core/PartitionModel.h"
|
2015-09-18 15:41:07 +02:00
|
|
|
#include "core/OsproberEntry.h"
|
2016-01-15 17:53:07 +01:00
|
|
|
#include "core/PartUtils.h"
|
2016-02-12 16:45:52 +01:00
|
|
|
#include "core/PartitionIterator.h"
|
2014-09-19 16:27:39 +02:00
|
|
|
|
2015-11-20 14:49:37 +01:00
|
|
|
#include "ReplaceWidget.h"
|
2014-09-03 18:09:37 +02:00
|
|
|
#include "PrettyRadioButton.h"
|
2015-12-03 17:19:02 +01:00
|
|
|
#include "PartitionBarsView.h"
|
2015-12-03 19:40:06 +01:00
|
|
|
#include "PartitionLabelsView.h"
|
2016-01-11 19:02:34 +01:00
|
|
|
#include "PartitionSplitterWidget.h"
|
2016-01-27 18:23:56 +01:00
|
|
|
#include "BootInfoWidget.h"
|
2015-11-27 17:25:47 +01:00
|
|
|
#include "DeviceInfoWidget.h"
|
2015-12-31 13:19:24 +01:00
|
|
|
#include "ScanningDialog.h"
|
2014-09-03 18:09:37 +02:00
|
|
|
|
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2014-09-19 16:27:39 +02:00
|
|
|
#include "utils/Logger.h"
|
2014-11-11 17:09:33 +01:00
|
|
|
#include "utils/Retranslator.h"
|
2014-10-16 17:00:08 +02:00
|
|
|
#include "Branding.h"
|
2015-12-17 16:14:01 +01:00
|
|
|
#include "core/KPMHelpers.h"
|
2016-01-12 11:42:38 +01:00
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "GlobalStorage.h"
|
2016-01-13 17:43:59 +01:00
|
|
|
#include "core/PartitionInfo.h"
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-09-18 17:25:55 +02:00
|
|
|
#include <kpmcore/core/device.h>
|
2016-01-12 11:42:38 +01:00
|
|
|
#include <kpmcore/core/partition.h>
|
2015-09-18 17:25:55 +02:00
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QButtonGroup>
|
2015-10-06 18:56:33 +02:00
|
|
|
#include <QComboBox>
|
2015-05-28 19:24:39 +02:00
|
|
|
#include <QDir>
|
2014-09-03 18:09:37 +02:00
|
|
|
#include <QLabel>
|
2015-09-18 17:25:55 +02:00
|
|
|
#include <QListView>
|
2015-12-24 17:02:50 +01:00
|
|
|
#include <QFutureWatcher>
|
|
|
|
#include <QtConcurrent/QtConcurrent>
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of
|
|
|
|
* the module loading code path.
|
|
|
|
* @param compactMode if true, the drive selector will be a combo box on top, otherwise it
|
|
|
|
* will show up as a list view.
|
|
|
|
* @param parent the QWidget parent.
|
|
|
|
*/
|
2015-11-26 15:31:06 +01:00
|
|
|
ChoicePage::ChoicePage( QWidget* parent )
|
2014-09-03 18:09:37 +02:00
|
|
|
: QWidget( parent )
|
|
|
|
, m_nextEnabled( false )
|
2015-06-14 00:55:26 +02:00
|
|
|
, m_core( nullptr )
|
2016-07-15 11:36:44 +02:00
|
|
|
, m_choice( NoChoice )
|
|
|
|
, m_isEfi( false )
|
2016-02-26 14:02:22 +01:00
|
|
|
, m_grp( nullptr )
|
2015-10-06 18:56:33 +02:00
|
|
|
, m_alongsideButton( nullptr )
|
|
|
|
, m_eraseButton( nullptr )
|
|
|
|
, m_replaceButton( nullptr )
|
|
|
|
, m_somethingElseButton( nullptr )
|
2015-11-27 17:25:47 +01:00
|
|
|
, m_deviceInfoWidget( nullptr )
|
2015-12-17 15:39:52 +01:00
|
|
|
, m_beforePartitionBarsView( nullptr )
|
|
|
|
, m_beforePartitionLabelsView( nullptr )
|
2016-01-29 17:07:08 +01:00
|
|
|
, m_bootloaderComboBox( nullptr )
|
2016-07-15 11:36:44 +02:00
|
|
|
, m_lastSelectedDeviceIndex( -1 )
|
2016-09-26 13:14:54 +02:00
|
|
|
, m_enableEncryptionWidget( true )
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
2015-09-30 17:24:37 +02:00
|
|
|
setupUi( this );
|
2015-10-22 18:37:09 +02:00
|
|
|
|
2016-06-10 15:22:21 +02:00
|
|
|
m_defaultFsType = Calamares::JobQueue::instance()->
|
|
|
|
globalStorage()->
|
|
|
|
value( "defaultFileSystemType" ).toString();
|
2016-09-26 13:14:54 +02:00
|
|
|
m_enableEncryptionWidget = Calamares::JobQueue::instance()->
|
|
|
|
globalStorage()->
|
|
|
|
value( "enableLuksAutomatedPartitioning" ).toBool();
|
2016-06-10 15:22:21 +02:00
|
|
|
if ( FileSystem::typeForName( m_defaultFsType ) == FileSystem::Unknown )
|
|
|
|
m_defaultFsType = "ext4";
|
|
|
|
|
2015-11-26 15:31:06 +01:00
|
|
|
// Set up drives combo
|
|
|
|
m_mainLayout->setDirection( QBoxLayout::TopToBottom );
|
|
|
|
m_drivesLayout->setDirection( QBoxLayout::LeftToRight );
|
2016-01-27 18:23:56 +01:00
|
|
|
|
|
|
|
BootInfoWidget* bootInfoWidget = new BootInfoWidget( this );
|
2016-01-27 18:27:03 +01:00
|
|
|
m_drivesLayout->insertWidget( 0, bootInfoWidget );
|
|
|
|
m_drivesLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() / 2 );
|
2016-01-27 18:23:56 +01:00
|
|
|
|
2015-11-26 15:31:06 +01:00
|
|
|
m_drivesCombo = new QComboBox( this );
|
|
|
|
m_mainLayout->setStretchFactor( m_drivesLayout, 0 );
|
|
|
|
m_mainLayout->setStretchFactor( m_rightLayout, 1 );
|
|
|
|
m_drivesLabel->setBuddy( m_drivesCombo );
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-11-26 15:31:06 +01:00
|
|
|
m_drivesLayout->addWidget( m_drivesCombo );
|
|
|
|
|
2015-11-27 17:25:47 +01:00
|
|
|
m_deviceInfoWidget = new DeviceInfoWidget;
|
|
|
|
m_drivesLayout->addWidget( m_deviceInfoWidget );
|
2016-01-28 13:04:44 +01:00
|
|
|
m_drivesLayout->addStretch();
|
2015-10-22 18:37:09 +02:00
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
m_messageLabel->setWordWrap( true );
|
2015-12-15 17:18:10 +01:00
|
|
|
m_messageLabel->hide();
|
2014-09-03 18:09:37 +02:00
|
|
|
|
|
|
|
CalamaresUtils::unmarginLayout( m_itemsLayout );
|
|
|
|
|
2015-09-30 17:24:37 +02:00
|
|
|
// Drive selector + preview
|
2015-11-26 15:31:06 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
retranslateUi( this );
|
2016-01-25 16:58:54 +01:00
|
|
|
m_drivesLabel->setText( tr( "Select storage de&vice:" ) );
|
|
|
|
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
2015-12-15 17:17:53 +01:00
|
|
|
m_previewAfterLabel->setText( tr( "After:" ) );
|
2015-11-26 15:31:06 +01:00
|
|
|
)
|
2015-09-18 17:25:55 +02:00
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
m_previewBeforeFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
|
|
|
m_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
2015-12-31 16:55:18 +01:00
|
|
|
m_previewAfterLabel->hide();
|
2015-10-29 17:34:59 +01:00
|
|
|
m_previewAfterFrame->hide();
|
2016-04-22 16:02:07 +02:00
|
|
|
m_encryptWidget->hide();
|
2016-07-15 11:25:47 +02:00
|
|
|
m_reuseHomeCheckBox->hide();
|
2016-07-15 13:09:07 +02:00
|
|
|
Calamares::JobQueue::instance()->globalStorage()->insert( "reuseHome", false );
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChoicePage::~ChoicePage()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2015-09-18 17:25:55 +02:00
|
|
|
void
|
2015-12-15 14:00:34 +01:00
|
|
|
ChoicePage::init( PartitionCoreModule* core )
|
2015-09-18 17:25:55 +02:00
|
|
|
{
|
2015-10-06 18:56:33 +02:00
|
|
|
m_core = core;
|
2017-08-28 11:36:21 +02:00
|
|
|
m_isEfi = PartUtils::isEfiSystem();
|
2015-09-18 17:25:55 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
setupChoices();
|
2015-09-18 17:25:55 +02:00
|
|
|
|
2015-11-26 15:31:06 +01:00
|
|
|
|
|
|
|
// We need to do this because a PCM revert invalidates the deviceModel.
|
|
|
|
connect( core, &PartitionCoreModule::reverted,
|
|
|
|
this, [=]
|
2015-10-06 18:56:33 +02:00
|
|
|
{
|
2015-11-26 15:31:06 +01:00
|
|
|
m_drivesCombo->setModel( core->deviceModel() );
|
|
|
|
m_drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex );
|
|
|
|
} );
|
|
|
|
m_drivesCombo->setModel( core->deviceModel() );
|
|
|
|
|
|
|
|
connect( m_drivesCombo,
|
|
|
|
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
|
|
|
this, &ChoicePage::applyDeviceChoice );
|
2015-10-29 17:34:59 +01:00
|
|
|
|
2016-04-22 16:02:07 +02:00
|
|
|
connect( m_encryptWidget, &EncryptWidget::stateChanged,
|
2016-05-05 12:26:28 +02:00
|
|
|
this, &ChoicePage::onEncryptWidgetStateChanged );
|
2016-07-15 11:25:47 +02:00
|
|
|
connect( m_reuseHomeCheckBox, &QCheckBox::stateChanged,
|
|
|
|
this, &ChoicePage::onHomeCheckBoxStateChanged );
|
2016-04-22 16:02:07 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
ChoicePage::applyDeviceChoice();
|
2015-09-18 17:25:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::setupChoices creates PrettyRadioButton objects for the action
|
|
|
|
* choices.
|
|
|
|
* @warning This must only run ONCE because it creates signal-slot connections for the
|
|
|
|
* actions. When an action is triggered, it runs action-specific code that may
|
|
|
|
* change the internal state of the PCM, and it updates the bottom preview (or
|
|
|
|
* split) widget.
|
|
|
|
* Synchronous loading ends here.
|
|
|
|
*/
|
2014-09-03 18:09:37 +02:00
|
|
|
void
|
2015-10-06 18:56:33 +02:00
|
|
|
ChoicePage::setupChoices()
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
|
|
|
// sample os-prober output:
|
|
|
|
// /dev/sda2:Windows 7 (loader):Windows:chain
|
|
|
|
// /dev/sda6::Arch:linux
|
|
|
|
//
|
|
|
|
// There are three possibilities we have to consider:
|
|
|
|
// - There are no operating systems present
|
|
|
|
// - There is one operating system present
|
|
|
|
// - There are multiple operating systems present
|
|
|
|
//
|
|
|
|
// There are three outcomes we have to provide:
|
|
|
|
// 1) Wipe+autopartition
|
|
|
|
// 2) Resize+autopartition
|
|
|
|
// 3) Manual
|
|
|
|
// TBD: upgrade option?
|
|
|
|
|
2016-01-29 17:10:28 +01:00
|
|
|
QSize iconSize( CalamaresUtils::defaultIconSize().width() * 2,
|
|
|
|
CalamaresUtils::defaultIconSize().height() * 2 );
|
2016-01-08 16:35:50 +01:00
|
|
|
m_grp = new QButtonGroup( this );
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
m_alongsideButton = new PrettyRadioButton;
|
|
|
|
m_alongsideButton->setIconSize( iconSize );
|
|
|
|
m_alongsideButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionAlongside,
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconSize ) );
|
2016-01-08 16:35:50 +01:00
|
|
|
m_grp->addButton( m_alongsideButton->buttonWidget(), Alongside );
|
2015-10-06 18:56:33 +02:00
|
|
|
|
2016-01-28 18:43:35 +01:00
|
|
|
m_eraseButton = new PrettyRadioButton;
|
2015-10-06 18:56:33 +02:00
|
|
|
m_eraseButton->setIconSize( iconSize );
|
|
|
|
m_eraseButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionEraseAuto,
|
2014-12-16 17:04:09 +01:00
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconSize ) );
|
2016-01-08 16:35:50 +01:00
|
|
|
m_grp->addButton( m_eraseButton->buttonWidget(), Erase );
|
2014-12-16 17:04:09 +01:00
|
|
|
|
2015-12-22 13:15:13 +01:00
|
|
|
m_replaceButton = new PrettyRadioButton;
|
2015-11-20 14:49:37 +01:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
m_replaceButton->setIconSize( iconSize );
|
|
|
|
m_replaceButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionReplaceOs,
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconSize ) );
|
2016-01-08 16:35:50 +01:00
|
|
|
m_grp->addButton( m_replaceButton->buttonWidget(), Replace );
|
2015-10-06 18:56:33 +02:00
|
|
|
|
|
|
|
m_itemsLayout->addWidget( m_alongsideButton );
|
|
|
|
m_itemsLayout->addWidget( m_replaceButton );
|
|
|
|
m_itemsLayout->addWidget( m_eraseButton );
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
m_somethingElseButton = new PrettyRadioButton;
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
m_somethingElseButton->setText( tr( "<strong>Manual partitioning</strong><br/>"
|
2015-12-31 00:56:46 +01:00
|
|
|
"You can create or resize partitions yourself." ) );
|
2015-10-06 18:56:33 +02:00
|
|
|
)
|
|
|
|
m_somethingElseButton->setIconSize( iconSize );
|
|
|
|
m_somethingElseButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionManual,
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconSize ) );
|
|
|
|
m_itemsLayout->addWidget( m_somethingElseButton );
|
2016-01-08 16:35:50 +01:00
|
|
|
m_grp->addButton( m_somethingElseButton->buttonWidget(), Manual );
|
2015-10-06 18:56:33 +02:00
|
|
|
|
|
|
|
m_itemsLayout->addStretch();
|
|
|
|
|
2016-01-08 16:35:50 +01:00
|
|
|
connect( m_grp, static_cast< void( QButtonGroup::* )( int, bool ) >( &QButtonGroup::buttonToggled ),
|
2016-01-08 16:37:45 +01:00
|
|
|
this, [ this ]( int id, bool checked )
|
2015-10-06 18:56:33 +02:00
|
|
|
{
|
2016-01-08 15:38:01 +01:00
|
|
|
if ( checked ) // An action was picked.
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2016-01-08 15:38:01 +01:00
|
|
|
m_choice = static_cast< Choice >( id );
|
2016-04-22 16:02:07 +02:00
|
|
|
updateNextEnabled();
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
emit actionChosen();
|
|
|
|
}
|
2016-01-08 15:38:01 +01:00
|
|
|
else // An action was unpicked, either on its own or because of another selection.
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2016-01-08 16:35:50 +01:00
|
|
|
if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must
|
2016-01-08 16:51:25 +01:00
|
|
|
{ // set m_choice to NoChoice and reset previews.
|
|
|
|
m_choice = NoChoice;
|
2016-04-22 16:02:07 +02:00
|
|
|
updateNextEnabled();
|
|
|
|
|
2016-01-08 15:38:01 +01:00
|
|
|
emit actionChosen();
|
|
|
|
}
|
2015-10-29 17:34:59 +01:00
|
|
|
}
|
2015-10-06 18:56:33 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
m_rightLayout->setStretchFactor( m_itemsLayout, 1 );
|
2015-10-29 17:34:59 +01:00
|
|
|
m_rightLayout->setStretchFactor( m_previewBeforeFrame, 0 );
|
|
|
|
m_rightLayout->setStretchFactor( m_previewAfterFrame, 0 );
|
|
|
|
|
|
|
|
connect( this, &ChoicePage::actionChosen,
|
|
|
|
this, [=]
|
|
|
|
{
|
|
|
|
Device* currd = selectedDevice();
|
|
|
|
if ( currd )
|
|
|
|
{
|
2015-12-17 18:02:14 +01:00
|
|
|
applyActionChoice( currentChoice() );
|
2015-10-29 17:34:59 +01:00
|
|
|
}
|
|
|
|
} );
|
2015-10-06 18:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::selectedDevice queries the device picker (which may be a combo or
|
|
|
|
* a list view) to get a pointer to the currently selected Device.
|
|
|
|
* @return a Device pointer, valid in the current state of the PCM, or nullptr if
|
|
|
|
* something goes wrong.
|
|
|
|
*/
|
|
|
|
Device*
|
|
|
|
ChoicePage::selectedDevice()
|
2015-10-06 18:56:33 +02:00
|
|
|
{
|
2015-10-23 17:45:28 +02:00
|
|
|
Device* currentDevice = nullptr;
|
2015-11-26 15:31:06 +01:00
|
|
|
currentDevice = m_core->deviceModel()->deviceForIndex(
|
|
|
|
m_core->deviceModel()->index(
|
|
|
|
m_drivesCombo->currentIndex() ) );
|
2015-10-06 18:56:33 +02:00
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
return currentDevice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief ChoicePage::applyDeviceChoice handler for the selected event of the device
|
|
|
|
* picker. Calls ChoicePage::selectedDevice() to get the current Device*, then
|
|
|
|
* updates the preview widget for the on-disk state (calls ChoicePage::
|
|
|
|
* updateDeviceStatePreview()) and finally sets up the available actions and their
|
|
|
|
* text by calling ChoicePage::setupActions().
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
ChoicePage::applyDeviceChoice()
|
|
|
|
{
|
2015-12-17 18:02:14 +01:00
|
|
|
if ( !selectedDevice() )
|
|
|
|
return;
|
2015-10-29 17:34:59 +01:00
|
|
|
|
2015-11-05 15:57:15 +01:00
|
|
|
if ( m_core->isDirty() )
|
2015-12-17 18:02:14 +01:00
|
|
|
{
|
2016-02-09 13:23:23 +01:00
|
|
|
ScanningDialog::run( QtConcurrent::run( [ = ]
|
|
|
|
{
|
|
|
|
QMutexLocker locker( &m_coreMutex );
|
|
|
|
m_core->revertAllDevices();
|
|
|
|
} ),
|
|
|
|
[ this ]
|
|
|
|
{
|
|
|
|
continueApplyDeviceChoice();
|
|
|
|
},
|
|
|
|
this );
|
2015-12-17 18:02:14 +01:00
|
|
|
}
|
2016-02-09 13:23:23 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
continueApplyDeviceChoice();
|
|
|
|
}
|
|
|
|
}
|
2015-12-17 18:02:14 +01:00
|
|
|
|
|
|
|
|
2016-02-09 13:23:23 +01:00
|
|
|
void
|
|
|
|
ChoicePage::continueApplyDeviceChoice()
|
|
|
|
{
|
|
|
|
Device* currd = selectedDevice();
|
2015-11-05 15:57:15 +01:00
|
|
|
|
2015-10-30 17:32:00 +01:00
|
|
|
// The device should only be nullptr immediately after a PCM reset.
|
|
|
|
// applyDeviceChoice() will be called again momentarily as soon as we handle the
|
|
|
|
// PartitionCoreModule::reverted signal.
|
|
|
|
if ( !currd )
|
|
|
|
return;
|
|
|
|
|
2015-12-17 18:02:14 +01:00
|
|
|
updateDeviceStatePreview();
|
2015-10-23 17:45:28 +02:00
|
|
|
// Preview setup done. Now we show/hide choices as needed.
|
|
|
|
|
2015-12-17 18:02:14 +01:00
|
|
|
setupActions();
|
2015-10-30 17:32:00 +01:00
|
|
|
|
2015-11-26 15:31:06 +01:00
|
|
|
m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex();
|
2015-11-05 15:57:15 +01:00
|
|
|
|
|
|
|
emit actionChosen();
|
2015-12-17 18:02:14 +01:00
|
|
|
emit deviceChosen();
|
2015-11-05 15:57:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2015-12-17 18:02:14 +01:00
|
|
|
ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
2015-11-05 15:57:15 +01:00
|
|
|
{
|
2015-12-31 15:14:42 +01:00
|
|
|
m_beforePartitionBarsView->selectionModel()->
|
|
|
|
disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) );
|
2015-12-31 16:58:50 +01:00
|
|
|
m_beforePartitionBarsView->selectionModel()->clearSelection();
|
|
|
|
m_beforePartitionBarsView->selectionModel()->clearCurrentIndex();
|
|
|
|
|
2015-11-05 15:57:15 +01:00
|
|
|
switch ( choice )
|
|
|
|
{
|
|
|
|
case Erase:
|
|
|
|
if ( m_core->isDirty() )
|
2015-12-17 18:02:14 +01:00
|
|
|
{
|
2015-12-31 14:40:40 +01:00
|
|
|
ScanningDialog::run( QtConcurrent::run( [ = ]
|
|
|
|
{
|
|
|
|
QMutexLocker locker( &m_coreMutex );
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
|
|
|
} ),
|
2015-12-31 16:12:52 +01:00
|
|
|
[ = ]
|
2015-12-31 15:39:32 +01:00
|
|
|
{
|
2016-07-15 11:25:47 +02:00
|
|
|
PartitionActions::doAutopartition( m_core,
|
|
|
|
selectedDevice(),
|
|
|
|
m_encryptWidget->passphrase() );
|
2016-01-07 17:23:29 +01:00
|
|
|
emit deviceChosen();
|
2015-12-31 15:39:32 +01:00
|
|
|
},
|
2015-12-31 14:40:40 +01:00
|
|
|
this );
|
2015-12-17 18:02:14 +01:00
|
|
|
}
|
2015-12-31 16:12:52 +01:00
|
|
|
else
|
2016-01-07 17:23:29 +01:00
|
|
|
{
|
2016-07-15 11:25:47 +02:00
|
|
|
PartitionActions::doAutopartition( m_core,
|
|
|
|
selectedDevice(),
|
|
|
|
m_encryptWidget->passphrase() );
|
2016-01-07 17:23:29 +01:00
|
|
|
emit deviceChosen();
|
|
|
|
}
|
2015-11-05 15:57:15 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
case Replace:
|
2015-12-17 18:02:14 +01:00
|
|
|
if ( m_core->isDirty() )
|
|
|
|
{
|
2015-12-31 14:14:47 +01:00
|
|
|
ScanningDialog::run( QtConcurrent::run( [ = ]
|
|
|
|
{
|
|
|
|
QMutexLocker locker( &m_coreMutex );
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
|
|
|
} ),
|
2015-12-31 15:39:32 +01:00
|
|
|
[]{},
|
2015-12-31 14:14:47 +01:00
|
|
|
this );
|
2015-12-17 18:02:14 +01:00
|
|
|
}
|
2016-04-22 16:02:07 +02:00
|
|
|
updateNextEnabled();
|
2015-12-17 18:02:14 +01:00
|
|
|
|
2015-12-31 15:12:40 +01:00
|
|
|
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
2016-07-15 11:25:47 +02:00
|
|
|
this, SLOT( onPartitionToReplaceSelected( QModelIndex, QModelIndex ) ),
|
2015-12-31 14:38:28 +01:00
|
|
|
Qt::UniqueConnection );
|
2015-12-18 15:03:31 +01:00
|
|
|
break;
|
2016-01-11 19:02:34 +01:00
|
|
|
|
|
|
|
case Alongside:
|
|
|
|
if ( m_core->isDirty() )
|
|
|
|
{
|
|
|
|
ScanningDialog::run( QtConcurrent::run( [ = ]
|
|
|
|
{
|
|
|
|
QMutexLocker locker( &m_coreMutex );
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
|
|
|
} ),
|
2016-01-14 16:03:39 +01:00
|
|
|
[this]
|
|
|
|
{
|
|
|
|
// We need to reupdate after reverting because the splitter widget is
|
|
|
|
// not a true view.
|
|
|
|
updateActionChoicePreview( currentChoice() );
|
2016-06-03 17:55:01 +02:00
|
|
|
updateNextEnabled();
|
2016-01-14 16:03:39 +01:00
|
|
|
},
|
2016-01-11 19:02:34 +01:00
|
|
|
this );
|
|
|
|
}
|
2016-04-22 16:02:07 +02:00
|
|
|
updateNextEnabled();
|
2016-01-11 19:02:34 +01:00
|
|
|
|
|
|
|
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
2016-01-12 14:04:25 +01:00
|
|
|
this, SLOT( doAlongsideSetupSplitter( QModelIndex, QModelIndex ) ),
|
2016-01-11 19:02:34 +01:00
|
|
|
Qt::UniqueConnection );
|
|
|
|
break;
|
2015-11-05 15:57:15 +01:00
|
|
|
case NoChoice:
|
|
|
|
case Manual:
|
|
|
|
break;
|
|
|
|
}
|
2015-12-23 19:14:47 +01:00
|
|
|
updateActionChoicePreview( currentChoice() );
|
2015-10-23 17:45:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-11 19:02:34 +01:00
|
|
|
void
|
2016-01-12 14:04:25 +01:00
|
|
|
ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
|
|
|
const QModelIndex& previous )
|
2016-01-11 19:02:34 +01:00
|
|
|
{
|
|
|
|
Q_UNUSED( previous );
|
|
|
|
if ( !current.isValid() )
|
|
|
|
return;
|
|
|
|
|
2016-01-12 11:42:38 +01:00
|
|
|
if ( !m_afterPartitionSplitterWidget )
|
|
|
|
return;
|
|
|
|
|
|
|
|
const PartitionModel* modl = qobject_cast< const PartitionModel* >( current.model() );
|
|
|
|
if ( !modl )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Partition* part = modl->partitionForIndex( current );
|
2016-02-26 13:00:08 +01:00
|
|
|
if ( !part )
|
|
|
|
{
|
|
|
|
cDebug() << Q_FUNC_INFO << "Partition not found for index" << current;
|
|
|
|
return;
|
|
|
|
}
|
2016-01-12 11:42:38 +01:00
|
|
|
|
|
|
|
double requiredStorageGB = Calamares::JobQueue::instance()
|
|
|
|
->globalStorage()
|
|
|
|
->value( "requiredStorageGB" )
|
|
|
|
.toDouble();
|
|
|
|
|
2016-07-15 11:36:44 +02:00
|
|
|
qint64 requiredStorageB = qRound64( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
|
2016-01-11 19:02:34 +01:00
|
|
|
|
2016-01-12 11:42:38 +01:00
|
|
|
m_afterPartitionSplitterWidget->setSplitPartition(
|
|
|
|
part->partitionPath(),
|
2016-07-15 11:39:27 +02:00
|
|
|
qRound64( part->used() * 1.1 ),
|
2016-01-12 11:42:38 +01:00
|
|
|
part->capacity() - requiredStorageB,
|
2017-09-08 13:50:09 +02:00
|
|
|
part->capacity() / 2 );
|
2016-01-11 19:02:34 +01:00
|
|
|
|
2016-02-19 16:57:49 +01:00
|
|
|
if ( m_isEfi )
|
|
|
|
setupEfiSystemPartitionSelector();
|
2016-02-19 16:51:24 +01:00
|
|
|
|
2016-01-11 19:02:34 +01:00
|
|
|
cDebug() << "Partition selected for Alongside.";
|
2016-05-17 08:46:56 +02:00
|
|
|
|
|
|
|
updateNextEnabled();
|
2016-01-13 17:43:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-05 12:26:28 +02:00
|
|
|
void
|
|
|
|
ChoicePage::onEncryptWidgetStateChanged()
|
|
|
|
{
|
|
|
|
EncryptWidget::State state = m_encryptWidget->state();
|
|
|
|
if ( m_choice == Erase )
|
|
|
|
{
|
|
|
|
if ( state == EncryptWidget::EncryptionConfirmed ||
|
|
|
|
state == EncryptWidget::EncryptionDisabled )
|
|
|
|
applyActionChoice( m_choice );
|
|
|
|
}
|
2016-05-27 16:29:03 +02:00
|
|
|
else if ( m_choice == Replace )
|
|
|
|
{
|
|
|
|
if ( m_beforePartitionBarsView &&
|
|
|
|
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() &&
|
|
|
|
( state == EncryptWidget::EncryptionConfirmed ||
|
|
|
|
state == EncryptWidget::EncryptionDisabled ) )
|
|
|
|
{
|
|
|
|
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
|
|
|
selectionModel()->
|
2016-07-15 11:25:47 +02:00
|
|
|
currentIndex() );
|
2016-05-27 16:29:03 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-05 12:26:28 +02:00
|
|
|
updateNextEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-15 11:25:47 +02:00
|
|
|
void
|
|
|
|
ChoicePage::onHomeCheckBoxStateChanged()
|
|
|
|
{
|
|
|
|
if ( currentChoice() == Replace &&
|
|
|
|
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() )
|
|
|
|
{
|
|
|
|
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
|
|
|
selectionModel()->
|
|
|
|
currentIndex() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-19 16:33:19 +01:00
|
|
|
void
|
|
|
|
ChoicePage::onLeave()
|
|
|
|
{
|
|
|
|
if ( m_choice == Alongside )
|
|
|
|
doAlongsideApply();
|
|
|
|
|
|
|
|
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) )
|
|
|
|
{
|
|
|
|
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
|
|
|
|
if ( efiSystemPartitions.count() == 1 )
|
|
|
|
{
|
|
|
|
PartitionInfo::setMountPoint(
|
|
|
|
efiSystemPartitions.first(),
|
|
|
|
Calamares::JobQueue::instance()->
|
|
|
|
globalStorage()->
|
|
|
|
value( "efiSystemPartition" ).toString() );
|
|
|
|
}
|
|
|
|
else if ( efiSystemPartitions.count() > 1 && m_efiComboBox )
|
|
|
|
{
|
|
|
|
PartitionInfo::setMountPoint(
|
|
|
|
efiSystemPartitions.at( m_efiComboBox->currentIndex() ),
|
|
|
|
Calamares::JobQueue::instance()->
|
|
|
|
globalStorage()->
|
|
|
|
value( "efiSystemPartition" ).toString() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cDebug() << "ERROR: cannot set up EFI system partition.\nESP count:"
|
|
|
|
<< efiSystemPartitions.count() << "\nm_efiComboBox:"
|
|
|
|
<< m_efiComboBox;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // installPath is then passed to the bootloader module for MBR setup
|
|
|
|
{
|
2017-01-18 19:38:12 +01:00
|
|
|
if ( !m_isEfi )
|
|
|
|
{
|
|
|
|
if ( m_bootloaderComboBox.isNull() )
|
|
|
|
{
|
|
|
|
m_core->setBootLoaderInstallPath( selectedDevice()->deviceNode() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QVariant var = m_bootloaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole );
|
|
|
|
if ( !var.isValid() )
|
|
|
|
return;
|
|
|
|
m_core->setBootLoaderInstallPath( var.toString() );
|
|
|
|
}
|
|
|
|
}
|
2016-02-19 16:33:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-13 17:43:59 +01:00
|
|
|
void
|
|
|
|
ChoicePage::doAlongsideApply()
|
|
|
|
{
|
|
|
|
Q_ASSERT( m_afterPartitionSplitterWidget->splitPartitionSize() >= 0 );
|
|
|
|
Q_ASSERT( m_afterPartitionSplitterWidget->newPartitionSize() >= 0 );
|
2016-01-11 19:02:34 +01:00
|
|
|
|
2016-06-29 18:21:38 +02:00
|
|
|
QMutexLocker locker( &m_coreMutex );
|
|
|
|
|
2016-01-13 17:43:59 +01:00
|
|
|
QString path = m_beforePartitionBarsView->
|
|
|
|
selectionModel()->
|
|
|
|
currentIndex().data( PartitionModel::PartitionPathRole ).toString();
|
|
|
|
|
|
|
|
DeviceModel* dm = m_core->deviceModel();
|
|
|
|
for ( int i = 0; i < dm->rowCount(); ++i )
|
|
|
|
{
|
|
|
|
Device* dev = dm->deviceForIndex( dm->index( i ) );
|
|
|
|
Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, path );
|
|
|
|
if ( candidate )
|
|
|
|
{
|
|
|
|
qint64 firstSector = candidate->firstSector();
|
|
|
|
qint64 oldLastSector = candidate->lastSector();
|
2016-01-13 18:23:50 +01:00
|
|
|
qint64 newLastSector = firstSector +
|
|
|
|
m_afterPartitionSplitterWidget->splitPartitionSize() /
|
2016-08-31 05:30:45 +02:00
|
|
|
dev->logicalSize();
|
2016-01-13 17:43:59 +01:00
|
|
|
|
|
|
|
m_core->resizePartition( dev, candidate, firstSector, newLastSector );
|
2016-06-07 17:05:22 +02:00
|
|
|
Partition* newPartition = nullptr;
|
|
|
|
QString luksPassphrase = m_encryptWidget->passphrase();
|
|
|
|
if ( luksPassphrase.isEmpty() )
|
|
|
|
{
|
|
|
|
newPartition = KPMHelpers::createNewPartition(
|
|
|
|
candidate->parent(),
|
|
|
|
*dev,
|
|
|
|
candidate->roles(),
|
2016-06-10 15:22:21 +02:00
|
|
|
FileSystem::typeForName( m_defaultFsType ),
|
2016-06-07 17:05:22 +02:00
|
|
|
newLastSector + 2, // *
|
|
|
|
oldLastSector
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newPartition = KPMHelpers::createNewEncryptedPartition(
|
|
|
|
candidate->parent(),
|
|
|
|
*dev,
|
|
|
|
candidate->roles(),
|
2016-06-10 15:22:21 +02:00
|
|
|
FileSystem::typeForName( m_defaultFsType ),
|
2016-06-07 17:05:22 +02:00
|
|
|
newLastSector + 2, // *
|
|
|
|
oldLastSector,
|
|
|
|
luksPassphrase
|
|
|
|
);
|
|
|
|
}
|
2016-01-13 17:43:59 +01:00
|
|
|
PartitionInfo::setMountPoint( newPartition, "/" );
|
|
|
|
PartitionInfo::setFormat( newPartition, true );
|
2016-01-14 18:47:02 +01:00
|
|
|
// * for some reason ped_disk_add_partition refuses to create a new partition
|
|
|
|
// if it starts on the sector immediately after the last used sector, so we
|
|
|
|
// have to push it one sector further, therefore + 2 instead of + 1.
|
2016-01-13 17:43:59 +01:00
|
|
|
|
|
|
|
m_core->createPartition( dev, newPartition );
|
|
|
|
|
|
|
|
m_core->dumpQueue();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-01-11 19:02:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-24 17:24:26 +01:00
|
|
|
void
|
2016-07-15 11:25:47 +02:00
|
|
|
ChoicePage::onPartitionToReplaceSelected( const QModelIndex& current,
|
|
|
|
const QModelIndex& previous )
|
2015-12-24 17:24:26 +01:00
|
|
|
{
|
2016-01-11 19:02:34 +01:00
|
|
|
Q_UNUSED( previous );
|
2015-12-31 14:50:43 +01:00
|
|
|
if ( !current.isValid() )
|
|
|
|
return;
|
|
|
|
|
2016-07-15 11:25:47 +02:00
|
|
|
// Reset state on selection regardless of whether this will be used.
|
|
|
|
m_reuseHomeCheckBox->setChecked( false );
|
|
|
|
|
|
|
|
doReplaceSelectedPartition( current );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
|
|
|
|
{
|
|
|
|
if ( !current.isValid() )
|
|
|
|
return;
|
|
|
|
|
2016-07-22 09:55:55 +02:00
|
|
|
QString* homePartitionPath = new QString();
|
2016-07-15 11:25:47 +02:00
|
|
|
bool doReuseHomePartition = m_reuseHomeCheckBox->isChecked();
|
|
|
|
|
|
|
|
// NOTE: using by-ref captures because we need to write homePartitionPath and
|
|
|
|
// doReuseHomePartition *after* the device revert, for later use.
|
|
|
|
ScanningDialog::run( QtConcurrent::run(
|
2016-07-22 09:55:55 +02:00
|
|
|
[ this, current ]( QString* homePartitionPath, bool doReuseHomePartition )
|
2015-12-24 17:24:26 +01:00
|
|
|
{
|
2015-12-31 14:38:28 +01:00
|
|
|
QMutexLocker locker( &m_coreMutex );
|
|
|
|
|
|
|
|
if ( m_core->isDirty() )
|
|
|
|
{
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
|
|
|
}
|
2016-03-10 13:16:18 +01:00
|
|
|
|
2017-08-28 11:36:21 +02:00
|
|
|
// if the partition is unallocated(free space), we don't replace it but create new one
|
2016-03-18 11:09:50 +01:00
|
|
|
// with the same first and last sector
|
2016-07-15 11:42:59 +02:00
|
|
|
Partition* selectedPartition =
|
|
|
|
static_cast< Partition* >( current.data( PartitionModel::PartitionPtrRole )
|
|
|
|
.value< void* >() );
|
2016-03-18 11:09:50 +01:00
|
|
|
if ( KPMHelpers::isPartitionFreeSpace( selectedPartition ) )
|
|
|
|
{
|
2016-07-15 11:25:47 +02:00
|
|
|
//NOTE: if the selected partition is free space, we don't deal with
|
|
|
|
// a separate /home partition at all because there's no existing
|
|
|
|
// rootfs to read it from.
|
2016-03-18 11:09:50 +01:00
|
|
|
PartitionRole newRoles = PartitionRole( PartitionRole::Primary );
|
|
|
|
PartitionNode* newParent = selectedDevice()->partitionTable();
|
|
|
|
|
|
|
|
if ( selectedPartition->parent() )
|
|
|
|
{
|
|
|
|
Partition* parent = dynamic_cast< Partition* >( selectedPartition->parent() );
|
|
|
|
if ( parent && parent->roles().has( PartitionRole::Extended ) )
|
|
|
|
{
|
|
|
|
newRoles = PartitionRole( PartitionRole::Logical );
|
|
|
|
newParent = KPMHelpers::findPartitionByPath( { selectedDevice() }, parent->partitionPath() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-27 16:29:03 +02:00
|
|
|
Partition* newPartition = nullptr;
|
|
|
|
if ( m_encryptWidget->state() == EncryptWidget::EncryptionConfirmed )
|
|
|
|
{
|
|
|
|
newPartition = KPMHelpers::createNewEncryptedPartition(
|
|
|
|
newParent,
|
|
|
|
*selectedDevice(),
|
|
|
|
newRoles,
|
2016-06-10 15:22:21 +02:00
|
|
|
FileSystem::typeForName( m_defaultFsType ),
|
2016-05-27 16:29:03 +02:00
|
|
|
selectedPartition->firstSector(),
|
|
|
|
selectedPartition->lastSector(),
|
|
|
|
m_encryptWidget->passphrase() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newPartition = KPMHelpers::createNewPartition(
|
2016-03-18 11:09:50 +01:00
|
|
|
newParent,
|
|
|
|
*selectedDevice(),
|
|
|
|
newRoles,
|
2016-06-10 15:22:21 +02:00
|
|
|
FileSystem::typeForName( m_defaultFsType ),
|
2016-03-18 11:09:50 +01:00
|
|
|
selectedPartition->firstSector(),
|
|
|
|
selectedPartition->lastSector() );
|
2016-05-27 16:29:03 +02:00
|
|
|
}
|
2016-03-18 11:09:50 +01:00
|
|
|
|
|
|
|
PartitionInfo::setMountPoint( newPartition, "/" );
|
|
|
|
PartitionInfo::setFormat( newPartition, true );
|
|
|
|
|
|
|
|
m_core->createPartition( selectedDevice(), newPartition);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We can't use the PartitionPtrRole because we need to make changes to the
|
|
|
|
// main DeviceModel, not the immutable copy.
|
|
|
|
QString partPath = current.data( PartitionModel::PartitionPathRole ).toString();
|
|
|
|
selectedPartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
2016-07-15 11:25:47 +02:00
|
|
|
partPath );
|
2016-03-18 11:09:50 +01:00
|
|
|
if ( selectedPartition )
|
2016-07-15 11:25:47 +02:00
|
|
|
{
|
2016-07-20 17:06:14 +02:00
|
|
|
// Find out is the selected partition has a rootfs. If yes, then make the
|
|
|
|
// m_reuseHomeCheckBox visible and set its text to something meaningful.
|
2016-07-22 09:55:55 +02:00
|
|
|
homePartitionPath->clear();
|
2016-09-01 14:21:05 +02:00
|
|
|
for ( const OsproberEntry& osproberEntry : m_core->osproberEntries() )
|
2016-07-20 17:06:14 +02:00
|
|
|
if ( osproberEntry.path == partPath )
|
2016-07-22 09:55:55 +02:00
|
|
|
*homePartitionPath = osproberEntry.homePath;
|
|
|
|
if ( homePartitionPath->isEmpty() )
|
2016-07-20 17:06:14 +02:00
|
|
|
doReuseHomePartition = false;
|
|
|
|
|
2016-03-18 11:09:50 +01:00
|
|
|
PartitionActions::doReplacePartition( m_core,
|
|
|
|
selectedDevice(),
|
2016-06-03 16:39:28 +02:00
|
|
|
selectedPartition,
|
|
|
|
m_encryptWidget->passphrase() );
|
2016-07-15 11:25:47 +02:00
|
|
|
Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
2016-07-22 09:55:55 +02:00
|
|
|
*homePartitionPath );
|
2016-07-15 13:09:07 +02:00
|
|
|
|
|
|
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
2016-07-22 09:55:55 +02:00
|
|
|
if ( homePartition && doReuseHomePartition )
|
2016-07-15 11:25:47 +02:00
|
|
|
{
|
|
|
|
PartitionInfo::setMountPoint( homePartition, "/home" );
|
2016-07-15 13:09:07 +02:00
|
|
|
gs->insert( "reuseHome", true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gs->insert( "reuseHome", false );
|
2016-07-15 11:25:47 +02:00
|
|
|
}
|
|
|
|
}
|
2016-03-18 11:09:50 +01:00
|
|
|
}
|
2016-07-22 09:55:55 +02:00
|
|
|
}, homePartitionPath, doReuseHomePartition ),
|
|
|
|
[ = ]
|
2015-12-31 16:21:50 +01:00
|
|
|
{
|
2016-07-22 09:55:55 +02:00
|
|
|
m_reuseHomeCheckBox->setVisible( !homePartitionPath->isEmpty() );
|
2016-07-22 14:50:10 +02:00
|
|
|
if ( !homePartitionPath->isEmpty() )
|
|
|
|
m_reuseHomeCheckBox->setText( tr( "Reuse %1 as home partition for %2." )
|
|
|
|
.arg( *homePartitionPath )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ShortProductName ) );
|
2016-07-22 09:55:55 +02:00
|
|
|
delete homePartitionPath;
|
2016-07-15 11:25:47 +02:00
|
|
|
|
2016-02-19 16:57:49 +01:00
|
|
|
if ( m_isEfi )
|
|
|
|
setupEfiSystemPartitionSelector();
|
2016-02-19 16:51:24 +01:00
|
|
|
|
2016-04-22 16:02:07 +02:00
|
|
|
updateNextEnabled();
|
2016-01-29 17:43:55 +01:00
|
|
|
if ( !m_bootloaderComboBox.isNull() &&
|
|
|
|
m_bootloaderComboBox->currentIndex() < 0 )
|
|
|
|
m_bootloaderComboBox->setCurrentIndex( m_lastSelectedDeviceIndex );
|
2015-12-31 16:21:50 +01:00
|
|
|
}, this );
|
2015-12-24 17:24:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::updateDeviceStatePreview clears and rebuilds the contents of the
|
|
|
|
* preview widget for the current on-disk state. This also triggers a rescan in the
|
|
|
|
* PCM to get a Device* copy that's unaffected by subsequent PCM changes.
|
|
|
|
* @param currentDevice a pointer to the selected Device.
|
|
|
|
*/
|
2015-10-23 17:45:28 +02:00
|
|
|
void
|
2015-12-17 18:02:14 +01:00
|
|
|
ChoicePage::updateDeviceStatePreview()
|
2015-10-23 17:45:28 +02:00
|
|
|
{
|
2015-10-29 17:34:59 +01:00
|
|
|
//FIXME: this needs to be made async because the rescan can block the UI thread for
|
|
|
|
// a while. --Teo 10/2015
|
2015-12-17 18:02:14 +01:00
|
|
|
Device* currentDevice = selectedDevice();
|
2015-10-23 17:45:28 +02:00
|
|
|
Q_ASSERT( currentDevice );
|
|
|
|
QMutexLocker locker( &m_previewsMutex );
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
cDebug() << "Updating partitioning state widgets.";
|
|
|
|
qDeleteAll( m_previewBeforeFrame->children() );
|
2015-10-23 17:45:28 +02:00
|
|
|
|
2017-09-07 10:04:50 +02:00
|
|
|
auto layout = m_previewBeforeFrame->layout();
|
|
|
|
if ( layout )
|
|
|
|
layout->deleteLater(); // Doesn't like nullptr
|
|
|
|
|
|
|
|
layout = new QVBoxLayout;
|
2015-10-29 17:34:59 +01:00
|
|
|
m_previewBeforeFrame->setLayout( layout );
|
2015-12-03 19:40:06 +01:00
|
|
|
CalamaresUtils::unmarginLayout( layout );
|
|
|
|
layout->setSpacing( 6 );
|
2015-10-06 18:56:33 +02:00
|
|
|
|
2016-02-10 14:59:17 +01:00
|
|
|
PartitionBarsView::NestedPartitionsMode mode = Calamares::JobQueue::instance()->globalStorage()->
|
|
|
|
value( "drawNestedPartitions" ).toBool() ?
|
|
|
|
PartitionBarsView::DrawNestedPartitions :
|
|
|
|
PartitionBarsView::NoNestedPartitions;
|
2015-12-17 15:39:52 +01:00
|
|
|
m_beforePartitionBarsView = new PartitionBarsView( m_previewBeforeFrame );
|
2016-02-10 14:59:17 +01:00
|
|
|
m_beforePartitionBarsView->setNestedPartitionsMode( mode );
|
2015-12-17 15:39:52 +01:00
|
|
|
m_beforePartitionLabelsView = new PartitionLabelsView( m_previewBeforeFrame );
|
2016-02-11 16:00:36 +01:00
|
|
|
m_beforePartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
2015-10-23 17:45:28 +02:00
|
|
|
|
2016-09-09 11:25:04 +02:00
|
|
|
Device* deviceBefore = m_core->immutableDeviceCopy( currentDevice );
|
2015-10-23 17:45:28 +02:00
|
|
|
|
2015-12-17 15:39:52 +01:00
|
|
|
PartitionModel* model = new PartitionModel( m_beforePartitionBarsView );
|
2015-12-15 14:00:34 +01:00
|
|
|
model->init( deviceBefore, m_core->osproberEntries() );
|
2015-10-23 17:45:28 +02:00
|
|
|
|
|
|
|
// The QObject parents tree is meaningful for memory management here,
|
|
|
|
// see qDeleteAll above.
|
2017-09-07 10:04:50 +02:00
|
|
|
deviceBefore->setParent( model ); // Can't reparent across threads
|
2015-12-17 15:39:52 +01:00
|
|
|
model->setParent( m_beforePartitionBarsView );
|
2015-10-23 17:45:28 +02:00
|
|
|
|
2015-12-17 15:39:52 +01:00
|
|
|
m_beforePartitionBarsView->setModel( model );
|
|
|
|
m_beforePartitionLabelsView->setModel( model );
|
2015-12-17 13:45:11 +01:00
|
|
|
|
|
|
|
// Make the bars and labels view use the same selectionModel.
|
2015-12-17 15:39:52 +01:00
|
|
|
auto sm = m_beforePartitionLabelsView->selectionModel();
|
|
|
|
m_beforePartitionLabelsView->setSelectionModel( m_beforePartitionBarsView->selectionModel() );
|
2017-09-07 10:04:50 +02:00
|
|
|
if ( sm )
|
|
|
|
sm->deleteLater();
|
2015-12-17 13:45:11 +01:00
|
|
|
|
|
|
|
switch ( m_choice )
|
|
|
|
{
|
|
|
|
case Replace:
|
|
|
|
case Alongside:
|
2015-12-17 15:39:52 +01:00
|
|
|
m_beforePartitionBarsView->setSelectionMode( QAbstractItemView::SingleSelection );
|
|
|
|
m_beforePartitionLabelsView->setSelectionMode( QAbstractItemView::SingleSelection );
|
2015-12-17 13:45:11 +01:00
|
|
|
break;
|
|
|
|
default:
|
2015-12-17 15:39:52 +01:00
|
|
|
m_beforePartitionBarsView->setSelectionMode( QAbstractItemView::NoSelection );
|
|
|
|
m_beforePartitionLabelsView->setSelectionMode( QAbstractItemView::NoSelection );
|
2015-12-17 13:45:11 +01:00
|
|
|
}
|
2015-12-16 18:23:29 +01:00
|
|
|
|
2015-12-17 15:39:52 +01:00
|
|
|
layout->addWidget( m_beforePartitionBarsView );
|
|
|
|
layout->addWidget( m_beforePartitionLabelsView );
|
2015-10-23 17:45:28 +02:00
|
|
|
}
|
2015-10-06 18:56:33 +02:00
|
|
|
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::updateActionChoicePreview clears and rebuilds the contents of the
|
|
|
|
* preview widget for the current PCM-proposed state. No rescans here, this should
|
|
|
|
* be immediate.
|
|
|
|
* @param currentDevice a pointer to the selected Device.
|
|
|
|
* @param choice the chosen partitioning action.
|
|
|
|
*/
|
|
|
|
void
|
2015-12-17 18:02:14 +01:00
|
|
|
ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2015-12-17 18:02:14 +01:00
|
|
|
Device* currentDevice = selectedDevice();
|
2015-10-29 17:34:59 +01:00
|
|
|
Q_ASSERT( currentDevice );
|
2015-12-17 13:45:11 +01:00
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
QMutexLocker locker( &m_previewsMutex );
|
|
|
|
|
|
|
|
cDebug() << "Updating partitioning preview widgets.";
|
|
|
|
qDeleteAll( m_previewAfterFrame->children() );
|
2017-09-07 10:04:50 +02:00
|
|
|
|
|
|
|
auto oldlayout = m_previewAfterFrame->layout();
|
|
|
|
if ( oldlayout )
|
|
|
|
oldlayout->deleteLater();
|
2015-10-29 17:34:59 +01:00
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout;
|
|
|
|
m_previewAfterFrame->setLayout( layout );
|
2015-12-03 19:40:06 +01:00
|
|
|
CalamaresUtils::unmarginLayout( layout );
|
|
|
|
layout->setSpacing( 6 );
|
2015-10-29 17:34:59 +01:00
|
|
|
|
2016-02-10 17:02:42 +01:00
|
|
|
PartitionBarsView::NestedPartitionsMode mode = Calamares::JobQueue::instance()->globalStorage()->
|
|
|
|
value( "drawNestedPartitions" ).toBool() ?
|
|
|
|
PartitionBarsView::DrawNestedPartitions :
|
|
|
|
PartitionBarsView::NoNestedPartitions;
|
|
|
|
|
2016-07-15 11:32:34 +02:00
|
|
|
m_reuseHomeCheckBox->hide();
|
2016-07-15 13:09:07 +02:00
|
|
|
Calamares::JobQueue::instance()->globalStorage()->insert( "reuseHome", false );
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
switch ( choice )
|
|
|
|
{
|
|
|
|
case Alongside:
|
2016-01-11 19:02:34 +01:00
|
|
|
{
|
2016-09-26 13:14:54 +02:00
|
|
|
if ( m_enableEncryptionWidget )
|
|
|
|
m_encryptWidget->show();
|
2016-01-25 16:58:54 +01:00
|
|
|
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
|
|
|
m_selectLabel->setText( tr( "<strong>Select a partition to shrink, "
|
|
|
|
"then drag the bottom bar to resize</strong>" ) );
|
2016-01-11 19:02:34 +01:00
|
|
|
m_selectLabel->show();
|
|
|
|
|
2016-01-11 19:07:48 +01:00
|
|
|
m_afterPartitionSplitterWidget = new PartitionSplitterWidget( m_previewAfterFrame );
|
2016-02-10 17:02:42 +01:00
|
|
|
m_afterPartitionSplitterWidget->init( selectedDevice(), mode == PartitionBarsView::DrawNestedPartitions );
|
2016-01-11 19:02:34 +01:00
|
|
|
layout->addWidget( m_afterPartitionSplitterWidget );
|
|
|
|
|
2016-01-11 19:07:48 +01:00
|
|
|
QLabel* sizeLabel = new QLabel( m_previewAfterFrame );
|
2016-01-11 19:02:34 +01:00
|
|
|
layout->addWidget( sizeLabel );
|
|
|
|
sizeLabel->setWordWrap( true );
|
|
|
|
connect( m_afterPartitionSplitterWidget, &PartitionSplitterWidget::partitionResized,
|
2016-07-15 11:36:44 +02:00
|
|
|
this, [ this, sizeLabel ]( const QString& path,
|
|
|
|
qint64 size,
|
|
|
|
qint64 sizeNext )
|
2016-01-11 19:02:34 +01:00
|
|
|
{
|
2016-07-15 11:36:44 +02:00
|
|
|
Q_UNUSED( path )
|
2016-01-11 19:02:34 +01:00
|
|
|
sizeLabel->setText( tr( "%1 will be shrunk to %2MB and a new "
|
|
|
|
"%3MB partition will be created for %4." )
|
|
|
|
.arg( m_beforePartitionBarsView->selectionModel()->currentIndex().data().toString() )
|
|
|
|
.arg( size / ( 1024 * 1024 ) )
|
|
|
|
.arg( sizeNext / ( 1024 * 1024 ) )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ShortProductName ) );
|
2016-01-11 19:02:34 +01:00
|
|
|
} );
|
|
|
|
|
|
|
|
m_previewAfterFrame->show();
|
|
|
|
m_previewAfterLabel->show();
|
|
|
|
|
2016-01-15 18:20:40 +01:00
|
|
|
SelectionFilter filter = [ this ]( const QModelIndex& index )
|
|
|
|
{
|
2016-07-15 11:42:59 +02:00
|
|
|
return PartUtils::canBeResized(
|
|
|
|
static_cast< Partition* >(
|
|
|
|
index.data( PartitionModel::PartitionPtrRole )
|
|
|
|
.value< void* >() ) );
|
2016-01-15 18:20:40 +01:00
|
|
|
};
|
|
|
|
m_beforePartitionBarsView->setSelectionFilter( filter );
|
|
|
|
m_beforePartitionLabelsView->setSelectionFilter( filter );
|
|
|
|
|
2016-01-11 19:02:34 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-10-29 17:34:59 +01:00
|
|
|
case Erase:
|
|
|
|
case Replace:
|
|
|
|
{
|
2016-09-26 13:14:54 +02:00
|
|
|
if ( m_enableEncryptionWidget )
|
|
|
|
m_encryptWidget->show();
|
2016-01-25 16:58:54 +01:00
|
|
|
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
2015-12-24 13:06:35 +01:00
|
|
|
m_afterPartitionBarsView = new PartitionBarsView( m_previewAfterFrame );
|
2016-02-10 14:59:17 +01:00
|
|
|
m_afterPartitionBarsView->setNestedPartitionsMode( mode );
|
2015-12-24 13:06:35 +01:00
|
|
|
m_afterPartitionLabelsView = new PartitionLabelsView( m_previewAfterFrame );
|
2016-02-11 16:00:36 +01:00
|
|
|
m_afterPartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
2017-07-04 00:07:18 +02:00
|
|
|
m_afterPartitionLabelsView->setCustomNewRootLabel( *Calamares::Branding::BootloaderEntryName );
|
2015-10-29 17:34:59 +01:00
|
|
|
|
2015-12-17 19:10:47 +01:00
|
|
|
PartitionModel* model = m_core->partitionModelForDevice( selectedDevice() );
|
2015-10-29 17:34:59 +01:00
|
|
|
|
|
|
|
// The QObject parents tree is meaningful for memory management here,
|
|
|
|
// see qDeleteAll above.
|
2015-12-24 13:06:35 +01:00
|
|
|
m_afterPartitionBarsView->setModel( model );
|
|
|
|
m_afterPartitionLabelsView->setModel( model );
|
|
|
|
m_afterPartitionBarsView->setSelectionMode( QAbstractItemView::NoSelection );
|
|
|
|
m_afterPartitionLabelsView->setSelectionMode( QAbstractItemView::NoSelection );
|
2015-12-16 18:28:22 +01:00
|
|
|
|
2015-12-24 13:06:35 +01:00
|
|
|
layout->addWidget( m_afterPartitionBarsView );
|
|
|
|
layout->addWidget( m_afterPartitionLabelsView );
|
2015-10-29 17:34:59 +01:00
|
|
|
|
2016-01-28 18:43:35 +01:00
|
|
|
if ( !m_isEfi )
|
|
|
|
{
|
|
|
|
QWidget* eraseWidget = new QWidget;
|
|
|
|
|
|
|
|
QHBoxLayout* eraseLayout = new QHBoxLayout;
|
|
|
|
eraseWidget->setLayout( eraseLayout );
|
|
|
|
eraseLayout->setContentsMargins( 0, 0, 0, 0 );
|
|
|
|
QLabel* eraseBootloaderLabel = new QLabel( eraseWidget );
|
|
|
|
eraseLayout->addWidget( eraseBootloaderLabel );
|
|
|
|
eraseBootloaderLabel->setText( tr( "Boot loader location:" ) );
|
|
|
|
|
2016-01-29 17:07:08 +01:00
|
|
|
m_bootloaderComboBox = createBootloaderComboBox( eraseWidget );
|
|
|
|
connect( m_core, &PartitionCoreModule::deviceReverted,
|
|
|
|
this, [ this ]( Device* dev )
|
|
|
|
{
|
2016-07-15 11:46:28 +02:00
|
|
|
Q_UNUSED( dev )
|
2016-01-29 17:43:55 +01:00
|
|
|
if ( !m_bootloaderComboBox.isNull() )
|
2016-01-29 17:07:08 +01:00
|
|
|
{
|
|
|
|
if ( m_bootloaderComboBox->model() != m_core->bootLoaderModel() )
|
|
|
|
m_bootloaderComboBox->setModel( m_core->bootLoaderModel() );
|
|
|
|
|
|
|
|
m_bootloaderComboBox->setCurrentIndex( m_lastSelectedDeviceIndex );
|
|
|
|
}
|
|
|
|
}, Qt::QueuedConnection );
|
|
|
|
// ^ Must be Queued so it's sure to run when the widget is already visible.
|
|
|
|
|
|
|
|
eraseLayout->addWidget( m_bootloaderComboBox );
|
|
|
|
eraseBootloaderLabel->setBuddy( m_bootloaderComboBox );
|
2016-01-28 18:43:35 +01:00
|
|
|
eraseLayout->addStretch();
|
|
|
|
|
|
|
|
layout->addWidget( eraseWidget );
|
|
|
|
}
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
m_previewAfterFrame->show();
|
2015-12-31 16:55:18 +01:00
|
|
|
m_previewAfterLabel->show();
|
2015-12-22 12:41:47 +01:00
|
|
|
|
|
|
|
if ( m_choice == Erase )
|
|
|
|
m_selectLabel->hide();
|
|
|
|
else
|
|
|
|
{
|
2016-02-12 15:02:30 +01:00
|
|
|
SelectionFilter filter = [ this ]( const QModelIndex& index )
|
|
|
|
{
|
2016-07-15 11:42:59 +02:00
|
|
|
return PartUtils::canBeReplaced(
|
|
|
|
static_cast< Partition* >(
|
|
|
|
index.data( PartitionModel::PartitionPtrRole )
|
|
|
|
.value< void* >() ) );
|
2016-02-12 15:02:30 +01:00
|
|
|
};
|
|
|
|
m_beforePartitionBarsView->setSelectionFilter( filter );
|
|
|
|
m_beforePartitionLabelsView->setSelectionFilter( filter );
|
|
|
|
|
2015-12-22 12:41:47 +01:00
|
|
|
m_selectLabel->show();
|
2016-01-25 16:58:54 +01:00
|
|
|
m_selectLabel->setText( tr( "<strong>Select a partition to install on</strong>" ) );
|
2015-12-22 12:41:47 +01:00
|
|
|
}
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NoChoice:
|
|
|
|
case Manual:
|
2015-12-22 12:41:47 +01:00
|
|
|
m_selectLabel->hide();
|
2015-10-29 17:34:59 +01:00
|
|
|
m_previewAfterFrame->hide();
|
2016-01-25 16:58:54 +01:00
|
|
|
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
2015-12-31 16:55:18 +01:00
|
|
|
m_previewAfterLabel->hide();
|
2016-04-22 16:02:07 +02:00
|
|
|
m_encryptWidget->hide();
|
2015-10-29 17:34:59 +01:00
|
|
|
break;
|
|
|
|
}
|
2015-12-17 13:45:11 +01:00
|
|
|
|
2016-02-19 16:33:19 +01:00
|
|
|
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) )
|
|
|
|
{
|
|
|
|
QHBoxLayout* efiLayout = new QHBoxLayout;
|
|
|
|
layout->addLayout( efiLayout );
|
|
|
|
m_efiLabel = new QLabel( m_previewAfterFrame );
|
|
|
|
efiLayout->addWidget( m_efiLabel );
|
|
|
|
m_efiComboBox = new QComboBox( m_previewAfterFrame );
|
|
|
|
efiLayout->addWidget( m_efiComboBox );
|
|
|
|
m_efiLabel->setBuddy( m_efiComboBox );
|
|
|
|
m_efiComboBox->hide();
|
|
|
|
efiLayout->addStretch();
|
|
|
|
}
|
|
|
|
|
2015-12-17 13:45:11 +01:00
|
|
|
// Also handle selection behavior on beforeFrame.
|
|
|
|
QAbstractItemView::SelectionMode previewSelectionMode;
|
|
|
|
switch ( m_choice )
|
|
|
|
{
|
|
|
|
case Replace:
|
|
|
|
case Alongside:
|
|
|
|
previewSelectionMode = QAbstractItemView::SingleSelection;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
previewSelectionMode = QAbstractItemView::NoSelection;
|
|
|
|
}
|
|
|
|
|
2015-12-31 15:02:46 +01:00
|
|
|
m_beforePartitionBarsView->setSelectionMode( previewSelectionMode );
|
|
|
|
m_beforePartitionLabelsView->setSelectionMode( previewSelectionMode );
|
2015-10-29 17:34:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-19 16:57:49 +01:00
|
|
|
void
|
|
|
|
ChoicePage::setupEfiSystemPartitionSelector()
|
|
|
|
{
|
|
|
|
Q_ASSERT( m_isEfi );
|
|
|
|
|
|
|
|
// Only the already existing ones:
|
|
|
|
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
|
|
|
|
|
|
|
|
if ( efiSystemPartitions.count() == 0 ) //should never happen
|
|
|
|
{
|
|
|
|
m_efiLabel->setText(
|
|
|
|
tr( "An EFI system partition cannot be found anywhere "
|
|
|
|
"on this system. Please go back and use manual "
|
|
|
|
"partitioning to set up %1." )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ShortProductName ) );
|
2016-04-22 16:02:07 +02:00
|
|
|
updateNextEnabled();
|
2016-02-19 16:57:49 +01:00
|
|
|
}
|
|
|
|
else if ( efiSystemPartitions.count() == 1 ) //probably most usual situation
|
|
|
|
{
|
|
|
|
m_efiLabel->setText(
|
|
|
|
tr( "The EFI system partition at %1 will be used for "
|
|
|
|
"starting %2." )
|
|
|
|
.arg( efiSystemPartitions.first()->partitionPath() )
|
2017-07-04 00:07:18 +02:00
|
|
|
.arg( *Calamares::Branding::ShortProductName ) );
|
2016-02-19 16:57:49 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_efiComboBox->show();
|
|
|
|
m_efiLabel->setText( tr( "EFI system partition:" ) );
|
|
|
|
for ( int i = 0; i < efiSystemPartitions.count(); ++i )
|
|
|
|
{
|
|
|
|
Partition* efiPartition = efiSystemPartitions.at( i );
|
|
|
|
m_efiComboBox->addItem( efiPartition->partitionPath(), i );
|
|
|
|
|
|
|
|
// We pick an ESP on the currently selected device, if possible
|
|
|
|
if ( efiPartition->devicePath() == selectedDevice()->deviceNode() &&
|
|
|
|
efiPartition->number() == 1 )
|
|
|
|
m_efiComboBox->setCurrentIndex( i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-28 18:43:35 +01:00
|
|
|
QComboBox*
|
|
|
|
ChoicePage::createBootloaderComboBox( QWidget* parent )
|
|
|
|
{
|
|
|
|
QComboBox* bcb = new QComboBox( parent );
|
|
|
|
bcb->setModel( m_core->bootLoaderModel() );
|
|
|
|
|
|
|
|
// When the chosen bootloader device changes, we update the choice in the PCM
|
|
|
|
connect( bcb, static_cast< void (QComboBox::*)(int) >( &QComboBox::currentIndexChanged ),
|
2017-01-10 14:42:36 +01:00
|
|
|
this, [this]( int newIndex )
|
2016-01-28 18:43:35 +01:00
|
|
|
{
|
2016-01-29 17:07:08 +01:00
|
|
|
QComboBox* bcb = qobject_cast< QComboBox* >( sender() );
|
|
|
|
if ( bcb )
|
2016-01-29 16:49:21 +01:00
|
|
|
{
|
2016-01-29 17:07:08 +01:00
|
|
|
QVariant var = bcb->itemData( newIndex, BootLoaderModel::BootLoaderPathRole );
|
|
|
|
if ( !var.isValid() )
|
|
|
|
return;
|
|
|
|
m_core->setBootLoaderInstallPath( var.toString() );
|
2016-01-29 16:49:21 +01:00
|
|
|
}
|
2016-01-29 17:07:08 +01:00
|
|
|
} );
|
2016-01-28 18:43:35 +01:00
|
|
|
|
|
|
|
return bcb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-07 10:55:26 +02:00
|
|
|
static inline void
|
|
|
|
force_uncheck(QButtonGroup* grp, PrettyRadioButton* button)
|
|
|
|
{
|
|
|
|
button->hide();
|
|
|
|
grp->setExclusive( false );
|
|
|
|
button->buttonWidget()->setChecked( false );
|
|
|
|
grp->setExclusive( true );
|
|
|
|
}
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::setupActions happens every time a new Device* is selected in the
|
|
|
|
* device picker. Sets up the text and visibility of the partitioning actions based
|
|
|
|
* on the currently selected Device*, bootloader and os-prober output.
|
|
|
|
* @param currentDevice
|
|
|
|
*/
|
2015-10-23 17:45:28 +02:00
|
|
|
void
|
2015-12-17 18:02:14 +01:00
|
|
|
ChoicePage::setupActions()
|
2015-10-23 17:45:28 +02:00
|
|
|
{
|
2015-12-17 18:02:14 +01:00
|
|
|
Device* currentDevice = selectedDevice();
|
2015-11-27 14:47:52 +01:00
|
|
|
OsproberEntryList osproberEntriesForCurrentDevice =
|
|
|
|
getOsproberEntriesForDevice( currentDevice );
|
|
|
|
|
2015-11-27 17:25:47 +01:00
|
|
|
if ( currentDevice->partitionTable() )
|
|
|
|
m_deviceInfoWidget->setPartitionTableType( currentDevice->partitionTable()->type() );
|
|
|
|
else
|
|
|
|
m_deviceInfoWidget->setPartitionTableType( PartitionTable::unknownTableType );
|
|
|
|
|
2016-02-12 16:48:29 +01:00
|
|
|
bool atLeastOneCanBeResized = false;
|
2017-09-07 10:55:26 +02:00
|
|
|
bool atLeastOneCanBeReplaced = false;
|
|
|
|
bool atLeastOneIsMounted = false; // Suppress 'erase' if so
|
2016-02-12 16:48:29 +01:00
|
|
|
|
|
|
|
for ( auto it = PartitionIterator::begin( currentDevice );
|
|
|
|
it != PartitionIterator::end( currentDevice ); ++it )
|
|
|
|
{
|
|
|
|
if ( PartUtils::canBeResized( *it ) )
|
|
|
|
atLeastOneCanBeResized = true;
|
2016-03-18 12:26:41 +01:00
|
|
|
if ( PartUtils::canBeReplaced( *it ) )
|
|
|
|
atLeastOneCanBeReplaced = true;
|
2017-09-07 10:55:26 +02:00
|
|
|
if ( (*it)->isMounted() )
|
|
|
|
atLeastOneIsMounted = true;
|
2016-03-18 12:26:41 +01:00
|
|
|
}
|
|
|
|
|
2015-11-27 14:47:52 +01:00
|
|
|
if ( osproberEntriesForCurrentDevice.count() == 0 )
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
2014-11-11 17:09:33 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
2015-11-27 14:47:52 +01:00
|
|
|
m_messageLabel->setText( tr( "This storage device does not seem to have an operating system on it. "
|
2015-12-03 14:39:23 +01:00
|
|
|
"What would you like to do?<br/>"
|
|
|
|
"You will be able to review and confirm your choices "
|
|
|
|
"before any change is made to the storage device." ) );
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-12-15 17:21:45 +01:00
|
|
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
2015-12-21 11:28:11 +01:00
|
|
|
"This will <font color=\"red\">delete</font> all data "
|
|
|
|
"currently present on the selected storage device." ) );
|
2016-03-18 12:26:41 +01:00
|
|
|
|
|
|
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
|
|
|
"The installer will shrink a partition to make room for %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2016-03-18 12:26:41 +01:00
|
|
|
|
|
|
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
|
|
|
"Replaces a partition with %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
)
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
m_replaceButton->hide();
|
|
|
|
m_alongsideButton->hide();
|
2016-01-08 16:43:58 +01:00
|
|
|
m_grp->setExclusive( false );
|
2016-01-08 14:50:00 +01:00
|
|
|
m_replaceButton->buttonWidget()->setChecked( false );
|
|
|
|
m_alongsideButton->buttonWidget()->setChecked( false );
|
2016-01-08 16:43:58 +01:00
|
|
|
m_grp->setExclusive( true );
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
2015-11-27 14:47:52 +01:00
|
|
|
else if ( osproberEntriesForCurrentDevice.count() == 1 )
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
2015-11-27 14:47:52 +01:00
|
|
|
QString osName = osproberEntriesForCurrentDevice.first().prettyName;
|
2014-09-23 17:42:11 +02:00
|
|
|
|
|
|
|
if ( !osName.isEmpty() )
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
2014-11-11 17:09:33 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
2015-11-27 14:47:52 +01:00
|
|
|
m_messageLabel->setText( tr( "This storage device has %1 on it. "
|
2015-12-04 16:23:59 +01:00
|
|
|
"What would you like to do?<br/>"
|
|
|
|
"You will be able to review and confirm your choices "
|
|
|
|
"before any change is made to the storage device." )
|
2014-11-11 17:09:33 +01:00
|
|
|
.arg( osName ) );
|
|
|
|
|
2015-12-15 17:28:21 +01:00
|
|
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
2015-12-21 11:24:06 +01:00
|
|
|
"The installer will shrink a partition to make room for %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
|
2015-12-15 17:21:45 +01:00
|
|
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
2015-12-21 11:28:11 +01:00
|
|
|
"This will <font color=\"red\">delete</font> all data "
|
|
|
|
"currently present on the selected storage device." ) );
|
2014-12-16 17:04:09 +01:00
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
|
2015-12-15 17:23:13 +01:00
|
|
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
2015-12-21 11:26:12 +01:00
|
|
|
"Replaces a partition with %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
)
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
2014-09-19 16:27:39 +02:00
|
|
|
else
|
2014-09-23 17:42:11 +02:00
|
|
|
{
|
2014-11-11 17:09:33 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
2015-11-27 14:47:52 +01:00
|
|
|
m_messageLabel->setText( tr( "This storage device already has an operating system on it. "
|
2015-12-04 16:23:59 +01:00
|
|
|
"What would you like to do?<br/>"
|
|
|
|
"You will be able to review and confirm your choices "
|
|
|
|
"before any change is made to the storage device." ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
|
2015-12-15 17:28:21 +01:00
|
|
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
2015-12-21 11:24:06 +01:00
|
|
|
"The installer will shrink a partition to make room for %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
|
2015-12-15 17:21:45 +01:00
|
|
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
2015-12-21 11:28:11 +01:00
|
|
|
"This will <font color=\"red\">delete</font> all data "
|
|
|
|
"currently present on the selected storage device." ) );
|
2014-12-16 17:04:09 +01:00
|
|
|
|
2015-12-15 17:23:13 +01:00
|
|
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
2015-12-21 11:26:12 +01:00
|
|
|
"Replaces a partition with %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
)
|
2014-09-23 17:42:11 +02:00
|
|
|
}
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-27 14:47:52 +01:00
|
|
|
// osproberEntriesForCurrentDevice has at least 2 items.
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2014-11-11 17:09:33 +01:00
|
|
|
CALAMARES_RETRANSLATE(
|
2015-11-27 14:47:52 +01:00
|
|
|
m_messageLabel->setText( tr( "This storage device has multiple operating systems on it. "
|
2015-12-04 16:23:59 +01:00
|
|
|
"What would you like to do?<br/>"
|
|
|
|
"You will be able to review and confirm your choices "
|
|
|
|
"before any change is made to the storage device." ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
|
2015-12-15 17:28:21 +01:00
|
|
|
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
|
2015-12-21 11:24:06 +01:00
|
|
|
"The installer will shrink a partition to make room for %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-09-22 17:21:50 +02:00
|
|
|
|
2015-12-15 17:21:45 +01:00
|
|
|
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
|
2015-12-21 11:28:11 +01:00
|
|
|
"This will <font color=\"red\">delete</font> all data "
|
|
|
|
"currently present on the selected storage device." ) );
|
2014-12-16 17:04:09 +01:00
|
|
|
|
2015-12-15 17:23:13 +01:00
|
|
|
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
|
2015-12-21 11:26:12 +01:00
|
|
|
"Replaces a partition with %1." )
|
2017-07-04 14:29:31 +02:00
|
|
|
.arg( *Calamares::Branding::ShortVersionedName ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
)
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
|
2016-03-18 12:26:41 +01:00
|
|
|
if ( atLeastOneCanBeReplaced )
|
|
|
|
m_replaceButton->show();
|
|
|
|
else
|
2017-09-07 10:55:26 +02:00
|
|
|
force_uncheck( m_grp, m_replaceButton );
|
2016-03-18 12:26:41 +01:00
|
|
|
|
|
|
|
if ( atLeastOneCanBeResized )
|
|
|
|
m_alongsideButton->show();
|
|
|
|
else
|
2017-09-07 10:55:26 +02:00
|
|
|
force_uncheck( m_grp, m_alongsideButton );
|
|
|
|
|
|
|
|
if ( !atLeastOneIsMounted )
|
|
|
|
m_eraseButton->show(); // None mounted
|
|
|
|
else
|
|
|
|
force_uncheck( m_grp, m_eraseButton );
|
2016-03-18 12:26:41 +01:00
|
|
|
|
2017-08-28 11:36:21 +02:00
|
|
|
bool isEfi = PartUtils::isEfiSystem();
|
2015-05-28 19:24:39 +02:00
|
|
|
bool efiSystemPartitionFound = !m_core->efiSystemPartitions().isEmpty();
|
|
|
|
|
|
|
|
if ( isEfi && !efiSystemPartitionFound )
|
|
|
|
{
|
2015-10-06 18:56:33 +02:00
|
|
|
cDebug() << "WARNING: system is EFI but there's no EFI system partition, "
|
2015-05-28 19:24:39 +02:00
|
|
|
"DISABLING alongside and replace features.";
|
2015-10-06 18:56:33 +02:00
|
|
|
m_alongsideButton->hide();
|
|
|
|
m_replaceButton->hide();
|
2015-05-28 19:24:39 +02:00
|
|
|
}
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-27 14:47:52 +01:00
|
|
|
OsproberEntryList
|
|
|
|
ChoicePage::getOsproberEntriesForDevice( Device* device ) const
|
|
|
|
{
|
|
|
|
OsproberEntryList eList;
|
2016-09-01 14:21:05 +02:00
|
|
|
for ( const OsproberEntry& entry : m_core->osproberEntries() )
|
2015-11-27 14:47:52 +01:00
|
|
|
{
|
|
|
|
if ( entry.path.startsWith( device->deviceNode() ) )
|
|
|
|
eList.append( entry );
|
|
|
|
}
|
|
|
|
return eList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
bool
|
2015-04-15 12:20:01 +02:00
|
|
|
ChoicePage::isNextEnabled() const
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
|
|
|
return m_nextEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChoicePage::Choice
|
2015-04-15 12:20:01 +02:00
|
|
|
ChoicePage::currentChoice() const
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
|
|
|
return m_choice;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2016-04-22 16:02:07 +02:00
|
|
|
ChoicePage::updateNextEnabled()
|
2014-09-03 18:09:37 +02:00
|
|
|
{
|
2016-04-22 16:02:07 +02:00
|
|
|
bool enabled = false;
|
|
|
|
|
|
|
|
switch ( m_choice )
|
|
|
|
{
|
|
|
|
case NoChoice:
|
|
|
|
enabled = false;
|
|
|
|
break;
|
|
|
|
case Replace:
|
2016-06-03 17:55:01 +02:00
|
|
|
enabled = m_beforePartitionBarsView->selectionModel()->
|
|
|
|
currentIndex().isValid();
|
2016-04-22 16:02:07 +02:00
|
|
|
break;
|
|
|
|
case Alongside:
|
2016-06-03 17:55:01 +02:00
|
|
|
enabled = m_beforePartitionBarsView->selectionModel()->
|
2016-04-22 16:02:07 +02:00
|
|
|
currentIndex().isValid();
|
|
|
|
break;
|
|
|
|
case Erase:
|
|
|
|
case Manual:
|
|
|
|
enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_isEfi &&
|
|
|
|
( m_choice == Alongside ||
|
|
|
|
m_choice == Replace ) )
|
|
|
|
{
|
|
|
|
if ( m_core->efiSystemPartitions().count() == 0 )
|
|
|
|
enabled = false;
|
|
|
|
}
|
|
|
|
|
2016-06-10 14:39:27 +02:00
|
|
|
if ( m_choice != Manual &&
|
|
|
|
m_encryptWidget->isVisible() &&
|
2016-04-22 16:02:07 +02:00
|
|
|
m_encryptWidget->state() == EncryptWidget::EncryptionUnconfirmed )
|
|
|
|
enabled = false;
|
|
|
|
|
2014-09-03 18:09:37 +02:00
|
|
|
if ( enabled == m_nextEnabled )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_nextEnabled = enabled;
|
|
|
|
emit nextStatusChanged( enabled );
|
|
|
|
}
|
2014-09-19 16:27:39 +02:00
|
|
|
|