Merge branch 'improve-swap-ui' of https://github.com/calamares/calamares into development
This commit is contained in:
commit
067ca16112
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Units.h"
|
#include "utils/Units.h"
|
||||||
|
#include "utils/NamedEnum.h"
|
||||||
|
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
@ -303,4 +305,35 @@ doReplacePartition( PartitionCoreModule* core,
|
|||||||
core->dumpQueue();
|
core->dumpQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Choices
|
||||||
|
{
|
||||||
|
static const NamedEnumTable<SwapChoice>&
|
||||||
|
nameTable()
|
||||||
|
{
|
||||||
|
static const NamedEnumTable<SwapChoice> names{
|
||||||
|
{ QStringLiteral( "none" ), SwapChoice::NoSwap },
|
||||||
|
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
|
||||||
|
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
|
||||||
|
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
|
||||||
|
{ QStringLiteral( "file" ), SwapChoice::SwapFile }
|
||||||
|
};
|
||||||
|
|
||||||
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SwapChoice
|
||||||
|
nameToChoice( QString name, bool& ok )
|
||||||
|
{
|
||||||
|
return nameTable().find( name, ok );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
choiceToName( SwapChoice c )
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
return nameTable().find( c, ok );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Choices
|
||||||
|
|
||||||
|
} // namespace PartitionActions
|
||||||
|
@ -43,6 +43,9 @@ namespace Choices
|
|||||||
SwapFile // use a file (if supported)
|
SwapFile // use a file (if supported)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SwapChoice nameToChoice( QString name, bool& ok );
|
||||||
|
QString choiceToName( SwapChoice );
|
||||||
|
|
||||||
struct ReplacePartitionOptions
|
struct ReplacePartitionOptions
|
||||||
{
|
{
|
||||||
QString defaultFsType; // e.g. "ext4" or "btrfs"
|
QString defaultFsType; // e.g. "ext4" or "btrfs"
|
||||||
|
@ -66,14 +66,20 @@
|
|||||||
|
|
||||||
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.
|
||||||
* @param compactMode if true, the drive selector will be a combo box on top, otherwise it
|
|
||||||
* will show up as a list view.
|
|
||||||
* @param parent the QWidget parent.
|
* @param parent the QWidget parent.
|
||||||
*/
|
*/
|
||||||
ChoicePage::ChoicePage( QWidget* parent )
|
ChoicePage::ChoicePage( const SwapChoiceSet& swapChoices, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_nextEnabled( false )
|
, m_nextEnabled( false )
|
||||||
, m_core( nullptr )
|
, m_core( nullptr )
|
||||||
@ -85,14 +91,14 @@ ChoicePage::ChoicePage( QWidget* parent )
|
|||||||
, m_replaceButton( nullptr )
|
, m_replaceButton( nullptr )
|
||||||
, m_somethingElseButton( nullptr )
|
, m_somethingElseButton( nullptr )
|
||||||
, m_eraseSwapChoices( nullptr )
|
, m_eraseSwapChoices( nullptr )
|
||||||
, m_replaceSwapChoices( nullptr )
|
|
||||||
, m_alongsideSwapChoices( nullptr )
|
|
||||||
, m_deviceInfoWidget( nullptr )
|
, m_deviceInfoWidget( nullptr )
|
||||||
, m_beforePartitionBarsView( nullptr )
|
, m_beforePartitionBarsView( nullptr )
|
||||||
, m_beforePartitionLabelsView( nullptr )
|
, m_beforePartitionLabelsView( nullptr )
|
||||||
, m_bootloaderComboBox( nullptr )
|
, m_bootloaderComboBox( nullptr )
|
||||||
, m_lastSelectedDeviceIndex( -1 )
|
, m_lastSelectedDeviceIndex( -1 )
|
||||||
, m_enableEncryptionWidget( true )
|
, m_enableEncryptionWidget( true )
|
||||||
|
, m_availableSwapChoices( swapChoices )
|
||||||
|
, m_eraseSwapChoice( pickOne( swapChoices ) )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
|
|
||||||
@ -195,6 +201,16 @@ createCombo( std::initializer_list< SwapChoice > l )
|
|||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline QComboBox*
|
||||||
|
createCombo( const QSet< SwapChoice >& s )
|
||||||
|
{
|
||||||
|
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 );
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ChoicePage::setupChoices creates PrettyRadioButton objects for the action
|
* @brief ChoicePage::setupChoices creates PrettyRadioButton objects for the action
|
||||||
* choices.
|
* choices.
|
||||||
@ -250,16 +266,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( { SwapChoice::NoSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap } );
|
if ( m_availableSwapChoices.count() > 1 )
|
||||||
m_eraseButton->addOptionsComboBox( m_eraseSwapChoices );
|
{
|
||||||
|
m_eraseSwapChoices = createCombo( m_availableSwapChoices );
|
||||||
#if 0
|
m_eraseButton->addOptionsComboBox( m_eraseSwapChoices );
|
||||||
m_replaceSwapChoices = createCombo( { SwapChoice::NoSwap, SwapChoice::ReuseSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap } );
|
}
|
||||||
m_replaceButton->addOptionsComboBox( m_replaceSwapChoices );
|
|
||||||
|
|
||||||
m_alongsideSwapChoices = createCombo( { SwapChoice::NoSwap, SwapChoice::ReuseSwap, SwapChoice::SmallSwap, SwapChoice::FullSwap } );
|
|
||||||
m_alongsideButton->addOptionsComboBox( m_alongsideSwapChoices );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_itemsLayout->addWidget( m_alongsideButton );
|
m_itemsLayout->addWidget( m_alongsideButton );
|
||||||
m_itemsLayout->addWidget( m_replaceButton );
|
m_itemsLayout->addWidget( m_replaceButton );
|
||||||
@ -306,19 +317,12 @@ ChoicePage::setupChoices()
|
|||||||
m_rightLayout->setStretchFactor( m_previewAfterFrame, 0 );
|
m_rightLayout->setStretchFactor( m_previewAfterFrame, 0 );
|
||||||
|
|
||||||
connect( this, &ChoicePage::actionChosen,
|
connect( this, &ChoicePage::actionChosen,
|
||||||
this, [=]
|
this, &ChoicePage::onActionChanged );
|
||||||
{
|
connect( m_eraseSwapChoices, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
Device* currd = selectedDevice();
|
this, &ChoicePage::onActionChanged );
|
||||||
if ( currd )
|
|
||||||
{
|
|
||||||
applyActionChoice( currentChoice() );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE(
|
||||||
updateSwapChoicesTr( m_eraseSwapChoices );
|
updateSwapChoicesTr( m_eraseSwapChoices );
|
||||||
updateSwapChoicesTr( m_alongsideSwapChoices );
|
|
||||||
updateSwapChoicesTr( m_replaceSwapChoices );
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,6 +417,17 @@ ChoicePage::continueApplyDeviceChoice()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ChoicePage::onActionChanged()
|
||||||
|
{
|
||||||
|
Device* currd = selectedDevice();
|
||||||
|
if ( currd )
|
||||||
|
{
|
||||||
|
applyActionChoice( currentChoice() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
|
ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
|
||||||
{
|
{
|
||||||
|
@ -26,9 +26,11 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "core/OsproberEntry.h"
|
#include "core/OsproberEntry.h"
|
||||||
|
#include "core/PartitionActions.h"
|
||||||
|
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
class QBoxLayout;
|
class QBoxLayout;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
@ -44,6 +46,7 @@ class DeviceInfoWidget;
|
|||||||
|
|
||||||
class Device;
|
class Device;
|
||||||
|
|
||||||
|
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.
|
||||||
@ -63,7 +66,7 @@ public:
|
|||||||
Manual
|
Manual
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ChoicePage( QWidget* parent = nullptr );
|
explicit ChoicePage( const SwapChoiceSet& swapChoices, QWidget* parent = nullptr );
|
||||||
virtual ~ChoicePage();
|
virtual ~ChoicePage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,6 +116,9 @@ private slots:
|
|||||||
void onEncryptWidgetStateChanged();
|
void onEncryptWidgetStateChanged();
|
||||||
void onHomeCheckBoxStateChanged();
|
void onHomeCheckBoxStateChanged();
|
||||||
|
|
||||||
|
/** @brief Calls applyActionChoice() as needed. */
|
||||||
|
void onActionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateNextEnabled();
|
void updateNextEnabled();
|
||||||
void setupChoices();
|
void setupChoices();
|
||||||
@ -149,9 +155,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
|
||||||
QComboBox* m_replaceSwapChoices;
|
|
||||||
QComboBox* m_alongsideSwapChoices;
|
|
||||||
|
|
||||||
DeviceInfoWidget* m_deviceInfoWidget;
|
DeviceInfoWidget* m_deviceInfoWidget;
|
||||||
|
|
||||||
@ -168,6 +172,8 @@ private:
|
|||||||
|
|
||||||
QString m_defaultFsType;
|
QString m_defaultFsType;
|
||||||
bool m_enableEncryptionWidget;
|
bool m_enableEncryptionWidget;
|
||||||
|
SwapChoiceSet m_availableSwapChoices; // What is available
|
||||||
|
PartitionActions::Choices::SwapChoice m_eraseSwapChoice; // what is selected
|
||||||
|
|
||||||
QMutex m_coreMutex;
|
QMutex m_coreMutex;
|
||||||
};
|
};
|
||||||
|
@ -93,7 +93,7 @@ PartitionViewStep::continueLoading()
|
|||||||
Q_ASSERT( !m_manualPartitionPage );
|
Q_ASSERT( !m_manualPartitionPage );
|
||||||
|
|
||||||
m_manualPartitionPage = new PartitionPage( m_core );
|
m_manualPartitionPage = new PartitionPage( m_core );
|
||||||
m_choicePage = new ChoicePage();
|
m_choicePage = new ChoicePage( m_swapChoices );
|
||||||
|
|
||||||
m_choicePage->init( m_core );
|
m_choicePage->init( m_core );
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
for ( const auto& item : l )
|
for ( const auto& item : l )
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
auto v = nameToChoice( item, ok );
|
auto v = PartitionActions::Choices::nameToChoice( item, ok );
|
||||||
if ( ok )
|
if ( ok )
|
||||||
choices.insert( v );
|
choices.insert( v );
|
||||||
}
|
}
|
||||||
@ -612,6 +612,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
else
|
else
|
||||||
choices.insert( PartitionActions::Choices::SwapChoice::SmallSwap );
|
choices.insert( PartitionActions::Choices::SwapChoice::SmallSwap );
|
||||||
}
|
}
|
||||||
|
m_swapChoices = choices;
|
||||||
|
|
||||||
// These gs settings seem to be unused (in upstream Calamares) outside of
|
// These gs settings seem to be unused (in upstream Calamares) outside of
|
||||||
// the partition module itself.
|
// the partition module itself.
|
||||||
|
@ -26,7 +26,10 @@
|
|||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <PluginDllMacro.h>
|
||||||
|
|
||||||
|
#include "core/PartitionActions.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
class ChoicePage;
|
class ChoicePage;
|
||||||
class PartitionPage;
|
class PartitionPage;
|
||||||
@ -76,6 +79,8 @@ private:
|
|||||||
PartitionPage* m_manualPartitionPage;
|
PartitionPage* m_manualPartitionPage;
|
||||||
|
|
||||||
QWidget* m_waitingWidget;
|
QWidget* m_waitingWidget;
|
||||||
|
|
||||||
|
QSet< PartitionActions::Choices::SwapChoice > m_swapChoices;
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( PartitionViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( PartitionViewStepFactory )
|
||||||
|
@ -26,10 +26,10 @@ efiSystemPartition: "/boot/efi"
|
|||||||
# 8.8GiB on disk in the end).
|
# 8.8GiB on disk in the end).
|
||||||
userSwapChoices:
|
userSwapChoices:
|
||||||
- none # Create no swap, use no swap
|
- none # Create no swap, use no swap
|
||||||
# - reuse # Re-use existing swap, but don't create any
|
- reuse # Re-use existing swap, but don't create any
|
||||||
- small # Up to 4GB
|
- small # Up to 4GB
|
||||||
- suspend # At least main memory size
|
- suspend # At least main memory size
|
||||||
# - file # To swap file instead of partition (unsupported right now)
|
- file # To swap file instead of partition (unsupported right now)
|
||||||
|
|
||||||
# LEGACY SETTINGS (these will generate a warning)
|
# LEGACY SETTINGS (these will generate a warning)
|
||||||
# ensureSuspendToDisk: true
|
# ensureSuspendToDisk: true
|
||||||
|
Loading…
Reference in New Issue
Block a user