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 PartitionRole& role,
|
||||
FileSystem::Type fsType,
|
||||
const QString& fsLabel,
|
||||
qint64 firstSector,
|
||||
qint64 lastSector,
|
||||
PartitionTable::Flags flags )
|
||||
{
|
||||
FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() );
|
||||
fs->setLabel( fsLabel );
|
||||
return new Partition( parent,
|
||||
device,
|
||||
role,
|
||||
@ -71,6 +73,7 @@ createNewEncryptedPartition( PartitionNode* parent,
|
||||
const Device& device,
|
||||
const PartitionRole& role,
|
||||
FileSystem::Type fsType,
|
||||
const QString& fsLabel,
|
||||
qint64 firstSector,
|
||||
qint64 lastSector,
|
||||
const QString& passphrase,
|
||||
@ -92,6 +95,7 @@ createNewEncryptedPartition( PartitionNode* parent,
|
||||
|
||||
fs->createInnerFileSystem( fsType );
|
||||
fs->setPassphrase( passphrase );
|
||||
fs->setLabel( fsLabel );
|
||||
Partition* p = new Partition( parent,
|
||||
device,
|
||||
PartitionRole( newRoles ),
|
||||
|
@ -55,6 +55,7 @@ Partition* createNewPartition( PartitionNode* parent,
|
||||
const Device& device,
|
||||
const PartitionRole& role,
|
||||
FileSystem::Type fsType,
|
||||
const QString& fsLabel,
|
||||
qint64 firstSector,
|
||||
qint64 lastSector,
|
||||
PartitionTable::Flags flags );
|
||||
@ -63,6 +64,7 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
|
||||
const Device& device,
|
||||
const PartitionRole& role,
|
||||
FileSystem::Type fsType,
|
||||
const QString& fsLabel,
|
||||
qint64 firstSector,
|
||||
qint64 lastSector,
|
||||
const QString& passphrase,
|
||||
|
@ -132,6 +132,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
||||
*dev,
|
||||
PartitionRole( PartitionRole::Primary ),
|
||||
FileSystem::Fat32,
|
||||
QString(),
|
||||
firstFreeSector,
|
||||
lastSector,
|
||||
KPM_PARTITION_FLAG( None ) );
|
||||
@ -180,6 +181,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
||||
*dev,
|
||||
PartitionRole( PartitionRole::Primary ),
|
||||
FileSystem::LinuxSwap,
|
||||
QStringLiteral( "swap" ),
|
||||
lastSectorForRoot + 1,
|
||||
dev->totalLogical() - 1,
|
||||
KPM_PARTITION_FLAG( None ) );
|
||||
@ -190,6 +192,7 @@ doAutopartition( PartitionCoreModule* core, Device* dev, Choices::AutoPartitionO
|
||||
*dev,
|
||||
PartitionRole( PartitionRole::Primary ),
|
||||
FileSystem::LinuxSwap,
|
||||
QStringLiteral( "swap" ),
|
||||
lastSectorForRoot + 1,
|
||||
dev->totalLogical() - 1,
|
||||
o.luksPassphrase,
|
||||
|
@ -911,6 +911,14 @@ PartitionCoreModule::layoutApply( Device* dev,
|
||||
= std::find_if( partList.constBegin(), partList.constEnd(), is_boot ) != partList.constEnd();
|
||||
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 ) ) )
|
||||
{
|
||||
createPartition(
|
||||
|
@ -202,17 +202,18 @@ CreatePartitionDialog::createPartition()
|
||||
FileSystem::Type fsType = m_role.has( PartitionRole::Extended )
|
||||
? FileSystem::Extended
|
||||
: FileSystem::typeForName( m_ui->fsComboBox->currentText() );
|
||||
const QString fsLabel = m_ui->filesystemLabelEdit->text();
|
||||
|
||||
Partition* partition = nullptr;
|
||||
QString luksPassphrase = m_ui->encryptWidget->passphrase();
|
||||
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed && !luksPassphrase.isEmpty() )
|
||||
{
|
||||
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
|
||||
{
|
||||
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 )
|
||||
|
@ -130,10 +130,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="fsComboBox"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="EncryptWidget" name="encryptWidget" native="true"/>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -149,17 +149,17 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lvNameLabel">
|
||||
<property name="text">
|
||||
<string>LVM LV name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="lvNameLineEdit"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="mountPointLabel">
|
||||
<property name="text">
|
||||
<string>&Mount Point:</string>
|
||||
@ -169,7 +169,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QComboBox" name="mountPointComboBox">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
@ -179,21 +179,21 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QLabel" name="labelMountPoint">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Flags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QListWidget" name="m_listFlags">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
@ -206,7 +206,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="12" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -219,6 +219,29 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -70,6 +70,9 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
|
||||
m_ui->fileSystemLabel->setEnabled( doFormat );
|
||||
m_ui->fileSystemComboBox->setEnabled( doFormat );
|
||||
|
||||
m_ui->fileSystemLabelEdit->setEnabled( doFormat );
|
||||
m_ui->fileSystemLabelEdit->setText( m_partition->fileSystem().label() );
|
||||
|
||||
if ( !doFormat )
|
||||
{
|
||||
m_ui->fileSystemComboBox->setCurrentText( userVisibleFS( m_partition->fileSystem() ) );
|
||||
@ -146,6 +149,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
? FileSystem::Extended
|
||||
: FileSystem::typeForName( m_ui->fileSystemComboBox->currentText() );
|
||||
}
|
||||
const QString fsLabel = m_ui->fileSystemLabelEdit->text();
|
||||
|
||||
const auto resultFlags = newFlags();
|
||||
const auto currentFlags = PartitionInfo::flags( m_partition );
|
||||
@ -158,6 +162,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
*m_device,
|
||||
m_partition->roles(),
|
||||
fsType,
|
||||
fsLabel,
|
||||
newFirstSector,
|
||||
newLastSector,
|
||||
resultFlags );
|
||||
@ -197,6 +202,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
|
||||
*m_device,
|
||||
m_partition->roles(),
|
||||
fsType,
|
||||
fsLabel,
|
||||
m_partition->firstSector(),
|
||||
m_partition->lastSector(),
|
||||
resultFlags );
|
||||
|
@ -11,7 +11,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>579</height>
|
||||
<height>615</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -147,14 +147,14 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="fileSystemComboBox"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Flags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QListWidget" name="m_listFlags">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
@ -167,13 +167,36 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="labelMountPoint">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
Reference in New Issue
Block a user