[partition] Migrate required-storage setting to Config object
- Create and use the config object in the view step - Add setConfigurationMap() to Config
This commit is contained in:
parent
c7857b7749
commit
a381d6794f
@ -17,3 +17,31 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
|
Config::Config( QObject* parent )
|
||||||
|
: QObject( parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
|
{
|
||||||
|
// Settings that overlap with the Welcome module
|
||||||
|
m_requiredStorageGiB = CalamaresUtils::getDouble( configurationMap, "requiredStorage", -1.0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Config::updateGlobalStorage() const
|
||||||
|
{
|
||||||
|
// If there's no setting (e.g. from the welcome page) for required storage
|
||||||
|
// then use ours, if it was set.
|
||||||
|
auto* gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||||
|
if ( m_requiredStorageGiB >= 0.0 && gs && !gs->contains( "requiredStorageGiB" ) )
|
||||||
|
{
|
||||||
|
gs->insert( "requiredStorageGiB", m_requiredStorageGiB );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -29,14 +29,14 @@ class Config : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config() = default;
|
Config( QObject* parent );
|
||||||
virtual ~Config() = default;
|
virtual ~Config() = default;
|
||||||
|
|
||||||
using SwapChoiceSet = QSet< PartitionActions::Choices::SwapChoice >;
|
void setConfigurationMap( const QVariantMap& );
|
||||||
|
|
||||||
|
void updateGlobalStorage() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SwapChoiceSet m_swapChoices;
|
|
||||||
|
|
||||||
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module
|
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "gui/PartitionViewStep.h"
|
#include "gui/PartitionViewStep.h"
|
||||||
|
|
||||||
|
#include "core/Config.h"
|
||||||
#include "core/DeviceModel.h"
|
#include "core/DeviceModel.h"
|
||||||
#include "core/KPMHelpers.h"
|
#include "core/KPMHelpers.h"
|
||||||
#include "core/OsproberEntry.h"
|
#include "core/OsproberEntry.h"
|
||||||
@ -64,11 +65,11 @@
|
|||||||
|
|
||||||
PartitionViewStep::PartitionViewStep( QObject* parent )
|
PartitionViewStep::PartitionViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
|
, m_config( new Config( this ) )
|
||||||
, m_core( nullptr )
|
, m_core( nullptr )
|
||||||
, m_widget( new QStackedWidget() )
|
, m_widget( new QStackedWidget() )
|
||||||
, m_choicePage( nullptr )
|
, m_choicePage( nullptr )
|
||||||
, m_manualPartitionPage( nullptr )
|
, m_manualPartitionPage( nullptr )
|
||||||
, m_requiredStorageGiB( 0.0 )
|
|
||||||
{
|
{
|
||||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
|
||||||
@ -385,13 +386,7 @@ PartitionViewStep::isAtEnd() const
|
|||||||
void
|
void
|
||||||
PartitionViewStep::onActivate()
|
PartitionViewStep::onActivate()
|
||||||
{
|
{
|
||||||
// If there's no setting (e.g. from the welcome page) for required storage
|
m_config->updateGlobalStorage();
|
||||||
// then use ours, if it was set.
|
|
||||||
auto* gs = Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
|
||||||
if ( m_requiredStorageGiB >= 0.0 && gs && !gs->contains( "requiredStorageGiB" ) )
|
|
||||||
{
|
|
||||||
gs->insert( "requiredStorageGiB", m_requiredStorageGiB );
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we're coming back to PVS from the next VS
|
// if we're coming back to PVS from the next VS
|
||||||
if ( m_widget->currentWidget() == m_choicePage && m_choicePage->currentChoice() == ChoicePage::Alongside )
|
if ( m_widget->currentWidget() == m_choicePage && m_choicePage->currentChoice() == ChoicePage::Alongside )
|
||||||
@ -525,6 +520,8 @@ PartitionViewStep::onLeave()
|
|||||||
void
|
void
|
||||||
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
|
m_config->setConfigurationMap( configurationMap );
|
||||||
|
|
||||||
// Copy the efiSystemPartition setting to the global storage. It is needed not only in
|
// Copy the efiSystemPartition setting to the global storage. It is needed not only in
|
||||||
// the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader).
|
// the EraseDiskPage, but also in the bootloader configuration modules (grub, bootloader).
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
@ -635,9 +632,6 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
|
|
||||||
m_swapChoices = choices;
|
m_swapChoices = choices;
|
||||||
|
|
||||||
// Settings that overlap with the Welcome module
|
|
||||||
m_requiredStorageGiB = CalamaresUtils::getDouble( configurationMap, "requiredStorage", -1.0 );
|
|
||||||
|
|
||||||
// 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.
|
||||||
gs->insert( "ensureSuspendToDisk", ensureSuspendToDisk );
|
gs->insert( "ensureSuspendToDisk", ensureSuspendToDisk );
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
class ChoicePage;
|
class ChoicePage;
|
||||||
|
class Config;
|
||||||
class PartitionPage;
|
class PartitionPage;
|
||||||
class PartitionCoreModule;
|
class PartitionCoreModule;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
@ -78,6 +79,8 @@ private:
|
|||||||
void initPartitionCoreModule();
|
void initPartitionCoreModule();
|
||||||
void continueLoading();
|
void continueLoading();
|
||||||
|
|
||||||
|
Config* m_config;
|
||||||
|
|
||||||
PartitionCoreModule* m_core;
|
PartitionCoreModule* m_core;
|
||||||
QStackedWidget* m_widget;
|
QStackedWidget* m_widget;
|
||||||
ChoicePage* m_choicePage;
|
ChoicePage* m_choicePage;
|
||||||
@ -87,8 +90,6 @@ private:
|
|||||||
QFutureWatcher<void>* m_future;
|
QFutureWatcher<void>* m_future;
|
||||||
|
|
||||||
QSet< PartitionActions::Choices::SwapChoice > m_swapChoices;
|
QSet< PartitionActions::Choices::SwapChoice > m_swapChoices;
|
||||||
|
|
||||||
qreal m_requiredStorageGiB; // May duplicate setting in the welcome module
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( PartitionViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( PartitionViewStepFactory )
|
||||||
|
Loading…
Reference in New Issue
Block a user