Move onPartitionSelected into a slot instead of a huge lambda.

This commit is contained in:
Teo Mrnjavac 2015-05-29 16:21:55 +02:00
parent 195b585282
commit e3ef61a7f2
2 changed files with 88 additions and 79 deletions

View File

@ -94,9 +94,35 @@ AlongsidePage::init( PartitionCoreModule* core , const OsproberEntryList& osprob
connect( m_partitionsComboBox,
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
this, [ this ]( int index )
this, &AlongsidePage::onPartitionSelected );
connect( m_splitterWidget, &PartitionSplitterWidget::partitionResized,
this, [ this ]( const QString& path, qint64 size, qint64 sizeNext )
{
QString path = m_partitionsComboBox->itemData( index ).toString();
m_sizeLabel->setText( tr( "With this operation, the partition <strong>%1</strong> which contains "
"%4 will be shrunk "
"to %2MB and a new %3MB partition will be created for %5." )
.arg( path )
.arg( size / ( 1024 * 1024 ) )
.arg( sizeNext / ( 1024 * 1024 ) )
.arg( m_partitionsComboBox->currentText() )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductName ) ) );
} );
foreach ( const OsproberEntry& e, osproberEntries )
{
if ( e.canBeResized )
m_partitionsComboBox->addItem( e.prettyName + " (" + e.path + ")", e.path );
}
setNextEnabled( true );
}
void
AlongsidePage::onPartitionSelected( int comboBoxIndex )
{
QString path = m_partitionsComboBox->itemData( comboBoxIndex ).toString();
cDebug() << "Current index changed:" << path;
DeviceModel* dm = m_core->deviceModel();
@ -172,28 +198,6 @@ AlongsidePage::init( PartitionCoreModule* core , const OsproberEntryList& osprob
return;
}
}
} );
connect( m_splitterWidget, &PartitionSplitterWidget::partitionResized,
this, [ this ]( const QString& path, qint64 size, qint64 sizeNext )
{
m_sizeLabel->setText( tr( "With this operation, the partition <strong>%1</strong> which contains "
"%4 will be shrunk "
"to %2MB and a new %3MB partition will be created for %5." )
.arg( path )
.arg( size / ( 1024 * 1024 ) )
.arg( sizeNext / ( 1024 * 1024 ) )
.arg( m_partitionsComboBox->currentText() )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductName ) ) );
} );
foreach ( const OsproberEntry& e, osproberEntries )
{
if ( e.canBeResized )
m_partitionsComboBox->addItem( e.prettyName + " (" + e.path + ")", e.path );
}
setNextEnabled( true );
}

View File

@ -46,6 +46,9 @@ public:
signals:
void nextStatusChanged( bool );
private slots:
void onPartitionSelected( int comboBoxIndex );
private:
void setNextEnabled( bool enabled );
@ -56,6 +59,8 @@ private:
PartitionCoreModule* m_core;
bool m_isEfi;
bool m_nextEnabled;
};