mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-28 01:45:36 -04:00
[partition] Simplify code a little
- Document and make pickOne() more correct - Reduce calls to globalStorage(), it doesn't change
This commit is contained in:
parent
e85fedfd41
commit
8ecae75dc8
1 changed files with 18 additions and 10 deletions
|
@ -66,12 +66,22 @@
|
||||||
|
|
||||||
using PartitionActions::Choices::SwapChoice;
|
using PartitionActions::Choices::SwapChoice;
|
||||||
|
|
||||||
|
/** @brief Given a set of swap choices, return a sensible value from it.
|
||||||
|
*
|
||||||
|
* "Sensible" here means: if there is one value, use it; otherwise, use
|
||||||
|
* NoSwap if there are no choices, or if NoSwap is one of the choices, in the set.
|
||||||
|
* If that's not possible, any value from the set.
|
||||||
|
*/
|
||||||
SwapChoice pickOne( const SwapChoiceSet& s )
|
SwapChoice pickOne( const SwapChoiceSet& s )
|
||||||
{
|
{
|
||||||
|
if ( s.count() == 0 )
|
||||||
|
return SwapChoice::NoSwap;
|
||||||
if ( s.count() == 1 )
|
if ( s.count() == 1 )
|
||||||
for ( auto i = s.begin(); i != s.end(); ++i )
|
return *( s.begin() );
|
||||||
return *i; // That's the only element
|
if ( s.contains( SwapChoice::NoSwap ) )
|
||||||
return SwapChoice::NoSwap;
|
return SwapChoice::NoSwap;
|
||||||
|
// Here, count > 1 but NoSwap is not a member.
|
||||||
|
return *( s.begin() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,12 +112,10 @@ ChoicePage::ChoicePage( const SwapChoiceSet& swapChoices, QWidget* parent )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
m_defaultFsType = Calamares::JobQueue::instance()->
|
auto gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
globalStorage()->
|
|
||||||
value( "defaultFileSystemType" ).toString();
|
m_defaultFsType = gs->value( "defaultFileSystemType" ).toString();
|
||||||
m_enableEncryptionWidget = Calamares::JobQueue::instance()->
|
m_enableEncryptionWidget = gs->value( "enableLuksAutomatedPartitioning" ).toBool();
|
||||||
globalStorage()->
|
|
||||||
value( "enableLuksAutomatedPartitioning" ).toBool();
|
|
||||||
if ( FileSystem::typeForName( m_defaultFsType ) == FileSystem::Unknown )
|
if ( FileSystem::typeForName( m_defaultFsType ) == FileSystem::Unknown )
|
||||||
m_defaultFsType = "ext4";
|
m_defaultFsType = "ext4";
|
||||||
|
|
||||||
|
@ -149,7 +157,7 @@ ChoicePage::ChoicePage( const SwapChoiceSet& swapChoices, QWidget* parent )
|
||||||
m_previewAfterFrame->hide();
|
m_previewAfterFrame->hide();
|
||||||
m_encryptWidget->hide();
|
m_encryptWidget->hide();
|
||||||
m_reuseHomeCheckBox->hide();
|
m_reuseHomeCheckBox->hide();
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( "reuseHome", false );
|
gs->insert( "reuseHome", false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue