Signal-slot plumbing and splitter setup for Alongside.
This commit is contained in:
parent
46ea8a484e
commit
80018e1d5b
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,6 +30,7 @@
|
||||
#include "ExpandableRadioButton.h"
|
||||
#include "PartitionBarsView.h"
|
||||
#include "PartitionLabelsView.h"
|
||||
#include "PartitionSplitterWidget.h"
|
||||
#include "DeviceInfoWidget.h"
|
||||
#include "ScanningDialog.h"
|
||||
|
||||
@ -452,6 +453,24 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
||||
this, SLOT( doReplaceSelectedPartition( QModelIndex, QModelIndex ) ),
|
||||
Qt::UniqueConnection );
|
||||
break;
|
||||
|
||||
case Alongside:
|
||||
if ( m_core->isDirty() )
|
||||
{
|
||||
ScanningDialog::run( QtConcurrent::run( [ = ]
|
||||
{
|
||||
QMutexLocker locker( &m_coreMutex );
|
||||
m_core->revertDevice( selectedDevice() );
|
||||
} ),
|
||||
[]{},
|
||||
this );
|
||||
}
|
||||
setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() );
|
||||
|
||||
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
||||
this, SLOT( doAlongsideSelectedPartition( QModelIndex, QModelIndex ) ),
|
||||
Qt::UniqueConnection );
|
||||
break;
|
||||
case NoChoice:
|
||||
case Manual:
|
||||
break;
|
||||
@ -460,10 +479,26 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChoicePage::doAlongsideSelectedPartition( const QModelIndex& current,
|
||||
const QModelIndex& previous )
|
||||
{
|
||||
Q_UNUSED( previous );
|
||||
if ( !current.isValid() )
|
||||
return;
|
||||
|
||||
|
||||
|
||||
cDebug() << "Partition selected for Alongside.";
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ChoicePage::doReplaceSelectedPartition( const QModelIndex& current,
|
||||
const QModelIndex& previous )
|
||||
{
|
||||
Q_UNUSED( previous );
|
||||
if ( !current.isValid() )
|
||||
return;
|
||||
|
||||
@ -581,13 +616,35 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
||||
switch ( choice )
|
||||
{
|
||||
case Alongside:
|
||||
m_previewBeforeLabel->setText( tr( "Device:" ) );
|
||||
m_previewAfterLabel->hide();
|
||||
// split widget goes here
|
||||
//label->setText( tr( "Drag to split:" ) );
|
||||
m_selectLabel->hide();
|
||||
{
|
||||
m_previewBeforeLabel->setText( tr( "Before:" ) );
|
||||
m_selectLabel->setText( tr( "<strong>Select which partition to shrink, "
|
||||
"then drag to resize</strong>" ) );
|
||||
m_selectLabel->show();
|
||||
|
||||
break;
|
||||
m_afterPartitionSplitterWidget = new PartitionSplitterWidget;
|
||||
layout->addWidget( m_afterPartitionSplitterWidget );
|
||||
|
||||
QLabel* sizeLabel = new QLabel;
|
||||
layout->addWidget( sizeLabel );
|
||||
sizeLabel->setWordWrap( true );
|
||||
connect( m_afterPartitionSplitterWidget, &PartitionSplitterWidget::partitionResized,
|
||||
this, [ this, sizeLabel ]( const QString& path, qint64 size, qint64 sizeNext )
|
||||
{
|
||||
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 ) )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ShortProductName ) ) );
|
||||
} );
|
||||
|
||||
m_previewAfterFrame->show();
|
||||
m_previewAfterLabel->show();
|
||||
|
||||
break;
|
||||
}
|
||||
case Erase:
|
||||
case Replace:
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -35,6 +35,7 @@ class QListView;
|
||||
|
||||
class ExpandableRadioButton;
|
||||
class PartitionBarsView;
|
||||
class PartitionSplitterWidget;
|
||||
class PartitionLabelsView;
|
||||
class PartitionCoreModule;
|
||||
class PrettyRadioButton;
|
||||
@ -71,6 +72,7 @@ signals:
|
||||
|
||||
private slots:
|
||||
void doReplaceSelectedPartition( const QModelIndex& current, const QModelIndex& previous );
|
||||
void doAlongsideSelectedPartition( const QModelIndex& current, const QModelIndex& previous );
|
||||
|
||||
private:
|
||||
void setNextEnabled( bool enabled );
|
||||
@ -107,6 +109,7 @@ private:
|
||||
QPointer< PartitionLabelsView > m_beforePartitionLabelsView;
|
||||
QPointer< PartitionBarsView > m_afterPartitionBarsView;
|
||||
QPointer< PartitionLabelsView > m_afterPartitionLabelsView;
|
||||
QPointer< PartitionSplitterWidget > m_afterPartitionSplitterWidget;
|
||||
|
||||
int m_lastSelectedDeviceIndex;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user