[partition] Only create drop-down if there is something to select
- Swap choices may be 0 (then choose none), 1 (choose that one) or more (currently undecided)
This commit is contained in:
parent
00df8a9fb1
commit
4973d00ace
@ -65,6 +65,14 @@
|
|||||||
|
|
||||||
using PartitionActions::Choices::SwapChoice;
|
using PartitionActions::Choices::SwapChoice;
|
||||||
|
|
||||||
|
SwapChoice pickOne( const SwapChoiceSet& s )
|
||||||
|
{
|
||||||
|
if ( s.count() == 1 )
|
||||||
|
for ( auto i = s.begin(); i != s.end(); ++i )
|
||||||
|
return *i; // That's the only element
|
||||||
|
return SwapChoice::NoSwap;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of
|
* @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of
|
||||||
* the module loading code path.
|
* the module loading code path.
|
||||||
@ -90,7 +98,8 @@ ChoicePage::ChoicePage( const SwapChoiceSet& swapChoices, QWidget* parent )
|
|||||||
, m_bootloaderComboBox( nullptr )
|
, m_bootloaderComboBox( nullptr )
|
||||||
, m_lastSelectedDeviceIndex( -1 )
|
, m_lastSelectedDeviceIndex( -1 )
|
||||||
, m_enableEncryptionWidget( true )
|
, m_enableEncryptionWidget( true )
|
||||||
, m_swapChoices( swapChoices )
|
, m_availableSwapChoices( swapChoices )
|
||||||
|
, m_eraseSwapChoice( pickOne( swapChoices ) )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
@ -258,8 +267,11 @@ ChoicePage::setupChoices()
|
|||||||
|
|
||||||
// Fill up swap options
|
// Fill up swap options
|
||||||
// .. TODO: only if enabled in the config
|
// .. TODO: only if enabled in the config
|
||||||
m_eraseSwapChoices = createCombo( m_swapChoices );
|
if ( m_availableSwapChoices.count() > 1 )
|
||||||
|
{
|
||||||
|
m_eraseSwapChoices = createCombo( m_availableSwapChoices );
|
||||||
m_eraseButton->addOptionsComboBox( m_eraseSwapChoices );
|
m_eraseButton->addOptionsComboBox( m_eraseSwapChoices );
|
||||||
|
}
|
||||||
|
|
||||||
m_itemsLayout->addWidget( m_alongsideButton );
|
m_itemsLayout->addWidget( m_alongsideButton );
|
||||||
m_itemsLayout->addWidget( m_replaceButton );
|
m_itemsLayout->addWidget( m_replaceButton );
|
||||||
|
@ -45,7 +45,7 @@ class DeviceInfoWidget;
|
|||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
using SwapChoiceSet = QSet< PartitionActions::Choices::SwapChoice>;
|
using SwapChoiceSet = QSet< PartitionActions::Choices::SwapChoice >;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ChoicePage class is the first page of the partitioning interface.
|
* @brief The ChoicePage class is the first page of the partitioning interface.
|
||||||
@ -151,7 +151,7 @@ private:
|
|||||||
PrettyRadioButton* m_eraseButton;
|
PrettyRadioButton* m_eraseButton;
|
||||||
PrettyRadioButton* m_replaceButton;
|
PrettyRadioButton* m_replaceButton;
|
||||||
PrettyRadioButton* m_somethingElseButton;
|
PrettyRadioButton* m_somethingElseButton;
|
||||||
QComboBox* m_eraseSwapChoices;
|
QComboBox* m_eraseSwapChoices; // UI, see also m_swapChoices
|
||||||
|
|
||||||
DeviceInfoWidget* m_deviceInfoWidget;
|
DeviceInfoWidget* m_deviceInfoWidget;
|
||||||
|
|
||||||
@ -168,7 +168,8 @@ private:
|
|||||||
|
|
||||||
QString m_defaultFsType;
|
QString m_defaultFsType;
|
||||||
bool m_enableEncryptionWidget;
|
bool m_enableEncryptionWidget;
|
||||||
SwapChoiceSet m_swapChoices;
|
SwapChoiceSet m_availableSwapChoices; // What is available
|
||||||
|
PartitionActions::Choices::SwapChoice m_eraseSwapChoice; // what is selected
|
||||||
|
|
||||||
QMutex m_coreMutex;
|
QMutex m_coreMutex;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user