Rely on the partition role instead of the filesystem type.

This commit is contained in:
Teo Mrnjavac 2016-04-19 17:08:01 +02:00
parent 29d3a92805
commit cf4d687d54
1 changed files with 15 additions and 9 deletions

View File

@ -65,6 +65,8 @@
#include <config.h> #include <config.h>
#include <typeinfo>
class PartitionTreeWidgetItem : public QTreeWidgetItem class PartitionTreeWidgetItem : public QTreeWidgetItem
{ {
Q_DISABLE_COPY(PartitionTreeWidgetItem) Q_DISABLE_COPY(PartitionTreeWidgetItem)
@ -420,19 +422,23 @@ void PartitionManagerWidget::onDecryptPartition()
return; return;
} }
if (p->fileSystem().type() != FileSystem::Luks) if (!p->roles().has(PartitionRole::Luks))
return; return;
FS::luks& luksFs = dynamic_cast<FS::luks&>(p->fileSystem()); try {
FS::luks& luksFs = dynamic_cast<FS::luks&>(p->fileSystem());
if (luksFs.canCryptOpen(p->partitionPath())) { if (luksFs.canCryptOpen(p->partitionPath())) {
if (!luksFs.cryptOpen(p->partitionPath())) if (!luksFs.cryptOpen(p->partitionPath()))
KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition <filename>%1</filename> could not be unlocked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Unlock Encrypted File System.")); KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition <filename>%1</filename> could not be unlocked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Unlock Encrypted File System."));
} else if (luksFs.canCryptClose(p->partitionPath())) { } else if (luksFs.canCryptClose(p->partitionPath())) {
if (!luksFs.cryptClose(p->partitionPath())) if (!luksFs.cryptClose(p->partitionPath()))
KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition <filename>%1</filename> could not be locked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Lock Encrypted File System.")); KMessageBox::detailedSorry(this, xi18nc("@info", "The encrypted file system on partition <filename>%1</filename> could not be locked.", p->deviceNode()), QString(), i18nc("@title:window", "Could Not Lock Encrypted File System."));
}
} catch (const std::bad_cast&)
{
return;
} }
updatePartitions(); updatePartitions();
} }