summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan de Groot <groot@kde.org>2019-02-12 07:30:34 -0500
committerAdriaan de Groot <groot@kde.org>2019-02-12 07:30:34 -0500
commit2a8960cd0ff5f7b4472935cd5601bc193baa2a3b (patch)
tree2105e9008a7a84a52cc274bc6031f25d20c214dd
parent5f20eedb6e0f11731848f4252d778cacebfd4459 (diff)
[partition] Ensure combobox pre-selects consistently
- Match the selected item in the combobox with a given default, which should be whatever is selected from the available set of choices.
-rw-r--r--src/modules/partition/gui/ChoicePage.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp
index ee7905c33..7c980cf49 100644
--- a/src/modules/partition/gui/ChoicePage.cpp
+++ b/src/modules/partition/gui/ChoicePage.cpp
@@ -201,15 +201,21 @@ ChoicePage::init( PartitionCoreModule* core )
/** @brief Creates a combobox with the given choices in it.
*
+ * Pre-selects the choice given by @p dflt.
* No texts are set -- that happens later by the translator functions.
*/
static inline QComboBox*
-createCombo( const QSet< SwapChoice >& s )
+createCombo( const QSet< SwapChoice >& s, SwapChoice dflt )
{
QComboBox* box = new QComboBox;
for ( SwapChoice c : { SwapChoice::NoSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap, SwapChoice::ReuseSwap, SwapChoice::SwapFile } )
if ( s.contains( c ) )
box->addItem( QString(), c );
+
+ int dfltIndex = box->findData( dflt );
+ if ( dfltIndex >= 0 )
+ box->setCurrentIndex( dfltIndex );
+
return box;
}
@@ -270,7 +276,7 @@ ChoicePage::setupChoices()
// .. TODO: only if enabled in the config
if ( m_availableSwapChoices.count() > 1 )
{
- m_eraseSwapChoiceComboBox = createCombo( m_availableSwapChoices );
+ m_eraseSwapChoiceComboBox = createCombo( m_availableSwapChoices, m_eraseSwapChoice );
m_eraseButton->addOptionsComboBox( m_eraseSwapChoiceComboBox );
}