[partition] Introduce convenience translation for progress.
This commit is contained in:
parent
5c4286eebf
commit
55ed2ba4c0
@ -21,3 +21,12 @@
|
||||
PartitionJob::PartitionJob( Partition* partition )
|
||||
: m_partition( partition )
|
||||
{}
|
||||
|
||||
void PartitionJob::progress(int percent)
|
||||
{
|
||||
if ( percent < 0 )
|
||||
percent = 0;
|
||||
if ( percent > 100 )
|
||||
percent = 100;
|
||||
emit progress( qreal( percent / 100.0 ) );
|
||||
}
|
||||
|
@ -37,6 +37,14 @@ public:
|
||||
return m_partition;
|
||||
}
|
||||
|
||||
public slots:
|
||||
/** @brief Translate from KPMCore to Calamares progress.
|
||||
*
|
||||
* KPMCore presents progress as an integer percent from 0 .. 100,
|
||||
* while Calamares uses a qreal from 0 .. 1.00 .
|
||||
*/
|
||||
void progress( int percent );
|
||||
|
||||
protected:
|
||||
Partition* m_partition;
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ ResizePartitionJob::exec()
|
||||
m_partition->setLastSector( m_oldLastSector );
|
||||
ResizeOperation op(*m_device, *m_partition, m_newFirstSector, m_newLastSector);
|
||||
op.setStatus(Operation::StatusRunning);
|
||||
connect(&op, &Operation::progress, [&](int percent) { emit progress(percent / 100.0); } );
|
||||
connect(&op, &Operation::progress, this, &ResizePartitionJob::progress );
|
||||
|
||||
QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." )
|
||||
.arg( m_partition->partitionPath() )
|
||||
|
@ -135,10 +135,7 @@ SetPartFlagsJob::exec()
|
||||
Report report ( nullptr );
|
||||
SetPartFlagsOperation op( *m_device, *partition(), m_flags );
|
||||
op.setStatus( Operation::StatusRunning );
|
||||
connect( &op, &Operation::progress, [&]( int percent )
|
||||
{
|
||||
emit progress( percent / 100.0 );
|
||||
} );
|
||||
connect( &op, &Operation::progress, this, &SetPartFlagsJob::progress );
|
||||
|
||||
QString errorMessage = tr( "The installer failed to set flags on partition %1." )
|
||||
.arg( m_partition->partitionPath() );
|
||||
|
Loading…
Reference in New Issue
Block a user