Allow users to set/edit filesystem labels.
When creating or editing a new formatted partition, allow to set a filesystem label (16 chars maximum). Modify the KPMHelpers to accept it as a new parameter. Partitions created by default may get a meaningful label too.
This commit is contained in:
parent
1cfdc8044c
commit
b602d423c7
@ -46,11 +46,13 @@ createNewPartition( PartitionNode* parent,
|
|||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
|
const QString& fsLabel,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
PartitionTable::Flags flags )
|
PartitionTable::Flags flags )
|
||||||
{
|
{
|
||||||
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
|
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
|
||||||
|
fs->setLabel( fsLabel );
|
||||||
return new Partition( parent,
|
return new Partition( parent,
|
||||||
device,
|
device,
|
||||||
role,
|
role,
|
||||||
@ -71,6 +73,7 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
|
const QString& fsLabel,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
const QString& passphrase,
|
const QString& passphrase,
|
||||||
@ -92,6 +95,7 @@ createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
|
|
||||||
fs->createInnerFileSystem( fsType );
|
fs->createInnerFileSystem( fsType );
|
||||||
fs->setPassphrase( passphrase );
|
fs->setPassphrase( passphrase );
|
||||||
|
fs->setLabel( fsLabel );
|
||||||
Partition* p = new Partition( parent,
|
Partition* p = new Partition( parent,
|
||||||
device,
|
device,
|
||||||
PartitionRole( newRoles ),
|
PartitionRole( newRoles ),
|
||||||
|
@ -55,6 +55,7 @@ Partition* createNewPartition( PartitionNode* parent,
|
|||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
|
const QString& fsLabel,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
PartitionTable::Flags flags );
|
PartitionTable::Flags flags );
|
||||||
@ -63,6 +64,7 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
|
|||||||
const Device& device,
|
const Device& device,
|
||||||
const PartitionRole& role,
|
const PartitionRole& role,
|
||||||
FileSystem::Type fsType,
|
FileSystem::Type fsType,
|
||||||
|
const QString& fsLabel,
|
||||||
qint64 firstSector,
|
qint64 firstSector,
|
||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
const QString& passphrase,
|
const QString& passphrase,
|
||||||
|
@ -132,6 +132,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
*dev,
|
*dev,
|
||||||
PartitionRole( PartitionRole::Primary ),
|
PartitionRole( PartitionRole::Primary ),
|
||||||
FileSystem::Fat32,
|
FileSystem::Fat32,
|
||||||
|
QString(),
|
||||||
firstFreeSector,
|
firstFreeSector,
|
||||||
lastSector,
|
lastSector,
|
||||||
KPM_PARTITION_FLAG( None ) );
|
KPM_PARTITION_FLAG( None ) );
|
||||||
@ -180,6 +181,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
*dev,
|
*dev,
|
||||||
PartitionRole( PartitionRole::Primary ),
|
PartitionRole( PartitionRole::Primary ),
|
||||||
FileSystem::LinuxSwap,
|
FileSystem::LinuxSwap,
|
||||||
|
QStringLiteral( "swap" ),
|
||||||
lastSectorForRoot + 1,
|
lastSectorForRoot + 1,
|
||||||
dev->totalLogical() - 1,
|
dev->totalLogical() - 1,
|
||||||
KPM_PARTITION_FLAG( None ) );
|
KPM_PARTITION_FLAG( None ) );
|
||||||
@ -190,6 +192,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
|||||||
*dev,
|
*dev,
|
||||||
PartitionRole( PartitionRole::Primary ),
|
PartitionRole( PartitionRole::Primary ),
|
||||||
FileSystem::LinuxSwap,
|
FileSystem::LinuxSwap,
|
||||||
|
QStringLiteral( "swap" ),
|
||||||
lastSectorForRoot + 1,
|
lastSectorForRoot + 1,
|
||||||
dev->totalLogical() - 1,
|
dev->totalLogical() - 1,
|
||||||
o.luksPassphrase,
|
o.luksPassphrase,
|
||||||
|
@ -911,6 +911,14 @@ PartitionCoreModule::layoutApply( Device* dev,
|
|||||||
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
|
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
|
||||||
for ( Partition* part : partList )
|
for ( Partition* part : partList )
|
||||||
{
|
{
|
||||||
|
if ( is_boot( part ) )
|
||||||
|
{
|
||||||
|
part->setLabel( "boot" );
|
||||||
|
}
|
||||||
|
if ( is_root( part ) )
|
||||||
|
{
|
||||||
|
part->setLabel( "root" );
|
||||||
|
}
|
||||||
if ( ( separate_boot_partition && is_boot( part ) ) || ( !separate_boot_partition && is_root( part ) ) )
|
if ( ( separate_boot_partition && is_boot( part ) ) || ( !separate_boot_partition && is_root( part ) ) )
|
||||||
{
|
{
|
||||||
createPartition(
|
createPartition(
|
||||||
|
@ -202,17 +202,18 @@ CreatePartitionDialog::createPartition()
|
|||||||
FileSystem::Type fsType = m_role.has( PartitionRole::Extended )
|
FileSystem::Type fsType = m_role.has( PartitionRole::Extended )
|
||||||
? FileSystem::Extended
|
? FileSystem::Extended
|
||||||
: FileSystem::typeForName( m_ui->fsComboBox->currentText() );
|
: FileSystem::typeForName( m_ui->fsComboBox->currentText() );
|
||||||
|
const QString fsLabel = m_ui->filesystemLabelEdit->text();
|
||||||
|
|
||||||
Partition* partition = nullptr;
|
Partition* partition = nullptr;
|
||||||
QString luksPassphrase = m_ui->encryptWidget->passphrase();
|
QString luksPassphrase = m_ui->encryptWidget->passphrase();
|
||||||
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty() )
|
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty() )
|
||||||
{
|
{
|
||||||
partition = KPMHelpers::createNewEncryptedPartition(
|
partition = KPMHelpers::createNewEncryptedPartition(
|
||||||
m_parent, *m_device, m_role, fsType, first, last, luksPassphrase, newFlags() );
|
m_parent, *m_device, m_role, fsType, fsLabel, first, last, luksPassphrase, newFlags() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
partition = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, first, last, newFlags() );
|
partition = KPMHelpers::createNewPartition( m_parent, *m_device, m_role, fsType, fsLabel, first, last, newFlags() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_device->type() == Device::Type::LVM_Device )
|
if ( m_device->type() == Device::Type::LVM_Device )
|
||||||
|
@ -130,10 +130,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="fsComboBox"/>
|
<widget class="QComboBox" name="fsComboBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="EncryptWidget" name="encryptWidget" native="true"/>
|
<widget class="EncryptWidget" name="encryptWidget" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="6" column="1">
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -149,17 +149,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="lvNameLabel">
|
<widget class="QLabel" name="lvNameLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>LVM LV name</string>
|
<string>LVM LV name</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QLineEdit" name="lvNameLineEdit"/>
|
<widget class="QLineEdit" name="lvNameLineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="8" column="0">
|
||||||
<widget class="QLabel" name="mountPointLabel">
|
<widget class="QLabel" name="mountPointLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Mount Point:</string>
|
<string>&Mount Point:</string>
|
||||||
@ -169,7 +169,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QComboBox" name="mountPointComboBox">
|
<widget class="QComboBox" name="mountPointComboBox">
|
||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -179,21 +179,21 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="QLabel" name="labelMountPoint">
|
<widget class="QLabel" name="labelMountPoint">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
<item row="11" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Flags:</string>
|
<string>Flags:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="1">
|
<item row="11" column="1">
|
||||||
<widget class="QListWidget" name="m_listFlags">
|
<widget class="QListWidget" name="m_listFlags">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -206,7 +206,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="0">
|
<item row="12" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -219,6 +219,29 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="9" column="1">
|
||||||
|
<widget class="QLineEdit" name="filesystemLabelEdit">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Label for the filesystem</string>
|
||||||
|
</property>
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="9" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>FS Label:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -70,6 +70,9 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
|
|||||||
m_ui->fileSystemLabel->setEnabled( doFormat );
|
m_ui->fileSystemLabel->setEnabled( doFormat );
|
||||||
m_ui->fileSystemComboBox->setEnabled( doFormat );
|
m_ui->fileSystemComboBox->setEnabled( doFormat );
|
||||||
|
|
||||||
|
m_ui->fileSystemLabelEdit->setEnabled( doFormat );
|
||||||
|
m_ui->fileSystemLabelEdit->setText( m_partition->fileSystem().label() );
|
||||||
|
|
||||||
if ( !doFormat )
|
if ( !doFormat )
|
||||||
{
|
{
|
||||||
m_ui->fileSystemComboBox->setCurrentText( userVisibleFS( m_partition->fileSystem() ) );
|
m_ui->fileSystemComboBox->setCurrentText( userVisibleFS( m_partition->fileSystem() ) );
|
||||||
@ -146,6 +149,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
|||||||
? FileSystem::Extended
|
? FileSystem::Extended
|
||||||
: FileSystem::typeForName( m_ui->fileSystemComboBox->currentText() );
|
: FileSystem::typeForName( m_ui->fileSystemComboBox->currentText() );
|
||||||
}
|
}
|
||||||
|
const QString fsLabel = m_ui->fileSystemLabelEdit->text();
|
||||||
|
|
||||||
const auto resultFlags = newFlags();
|
const auto resultFlags = newFlags();
|
||||||
const auto currentFlags = PartitionInfo::flags( m_partition );
|
const auto currentFlags = PartitionInfo::flags( m_partition );
|
||||||
@ -158,6 +162,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
|||||||
*m_device,
|
*m_device,
|
||||||
m_partition->roles(),
|
m_partition->roles(),
|
||||||
fsType,
|
fsType,
|
||||||
|
fsLabel,
|
||||||
newFirstSector,
|
newFirstSector,
|
||||||
newLastSector,
|
newLastSector,
|
||||||
resultFlags );
|
resultFlags );
|
||||||
@ -197,6 +202,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
|||||||
*m_device,
|
*m_device,
|
||||||
m_partition->roles(),
|
m_partition->roles(),
|
||||||
fsType,
|
fsType,
|
||||||
|
fsLabel,
|
||||||
m_partition->firstSector(),
|
m_partition->firstSector(),
|
||||||
m_partition->lastSector(),
|
m_partition->lastSector(),
|
||||||
resultFlags );
|
resultFlags );
|
||||||
|
@ -11,7 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>450</width>
|
<width>450</width>
|
||||||
<height>579</height>
|
<height>615</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -147,14 +147,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QComboBox" name="fileSystemComboBox"/>
|
<widget class="QComboBox" name="fileSystemComboBox"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0">
|
<item row="9" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Flags:</string>
|
<string>Flags:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="1">
|
<item row="9" column="1">
|
||||||
<widget class="QListWidget" name="m_listFlags">
|
<widget class="QListWidget" name="m_listFlags">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -167,13 +167,36 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="8" column="1">
|
||||||
<widget class="QLabel" name="labelMountPoint">
|
<widget class="QLabel" name="labelMountPoint">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="1">
|
||||||
|
<widget class="QLineEdit" name="fileSystemLabelEdit">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Label for the filesystem</string>
|
||||||
|
</property>
|
||||||
|
<property name="maxLength">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QLabel" name="fileSystemLabelLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>FS Label:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user