Enable/disable Next button based on whether we have a root mount point

This commit is contained in:
Aurélien Gâteau 2014-07-07 16:26:56 +02:00
parent 52028d95f9
commit 36b3de7107
3 changed files with 29 additions and 2 deletions

View file

@ -88,13 +88,28 @@ PartitionCoreModule::createPartition( Device* device, PartitionInfo* partitionIn
partitionModel->reload(); partitionModel->reload();
m_jobs << Calamares::job_ptr( job ); m_jobs << Calamares::job_ptr( job );
if ( partitionInfo->mountPoint == "/" && !m_hasRootMountPoint )
{
m_hasRootMountPoint = true;
hasRootMountPointChanged( m_hasRootMountPoint );
}
dumpQueue(); dumpQueue();
} }
void void
PartitionCoreModule::deletePartition( Device* device, Partition* partition ) PartitionCoreModule::deletePartition( Device* device, Partition* partition )
{ {
m_infoForPartitionHash.remove( partition ); auto it = m_infoForPartitionHash.find( partition );
if ( it != m_infoForPartitionHash.end() )
{
if ( it.value()->mountPoint == "/" )
{
m_hasRootMountPoint = false;
hasRootMountPointChanged( m_hasRootMountPoint );
}
m_infoForPartitionHash.erase( it );
}
if ( partition->state() == Partition::StateNew ) if ( partition->state() == Partition::StateNew )
{ {

View file

@ -41,6 +41,7 @@ class PartitionModel;
*/ */
class PartitionCoreModule : public QObject class PartitionCoreModule : public QObject
{ {
Q_OBJECT
public: public:
PartitionCoreModule( QObject* parent = nullptr ); PartitionCoreModule( QObject* parent = nullptr );
~PartitionCoreModule(); ~PartitionCoreModule();
@ -58,10 +59,19 @@ public:
return m_jobs; return m_jobs;
} }
bool hasRootMountPoint() const
{
return m_hasRootMountPoint;
}
Q_SIGNALS:
void hasRootMountPointChanged( bool value );
private: private:
QList< Device* > m_devices; QList< Device* > m_devices;
QHash< Device*, PartitionModel* > m_partitionModelForDeviceHash; QHash< Device*, PartitionModel* > m_partitionModelForDeviceHash;
DeviceModel* m_deviceModel; DeviceModel* m_deviceModel;
bool m_hasRootMountPoint = false;
InfoForPartitionHash m_infoForPartitionHash; InfoForPartitionHash m_infoForPartitionHash;

View file

@ -27,6 +27,8 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
, m_core( new PartitionCoreModule( this ) ) , m_core( new PartitionCoreModule( this ) )
, m_widget( new PartitionPage( m_core ) ) , m_widget( new PartitionPage( m_core ) )
{ {
connect( m_core, SIGNAL( hasRootMountPointChanged( bool ) ),
SIGNAL( nextStatusChanged( bool ) ) );
} }
@ -60,7 +62,7 @@ PartitionViewStep::back()
bool bool
PartitionViewStep::isNextEnabled() const PartitionViewStep::isNextEnabled() const
{ {
return false; return m_core->hasRootMountPoint();
} }