mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-26 17:05:36 -04:00
commit
bbd2afc20f
14 changed files with 69 additions and 73 deletions
|
@ -74,7 +74,7 @@ canBeReplaced( Partition* candidate )
|
|||
bool ok = false;
|
||||
double requiredStorageGB = Calamares::JobQueue::instance()
|
||||
->globalStorage()
|
||||
->value( "requiredStorageGB" )
|
||||
->value( "requiredStorageGiB" )
|
||||
.toDouble( &ok );
|
||||
|
||||
qint64 availableStorageB = candidate->capacity();
|
||||
|
@ -146,7 +146,7 @@ canBeResized( Partition* candidate )
|
|||
bool ok = false;
|
||||
double requiredStorageGB = Calamares::JobQueue::instance()
|
||||
->globalStorage()
|
||||
->value( "requiredStorageGB" )
|
||||
->value( "requiredStorageGiB" )
|
||||
.toDouble( &ok );
|
||||
// We require a little more for partitioning overhead and swap file
|
||||
double advisedStorageGB = requiredStorageGB + 0.5 + 2.0;
|
||||
|
|
|
@ -98,7 +98,7 @@ PartitionIterator::begin( PartitionTable* table )
|
|||
{
|
||||
auto it = PartitionIterator( table );
|
||||
QList< Partition* > children = table->children();
|
||||
// Does not usually happen, but it did happen on a 10MB disk with an MBR
|
||||
// Does not usually happen, but it did happen on a tiny (10MiB) disk with an MBR
|
||||
// partition table.
|
||||
if ( children.isEmpty() )
|
||||
return it;
|
||||
|
|
|
@ -462,7 +462,7 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
|
|||
gs->value( "defaultFileSystemType" ).toString(),
|
||||
m_encryptWidget->passphrase(),
|
||||
gs->value( "efiSystemPartition" ).toString(),
|
||||
CalamaresUtils::GiBtoBytes( gs->value( "requiredStorageGB" ).toDouble() ),
|
||||
CalamaresUtils::GiBtoBytes( gs->value( "requiredStorageGiB" ).toDouble() ),
|
||||
m_eraseSwapChoice
|
||||
};
|
||||
|
||||
|
@ -560,11 +560,10 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
|||
|
||||
double requiredStorageGB = Calamares::JobQueue::instance()
|
||||
->globalStorage()
|
||||
->value( "requiredStorageGB" )
|
||||
->value( "requiredStorageGiB" )
|
||||
.toDouble();
|
||||
|
||||
// TODO: make this consistent
|
||||
qint64 requiredStorageB = qRound64( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
|
||||
qint64 requiredStorageB = CalamaresUtils::GiBtoBytes( requiredStorageGB + 0.1 + 2.0 );
|
||||
|
||||
m_afterPartitionSplitterWidget->setSplitPartition(
|
||||
part->partitionPath(),
|
||||
|
@ -967,11 +966,11 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
|
|||
qint64 sizeNext )
|
||||
{
|
||||
Q_UNUSED( path )
|
||||
sizeLabel->setText( tr( "%1 will be shrunk to %2MB and a new "
|
||||
"%3MB partition will be created for %4." )
|
||||
sizeLabel->setText( tr( "%1 will be shrunk to %2MiB and a new "
|
||||
"%3MiB partition will be created for %4." )
|
||||
.arg( m_beforePartitionBarsView->selectionModel()->currentIndex().data().toString() )
|
||||
.arg( size / ( 1024 * 1024 ) )
|
||||
.arg( sizeNext / ( 1024 * 1024 ) )
|
||||
.arg( CalamaresUtils::BytesToMiB( size ) )
|
||||
.arg( CalamaresUtils::BytesToMiB( sizeNext ) )
|
||||
.arg( *Calamares::Branding::ShortProductName ) );
|
||||
} );
|
||||
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
|
||||
#include "PartitionLabelsView.h"
|
||||
|
||||
#include <core/PartitionModel.h>
|
||||
#include <core/ColorUtils.h>
|
||||
#include "core/PartitionModel.h"
|
||||
#include "core/ColorUtils.h"
|
||||
|
||||
#include <utils/CalamaresUtilsGui.h>
|
||||
#include <utils/Logger.h>
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Units.h"
|
||||
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/fs/filesystem.h>
|
||||
|
@ -35,6 +36,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
using CalamaresUtils::operator""_MiB;
|
||||
|
||||
static const int LAYOUT_MARGIN = 4;
|
||||
static const int LABEL_PARTITION_SQUARE_MARGIN =
|
||||
|
@ -62,12 +64,6 @@ PartitionLabelsView::PartitionLabelsView( QWidget* parent )
|
|||
setSelectionBehavior( QAbstractItemView::SelectRows );
|
||||
setSelectionMode( QAbstractItemView::SingleSelection );
|
||||
this->setObjectName("partitionLabel");
|
||||
// Debug
|
||||
connect( this, &PartitionLabelsView::clicked,
|
||||
this, [=]( const QModelIndex& index )
|
||||
{
|
||||
cDebug() << "Clicked row" << index.row();
|
||||
} );
|
||||
setMouseTracking( true );
|
||||
}
|
||||
|
||||
|
@ -162,8 +158,8 @@ PartitionLabelsView::getIndexesToDraw( const QModelIndex& parent ) const
|
|||
|
||||
//HACK: horrible special casing follows.
|
||||
// To save vertical space, we choose to hide short instances of free space.
|
||||
// Arbitrary limit: 10MB.
|
||||
const qint64 maxHiddenB = 10000000;
|
||||
// Arbitrary limit: 10MiB.
|
||||
const qint64 maxHiddenB = 10_MiB;
|
||||
if ( index.data( PartitionModel::IsFreeSpaceRole ).toBool() &&
|
||||
index.data( PartitionModel::SizeRole ).toLongLong() < maxHiddenB )
|
||||
continue;
|
||||
|
|
|
@ -143,7 +143,7 @@ ReplaceWidget::onPartitionSelected()
|
|||
bool ok = false;
|
||||
double requiredSpaceB = Calamares::JobQueue::instance()
|
||||
->globalStorage()
|
||||
->value( "requiredStorageGB" )
|
||||
->value( "requiredStorageGiB" )
|
||||
.toDouble( &ok ) * 1024 * 1024 * 1024;
|
||||
|
||||
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
|
||||
|
|
|
@ -41,7 +41,7 @@ CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
|
|||
QString
|
||||
CreatePartitionJob::prettyName() const
|
||||
{
|
||||
return tr( "Create new %2MB partition on %4 (%3) with file system %1." )
|
||||
return tr( "Create new %2MiB partition on %4 (%3) with file system %1." )
|
||||
.arg( m_partition->fileSystem().name() )
|
||||
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
|
||||
.arg( m_device->name() )
|
||||
|
@ -52,7 +52,7 @@ CreatePartitionJob::prettyName() const
|
|||
QString
|
||||
CreatePartitionJob::prettyDescription() const
|
||||
{
|
||||
return tr( "Create new <strong>%2MB</strong> partition on <strong>%4</strong> "
|
||||
return tr( "Create new <strong>%2MiB</strong> partition on <strong>%4</strong> "
|
||||
"(%3) with file system <strong>%1</strong>." )
|
||||
.arg( m_partition->fileSystem().name() )
|
||||
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
|
||||
|
|
|
@ -38,7 +38,7 @@ FormatPartitionJob::FormatPartitionJob( Device* device, Partition* partition )
|
|||
QString
|
||||
FormatPartitionJob::prettyName() const
|
||||
{
|
||||
return tr( "Format partition %1 (file system: %2, size: %3 MB) on %4." )
|
||||
return tr( "Format partition %1 (file system: %2, size: %3 MiB) on %4." )
|
||||
.arg( m_partition->partitionPath() )
|
||||
.arg( m_partition->fileSystem().name() )
|
||||
.arg( m_partition->capacity() / 1024 / 1024 )
|
||||
|
@ -49,7 +49,7 @@ FormatPartitionJob::prettyName() const
|
|||
QString
|
||||
FormatPartitionJob::prettyDescription() const
|
||||
{
|
||||
return tr( "Format <strong>%3MB</strong> partition <strong>%1</strong> with "
|
||||
return tr( "Format <strong>%3MiB</strong> partition <strong>%1</strong> with "
|
||||
"file system <strong>%2</strong>." )
|
||||
.arg( m_partition->partitionPath() )
|
||||
.arg( m_partition->fileSystem().name() )
|
||||
|
|
|
@ -52,8 +52,8 @@ ResizePartitionJob::prettyName() const
|
|||
QString
|
||||
ResizePartitionJob::prettyDescription() const
|
||||
{
|
||||
return tr( "Resize <strong>%2MB</strong> partition <strong>%1</strong> to "
|
||||
"<strong>%3MB</strong>." )
|
||||
return tr( "Resize <strong>%2MiB</strong> partition <strong>%1</strong> to "
|
||||
"<strong>%3MiB</strong>." )
|
||||
.arg( partition()->partitionPath() )
|
||||
.arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) )
|
||||
.arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) );
|
||||
|
@ -63,8 +63,8 @@ ResizePartitionJob::prettyDescription() const
|
|||
QString
|
||||
ResizePartitionJob::prettyStatusMessage() const
|
||||
{
|
||||
return tr( "Resizing %2MB partition %1 to "
|
||||
"%3MB." )
|
||||
return tr( "Resizing %2MiB partition %1 to "
|
||||
"%3MiB." )
|
||||
.arg( partition()->partitionPath() )
|
||||
.arg( ( BytesToMiB( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() ) )
|
||||
.arg( ( BytesToMiB( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() ) );
|
||||
|
|
|
@ -49,7 +49,7 @@ SetPartFlagsJob::prettyName() const
|
|||
return tr( "Set flags on partition %1." ).arg( partition()->partitionPath() );
|
||||
|
||||
if ( !partition()->fileSystem().name().isEmpty() )
|
||||
return tr( "Set flags on %1MB %2 partition." )
|
||||
return tr( "Set flags on %1MiB %2 partition." )
|
||||
.arg( BytesToMiB( partition()->capacity() ) )
|
||||
.arg( partition()->fileSystem().name() );
|
||||
|
||||
|
@ -68,7 +68,7 @@ SetPartFlagsJob::prettyDescription() const
|
|||
.arg( partition()->partitionPath() );
|
||||
|
||||
if ( !partition()->fileSystem().name().isEmpty() )
|
||||
return tr( "Clear flags on %1MB <strong>%2</strong> partition." )
|
||||
return tr( "Clear flags on %1MiB <strong>%2</strong> partition." )
|
||||
.arg( BytesToMiB( partition()->capacity() ) )
|
||||
.arg( partition()->fileSystem().name() );
|
||||
|
||||
|
@ -82,7 +82,7 @@ SetPartFlagsJob::prettyDescription() const
|
|||
.arg( flagsList.join( ", " ) );
|
||||
|
||||
if ( !partition()->fileSystem().name().isEmpty() )
|
||||
return tr( "Flag %1MB <strong>%2</strong> partition as "
|
||||
return tr( "Flag %1MiB <strong>%2</strong> partition as "
|
||||
"<strong>%3</strong>." )
|
||||
.arg( BytesToMiB( partition()->capacity() ) )
|
||||
.arg( partition()->fileSystem().name() )
|
||||
|
@ -104,7 +104,7 @@ SetPartFlagsJob::prettyStatusMessage() const
|
|||
.arg( partition()->partitionPath() );
|
||||
|
||||
if ( !partition()->fileSystem().name().isEmpty() )
|
||||
return tr( "Clearing flags on %1MB <strong>%2</strong> partition." )
|
||||
return tr( "Clearing flags on %1MiB <strong>%2</strong> partition." )
|
||||
.arg( BytesToMiB( partition()->capacity() ) )
|
||||
.arg( partition()->fileSystem().name() );
|
||||
|
||||
|
@ -119,7 +119,7 @@ SetPartFlagsJob::prettyStatusMessage() const
|
|||
|
||||
if ( !partition()->fileSystem().name().isEmpty() )
|
||||
return tr( "Setting flags <strong>%3</strong> on "
|
||||
"%1MB <strong>%2</strong> partition." )
|
||||
"%1MiB <strong>%2</strong> partition." )
|
||||
.arg( BytesToMiB( partition()->capacity() ) )
|
||||
.arg( partition()->fileSystem().name() )
|
||||
.arg( flagsList.join( ", " ) );
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
bool m_mounted;
|
||||
};
|
||||
|
||||
/// @brief Generate random data of given @p size as a QByteArray
|
||||
static QByteArray
|
||||
generateTestData( qint64 size )
|
||||
{
|
||||
|
@ -321,10 +322,10 @@ PartitionJobTests::testCreatePartitionExtended()
|
|||
void
|
||||
PartitionJobTests::testResizePartition_data()
|
||||
{
|
||||
QTest::addColumn< int >( "oldStartMB" );
|
||||
QTest::addColumn< int >( "oldSizeMB" );
|
||||
QTest::addColumn< int >( "newStartMB" );
|
||||
QTest::addColumn< int >( "newSizeMB" );
|
||||
QTest::addColumn< int >( "oldStartMiB" );
|
||||
QTest::addColumn< int >( "oldSizeMiB" );
|
||||
QTest::addColumn< int >( "newStartMiB" );
|
||||
QTest::addColumn< int >( "newSizeMiB" );
|
||||
|
||||
QTest::newRow("grow") << 10 << 50 << 10 << 70;
|
||||
QTest::newRow("shrink") << 10 << 70 << 10 << 50;
|
||||
|
@ -335,22 +336,22 @@ PartitionJobTests::testResizePartition_data()
|
|||
void
|
||||
PartitionJobTests::testResizePartition()
|
||||
{
|
||||
QFETCH( int, oldStartMB );
|
||||
QFETCH( int, oldSizeMB );
|
||||
QFETCH( int, newStartMB );
|
||||
QFETCH( int, newSizeMB );
|
||||
QFETCH( int, oldStartMiB );
|
||||
QFETCH( int, oldSizeMiB );
|
||||
QFETCH( int, newStartMiB );
|
||||
QFETCH( int, newSizeMiB );
|
||||
|
||||
const qint64 sectorForMB = 1_MiB / m_device->logicalSize();
|
||||
const qint64 sectorsPerMiB = 1_MiB / m_device->logicalSize();
|
||||
|
||||
qint64 oldFirst = sectorForMB * oldStartMB;
|
||||
qint64 oldLast = oldFirst + sectorForMB * oldSizeMB - 1;
|
||||
qint64 newFirst = sectorForMB * newStartMB;
|
||||
qint64 newLast = newFirst + sectorForMB * newSizeMB - 1;
|
||||
qint64 oldFirst = sectorsPerMiB * oldStartMiB;
|
||||
qint64 oldLast = oldFirst + sectorsPerMiB * oldSizeMiB - 1;
|
||||
qint64 newFirst = sectorsPerMiB * newStartMiB;
|
||||
qint64 newLast = newFirst + sectorsPerMiB * newSizeMiB - 1;
|
||||
|
||||
// Make the test data file smaller than the full size of the partition to
|
||||
// accomodate for the file system overhead
|
||||
const unsigned long long minSizeMB = qMin( oldSizeMB, newSizeMB );
|
||||
const QByteArray testData = generateTestData( CalamaresUtils::MiBtoBytes( minSizeMB ) * 3 / 4 );
|
||||
const unsigned long long minSizeMiB = qMin( oldSizeMiB, newSizeMiB );
|
||||
const QByteArray testData = generateTestData( CalamaresUtils::MiBtoBytes( minSizeMiB ) * 3 / 4 );
|
||||
const QString testName = "test.data";
|
||||
|
||||
// Setup: create the test partition
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue