From 6388b41e6c69f3fdca172bb6dce1ad770801923b Mon Sep 17 00:00:00 2001 From: demmm Date: Tue, 6 Jul 2021 18:59:58 +0200 Subject: [PATCH] [partition] adding prettyStatus will be used in summaryq, reading from widgets not an option section probably better suited for Config.cpp/h, since quite a bit of duplicated code from createSummaryWidget --- src/modules/partition/PartitionViewStep.cpp | 90 +++++++++++++++++++++ src/modules/partition/PartitionViewStep.h | 1 + 2 files changed, 91 insertions(+) diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index 015aab2ce..8881d4569 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -109,6 +109,96 @@ PartitionViewStep::prettyName() const return tr( "Partitions" ); } +QString +PartitionViewStep::prettyStatus() const +{ + //return tr( "Create new GPT partition table on /dev/sdb" ); //includes %1" ); .arg ( m_pkgc ); + QString jobsLabel, modeText, diskInfoLabel; + + Config::InstallChoice choice = m_config->installChoice(); + const auto* branding = Calamares::Branding::instance(); + + QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo(); + + cDebug() << "Summary for Partition" << list.length() << choice; + if ( list.length() > 1 ) // There are changes on more than one disk + { +// NOTE: all of this should only happen when Manual partitioning is active. +// Any other choice should result in a list.length() == 1. + switch ( choice ) + { + case Config::Alongside: + modeText = tr( "Install %1 alongside another operating system." ) + .arg( branding->shortVersionedName() ); + break; + case Config::Erase: + modeText + = tr( "Erase disk and install %1." ).arg( branding->shortVersionedName() ); + break; + case Config::Replace: + modeText + = tr( "Replace a partition with %1." ).arg( branding->shortVersionedName() ); + break; + case Config::NoChoice: + case Config::Manual: + modeText = tr( "Manual partitioning." ); + } + } + + for ( const auto& info : list ) + { + if ( list.length() == 1 ) // this is the only disk preview + { + switch ( choice ) + { + case Config::Alongside: + diskInfoLabel = tr( "Install %1 alongside another operating system on disk " + "%2 (%3)." ) + .arg( branding->shortVersionedName() ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + break; + case Config::Erase: + diskInfoLabel = tr( "Erase disk %2 (%3) and install %1." ) + .arg( branding->shortVersionedName() ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + break; + case Config::Replace: + diskInfoLabel = tr( "Replace a partition on disk %2 (%3) with %1." ) + .arg( branding->shortVersionedName() ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + break; + case Config::NoChoice: + case Config::Manual: + diskInfoLabel = tr( "Manual partitioning on disk %1 (%2)." ) + .arg( info.deviceNode ) + .arg( info.deviceName ); + } + } + else // multiple disk previews! + { + diskInfoLabel = tr( "Disk %1 (%2)" ).arg( info.deviceNode ).arg( info.deviceName ) ; + } + } + + QStringList jobsLines; + foreach ( const Calamares::job_ptr& job, jobs() ) + { + if ( !job->prettyDescription().isEmpty() ) + { + jobsLines.append( job->prettyDescription() ); + } + } + if ( !jobsLines.isEmpty() ) + { + jobsLabel = jobsLines.join( "
" ); + } + + return diskInfoLabel + "
" + jobsLabel; +} + QWidget* PartitionViewStep::widget() diff --git a/src/modules/partition/PartitionViewStep.h b/src/modules/partition/PartitionViewStep.h index 9f3da9f3d..ecba73f45 100644 --- a/src/modules/partition/PartitionViewStep.h +++ b/src/modules/partition/PartitionViewStep.h @@ -43,6 +43,7 @@ public: ~PartitionViewStep() override; QString prettyName() const override; + QString prettyStatus() const override; QWidget* createSummaryWidget() const override; QWidget* widget() override;