2014-09-03 18:09:37 +02:00
|
|
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
|
|
|
*
|
2015-03-11 18:13:39 +01:00
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@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"
|
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-11-06 17:57:05 +01:00
|
|
|
#include "ExpandableRadioButton.h"
|
2015-12-03 17:19:02 +01:00
|
|
|
#include "PartitionBarsView.h"
|
2015-12-03 19:40:06 +01:00
|
|
|
#include "PartitionLabelsView.h"
|
2015-11-27 17:25:47 +01:00
|
|
|
#include "DeviceInfoWidget.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"
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-09-18 17:25:55 +02:00
|
|
|
#include <kpmcore/core/device.h>
|
|
|
|
|
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-23 16:35:26 +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_choice( NoChoice )
|
|
|
|
, m_nextEnabled( false )
|
2015-06-14 00:55:26 +02:00
|
|
|
, m_core( 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-10-30 17:32:00 +01:00
|
|
|
, m_lastSelectedDeviceIndex( -1 )
|
2015-11-06 17:57:05 +01:00
|
|
|
, m_isEfi( false )
|
2015-12-17 15:39:52 +01:00
|
|
|
, m_beforePartitionBarsView( nullptr )
|
|
|
|
, m_beforePartitionLabelsView( nullptr )
|
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
|
|
|
|
2015-11-26 15:31:06 +01:00
|
|
|
// Set up drives combo
|
|
|
|
m_mainLayout->setDirection( QBoxLayout::TopToBottom );
|
|
|
|
m_drivesLayout->setDirection( QBoxLayout::LeftToRight );
|
|
|
|
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 );
|
|
|
|
|
|
|
|
m_drivesLayout->addStretch();
|
2015-11-27 17:25:47 +01:00
|
|
|
m_deviceInfoWidget = new DeviceInfoWidget;
|
|
|
|
m_drivesLayout->addWidget( m_deviceInfoWidget );
|
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 );
|
2015-12-15 17:17:53 +01:00
|
|
|
m_drivesLabel->setText( tr( "Pick a storage de&vice:" ) );
|
|
|
|
m_previewBeforeLabel->setText( tr( "Before:" ) );
|
|
|
|
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 );
|
|
|
|
m_previewAfterFrame->hide();
|
2015-09-18 17:25:55 +02:00
|
|
|
// end
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChoicePage::~ChoicePage()
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
/**
|
|
|
|
* @brief ChoicePage::init runs when the PartitionViewStep and the PartitionCoreModule are
|
|
|
|
* ready. Sets up the rest of the UI based on os-prober output.
|
|
|
|
* @param core the PartitionCoreModule pointer.
|
|
|
|
* @param osproberEntries the output of os-prober, cleaned up and structured.
|
|
|
|
*/
|
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;
|
2015-11-06 17:57:05 +01:00
|
|
|
m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists();
|
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
|
|
|
|
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?
|
|
|
|
|
2015-11-06 17:57:05 +01:00
|
|
|
QSize iconSize( CalamaresUtils::defaultIconSize().width() * 2.5,
|
|
|
|
CalamaresUtils::defaultIconSize().height() * 2.5 );
|
2014-09-03 18:09:37 +02:00
|
|
|
QButtonGroup* grp = new QButtonGroup( this );
|
|
|
|
|
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 ) );
|
|
|
|
grp->addButton( m_alongsideButton->buttonWidget() );
|
|
|
|
|
2015-11-12 18:17:21 +01:00
|
|
|
m_eraseButton = createEraseButton();
|
2015-11-08 18:30:26 +01:00
|
|
|
|
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 ) );
|
2015-10-06 18:56:33 +02:00
|
|
|
grp->addButton( m_eraseButton->buttonWidget() );
|
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 ) );
|
|
|
|
grp->addButton( m_replaceButton->buttonWidget() );
|
|
|
|
|
|
|
|
m_itemsLayout->addWidget( m_alongsideButton );
|
|
|
|
m_itemsLayout->addWidget( m_replaceButton );
|
|
|
|
m_itemsLayout->addWidget( m_eraseButton );
|
2014-09-22 17:27:10 +02:00
|
|
|
m_itemsLayout->setSpacing( CalamaresUtils::defaultFontHeight() / 2 );
|
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-22 12:41:47 +01:00
|
|
|
"You can create or resize partitions yourself." )
|
2015-10-06 18:56:33 +02:00
|
|
|
.arg( Calamares::Branding::instance()->
|
|
|
|
string( Calamares::Branding::ShortVersionedName ) ) );
|
|
|
|
)
|
|
|
|
m_somethingElseButton->setIconSize( iconSize );
|
|
|
|
m_somethingElseButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionManual,
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
iconSize ) );
|
|
|
|
m_itemsLayout->addWidget( m_somethingElseButton );
|
|
|
|
grp->addButton( m_somethingElseButton->buttonWidget() );
|
|
|
|
|
|
|
|
m_itemsLayout->addStretch();
|
|
|
|
|
|
|
|
connect( m_alongsideButton->buttonWidget(), &QRadioButton::toggled,
|
|
|
|
this, [ this ]( bool checked )
|
|
|
|
{
|
|
|
|
if ( checked )
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2015-10-06 18:56:33 +02:00
|
|
|
m_choice = Alongside;
|
2015-10-29 17:34:59 +01:00
|
|
|
setNextEnabled( true );
|
|
|
|
emit actionChosen();
|
|
|
|
}
|
2015-10-06 18:56:33 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
connect( m_eraseButton->buttonWidget(), &QRadioButton::toggled,
|
|
|
|
this, [ this ]( bool checked )
|
|
|
|
{
|
|
|
|
if ( checked )
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2015-10-06 18:56:33 +02:00
|
|
|
m_choice = Erase;
|
2015-10-29 17:34:59 +01:00
|
|
|
setNextEnabled( true );
|
|
|
|
emit actionChosen();
|
|
|
|
}
|
2015-10-06 18:56:33 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
connect( m_replaceButton->buttonWidget(), &QRadioButton::toggled,
|
|
|
|
this, [ this ]( bool checked )
|
|
|
|
{
|
|
|
|
if ( checked )
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2015-10-06 18:56:33 +02:00
|
|
|
m_choice = Replace;
|
2015-10-29 17:34:59 +01:00
|
|
|
setNextEnabled( true );
|
|
|
|
emit actionChosen();
|
|
|
|
}
|
2015-10-06 18:56:33 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
connect( m_somethingElseButton->buttonWidget(), &QRadioButton::toggled,
|
|
|
|
this, [ this ]( bool checked )
|
|
|
|
{
|
|
|
|
if ( checked )
|
2015-10-29 17:34:59 +01:00
|
|
|
{
|
2015-10-06 18:56:33 +02:00
|
|
|
m_choice = Manual;
|
2015-10-29 17:34:59 +01:00
|
|
|
setNextEnabled( true );
|
|
|
|
emit actionChosen();
|
|
|
|
}
|
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() );
|
|
|
|
updateActionChoicePreview( currentChoice() );
|
2015-10-29 17:34:59 +01:00
|
|
|
}
|
|
|
|
} );
|
2015-10-06 18:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-20 14:49:37 +01:00
|
|
|
QComboBox*
|
|
|
|
ChoicePage::createBootloaderComboBox( ExpandableRadioButton* parentButton )
|
|
|
|
{
|
|
|
|
QComboBox* bcb = new QComboBox;
|
|
|
|
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 ),
|
|
|
|
[=]( int newIndex )
|
|
|
|
{
|
|
|
|
QVariant var = bcb->itemData( newIndex, BootLoaderModel::BootLoaderPathRole );
|
|
|
|
if ( !var.isValid() )
|
|
|
|
return;
|
|
|
|
m_core->setBootLoaderInstallPath( var.toString() );
|
|
|
|
} );
|
|
|
|
|
|
|
|
// If the user picks a new device, we update the bootloader choice to that
|
|
|
|
// same device automatically.
|
2015-12-17 18:02:14 +01:00
|
|
|
auto updateBootloaderDevice = [bcb, this]()
|
2015-11-20 14:49:37 +01:00
|
|
|
{
|
2015-12-17 18:02:14 +01:00
|
|
|
Device* currd = selectedDevice();
|
2015-11-20 14:49:37 +01:00
|
|
|
if ( !currd )
|
|
|
|
return;
|
|
|
|
QString devPath = currd->deviceNode();
|
|
|
|
for ( int i = 0; i < bcb->count(); ++i )
|
|
|
|
{
|
|
|
|
QVariant var = bcb->itemData( i , BootLoaderModel::BootLoaderPathRole );
|
|
|
|
if ( !var.isValid() )
|
|
|
|
continue;
|
|
|
|
if ( var.toString() == devPath )
|
|
|
|
{
|
|
|
|
bcb->setCurrentIndex( i );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
connect( this, &ChoicePage::deviceChosen,
|
|
|
|
this, updateBootloaderDevice );
|
|
|
|
connect( parentButton, &ExpandableRadioButton::expanded,
|
|
|
|
this, [=]( bool expanded )
|
|
|
|
{
|
|
|
|
if ( expanded )
|
2015-12-17 18:02:14 +01:00
|
|
|
updateBootloaderDevice();
|
2015-11-20 14:49:37 +01:00
|
|
|
}, Qt::QueuedConnection );
|
|
|
|
// ^ Must be Queued so it's sure to run when the widget is already visible.
|
|
|
|
|
|
|
|
return bcb;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-12 18:17:21 +01:00
|
|
|
ExpandableRadioButton*
|
|
|
|
ChoicePage::createEraseButton()
|
|
|
|
{
|
|
|
|
ExpandableRadioButton* eraseButton = new ExpandableRadioButton;
|
|
|
|
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:" ) );
|
2015-11-20 14:49:37 +01:00
|
|
|
|
|
|
|
QComboBox* eraseBootloaderCombo = createBootloaderComboBox( eraseButton );
|
2015-11-12 18:17:21 +01:00
|
|
|
eraseLayout->addWidget( eraseBootloaderCombo );
|
|
|
|
eraseBootloaderLabel->setBuddy( eraseBootloaderCombo );
|
|
|
|
eraseLayout->addStretch();
|
|
|
|
|
|
|
|
eraseButton->setExpandableWidget( eraseWidget );
|
|
|
|
}
|
|
|
|
return eraseButton;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
2015-11-05 15:57:15 +01:00
|
|
|
m_core->clearJobs();
|
2015-12-17 18:02:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
switch ( choice )
|
|
|
|
{
|
|
|
|
case Erase:
|
|
|
|
if ( m_core->isDirty() )
|
2015-12-17 18:02:14 +01:00
|
|
|
{
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
2015-11-05 15:57:15 +01:00
|
|
|
m_core->clearJobs();
|
2015-12-17 18:02:14 +01:00
|
|
|
}
|
2015-11-05 15:57:15 +01:00
|
|
|
|
|
|
|
PartitionActions::doAutopartition( m_core, selectedDevice() );
|
|
|
|
break;
|
|
|
|
case Replace:
|
2015-12-17 18:02:14 +01:00
|
|
|
if ( m_core->isDirty() )
|
|
|
|
{
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
|
|
|
m_core->clearJobs();
|
|
|
|
}
|
|
|
|
|
2015-12-17 15:39:52 +01:00
|
|
|
connect( m_beforePartitionBarsView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
|
|
|
this, [ this ]( const QModelIndex& current, const QModelIndex& previous )
|
|
|
|
{
|
2015-12-23 16:35:26 +01:00
|
|
|
auto doReplace = [=]
|
|
|
|
{
|
|
|
|
// 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();
|
|
|
|
Partition* partition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
|
|
|
partPath );
|
|
|
|
if ( partition )
|
|
|
|
PartitionActions::doReplacePartition( m_core,
|
|
|
|
selectedDevice(),
|
|
|
|
partition );
|
|
|
|
};
|
|
|
|
|
2015-12-18 15:03:31 +01:00
|
|
|
if ( m_core->isDirty() )
|
2015-12-18 15:32:29 +01:00
|
|
|
{
|
2015-12-23 16:35:26 +01:00
|
|
|
QFutureWatcher< void > watcher;
|
|
|
|
connect( &watcher, &QFutureWatcher< void >::finished,
|
|
|
|
this, doReplace );
|
|
|
|
|
|
|
|
QFuture< void > future = QtConcurrent::run( [=]
|
|
|
|
{
|
|
|
|
m_core->revertDevice( selectedDevice() );
|
|
|
|
m_core->clearJobs();
|
|
|
|
} );
|
|
|
|
watcher.setFuture( future );
|
2015-12-18 15:32:29 +01:00
|
|
|
}
|
2015-12-23 16:35:26 +01:00
|
|
|
else
|
|
|
|
doReplace();
|
2015-12-17 15:39:52 +01:00
|
|
|
|
|
|
|
} );
|
2015-12-18 15:03:31 +01:00
|
|
|
break;
|
2015-11-05 15:57:15 +01:00
|
|
|
case NoChoice:
|
|
|
|
case Manual:
|
|
|
|
break;
|
|
|
|
}
|
2015-10-23 17:45:28 +02: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() );
|
|
|
|
m_previewBeforeFrame->layout()->deleteLater();
|
2015-10-23 17:45:28 +02:00
|
|
|
|
2015-10-06 18:56:33 +02:00
|
|
|
QVBoxLayout* 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
|
|
|
|
2015-12-17 15:39:52 +01:00
|
|
|
m_beforePartitionBarsView = new PartitionBarsView( m_previewBeforeFrame );
|
|
|
|
m_beforePartitionLabelsView = new PartitionLabelsView( m_previewBeforeFrame );
|
2015-10-23 17:45:28 +02:00
|
|
|
|
|
|
|
Device* deviceBefore = m_core->createImmutableDeviceCopy( currentDevice );
|
|
|
|
|
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.
|
|
|
|
deviceBefore->setParent( model );
|
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() );
|
2015-12-17 13:45:11 +01:00
|
|
|
sm->deleteLater();
|
|
|
|
|
|
|
|
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() );
|
|
|
|
m_previewAfterFrame->layout()->deleteLater();
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
switch ( choice )
|
|
|
|
{
|
|
|
|
case Alongside:
|
|
|
|
// split widget goes here
|
2015-11-26 15:31:06 +01:00
|
|
|
//label->setText( tr( "Drag to split:" ) );
|
2015-12-22 12:41:47 +01:00
|
|
|
m_selectLabel->hide();
|
2015-10-29 17:34:59 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
case Erase:
|
|
|
|
case Replace:
|
|
|
|
{
|
2015-12-03 17:19:02 +01:00
|
|
|
PartitionBarsView* preview = new PartitionBarsView( m_previewAfterFrame );
|
2015-12-03 19:40:06 +01:00
|
|
|
PartitionLabelsView* previewLabels = new PartitionLabelsView( m_previewAfterFrame );
|
2015-12-16 11:13:03 +01:00
|
|
|
previewLabels->setCustomNewRootLabel( Calamares::Branding::instance()->
|
2015-12-16 15:31:25 +01:00
|
|
|
string( 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.
|
|
|
|
preview->setModel( model );
|
2015-12-03 19:40:06 +01:00
|
|
|
previewLabels->setModel( model );
|
2015-12-17 13:45:11 +01:00
|
|
|
preview->setSelectionMode( QAbstractItemView::NoSelection );
|
|
|
|
previewLabels->setSelectionMode( QAbstractItemView::NoSelection );
|
2015-12-16 18:28:22 +01:00
|
|
|
|
2015-10-29 17:34:59 +01:00
|
|
|
layout->addWidget( preview );
|
2015-12-03 19:40:06 +01:00
|
|
|
layout->addWidget( previewLabels );
|
2015-10-29 17:34:59 +01:00
|
|
|
|
|
|
|
m_previewAfterFrame->show();
|
2015-12-22 12:41:47 +01:00
|
|
|
|
|
|
|
if ( m_choice == Erase )
|
|
|
|
m_selectLabel->hide();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_selectLabel->show();
|
|
|
|
m_selectLabel->setText( tr( "Select which partition to replace" ) );
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
break;
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ( QObject* child, m_previewBeforeFrame->children() )
|
|
|
|
{
|
|
|
|
PartitionBarsView* pbv = qobject_cast< PartitionBarsView* >( child );
|
|
|
|
if ( pbv )
|
|
|
|
pbv->setSelectionMode( previewSelectionMode );
|
|
|
|
PartitionLabelsView* plv = qobject_cast< PartitionLabelsView* >( child );
|
|
|
|
if ( plv )
|
|
|
|
plv->setSelectionMode( previewSelectionMode );
|
|
|
|
}
|
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 );
|
|
|
|
|
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." ) );
|
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();
|
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." )
|
2014-11-11 17:09:33 +01:00
|
|
|
.arg( Calamares::Branding::instance()->
|
2015-03-18 20:11:53 +01:00
|
|
|
string( 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." )
|
|
|
|
.arg( Calamares::Branding::instance()->
|
|
|
|
string( 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." )
|
2014-11-11 17:09:33 +01:00
|
|
|
.arg( Calamares::Branding::instance()->
|
2015-12-15 17:28:21 +01:00
|
|
|
string( 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." )
|
|
|
|
.arg( Calamares::Branding::instance()->
|
|
|
|
string( Calamares::Branding::ShortVersionedName ) ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
)
|
2014-09-23 17:42:11 +02:00
|
|
|
}
|
2015-11-27 14:47:52 +01:00
|
|
|
if ( !osproberEntriesForCurrentDevice.first().canBeResized )
|
2015-10-06 18:56:33 +02:00
|
|
|
m_alongsideButton->hide();
|
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-09-22 17:21:50 +02:00
|
|
|
bool atLeastOneCanBeResized = false;
|
2014-09-03 18:09:37 +02:00
|
|
|
|
2015-11-27 14:47:52 +01:00
|
|
|
foreach ( const OsproberEntry& entry, osproberEntriesForCurrentDevice )
|
2014-09-22 17:21:50 +02:00
|
|
|
{
|
2014-09-23 17:42:11 +02:00
|
|
|
if ( entry.canBeResized )
|
2014-09-22 17:21:50 +02:00
|
|
|
{
|
|
|
|
atLeastOneCanBeResized = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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." )
|
2014-11-11 17:09:33 +01:00
|
|
|
.arg( Calamares::Branding::instance()->
|
2015-12-15 17:28:21 +01:00
|
|
|
string( 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." )
|
|
|
|
.arg( Calamares::Branding::instance()->
|
|
|
|
string( Calamares::Branding::ShortVersionedName ) ) );
|
2014-11-11 17:09:33 +01:00
|
|
|
)
|
2014-09-23 17:42:11 +02:00
|
|
|
|
|
|
|
if ( !atLeastOneCanBeResized )
|
2015-10-06 18:56:33 +02:00
|
|
|
m_alongsideButton->hide();
|
2014-09-03 18:09:37 +02:00
|
|
|
}
|
|
|
|
|
2015-05-28 19:24:39 +02:00
|
|
|
bool isEfi = QDir( "/sys/firmware/efi/efivars" ).exists();
|
|
|
|
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;
|
2015-12-15 14:00:34 +01:00
|
|
|
foreach ( 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
|
|
|
|
ChoicePage::setNextEnabled( bool enabled )
|
|
|
|
{
|
|
|
|
if ( enabled == m_nextEnabled )
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_nextEnabled = enabled;
|
|
|
|
emit nextStatusChanged( enabled );
|
|
|
|
}
|
2014-09-19 16:27:39 +02:00
|
|
|
|