diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index 0a3441b..4737457 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,12 @@ NewDialog::NewDialog(QWidget* parent, Device& device, Partition& unallocatedPart KConfigGroup kcg(KSharedConfig::openConfig(), "newDialog"); restoreGeometry(kcg.readEntry("Geometry", QByteArray())); + + // Hack on top of hack. The dialog is created via two inheritances. + auto *allowEveryone = new QCheckBox(i18n("Allow everyone to use this partition")); + QBoxLayout *l = qobject_cast(layout()); + int lCount = l->count(); + l->insertWidget(lCount-1, allowEveryone); } NewDialog::~NewDialog() @@ -284,3 +291,8 @@ void NewDialog::updateOkButtonStatus() { okButton->setEnabled(isValidPassword() && isValidLVName()); } + +bool NewDialog::useUnsecuredPartition() const +{ + return m_unsecuredPartition->checkState() == Qt::CheckState::Checked; +} diff --git a/src/gui/newdialog.h b/src/gui/newdialog.h index 2c2298d..cd7f670 100644 --- a/src/gui/newdialog.h +++ b/src/gui/newdialog.h @@ -17,6 +17,7 @@ #include class Device; +class QCheckBox; /** Dialog to create new Partitions. @@ -30,6 +31,9 @@ public: NewDialog(QWidget* parent, Device& device, Partition& unallocatedPartition, PartitionRole::Roles r); ~NewDialog(); + // returns true if any user can write on the partition. + // has the same effect as running `chmod 777` on it. + bool useUnsecuredPartition() const; protected: void accept() override; void onRoleChanged(bool); @@ -60,6 +64,7 @@ protected: private: PartitionRole::Roles m_PartitionRoles; bool m_IsValidPassword; + QCheckBox *m_unsecuredPartition; }; #endif diff --git a/src/gui/partitionmanagerwidget.cpp b/src/gui/partitionmanagerwidget.cpp index a2a8ae0..121b04f 100644 --- a/src/gui/partitionmanagerwidget.cpp +++ b/src/gui/partitionmanagerwidget.cpp @@ -504,10 +504,14 @@ void PartitionManagerWidget::onNewPartition() Partition* newPartition = NewOperation::createNew(*selectedPartition(), static_cast(Config::defaultFileSystem())); QPointer dlg = new NewDialog(this, *selectedDevice(), *newPartition, selectedDevice()->partitionTable()->childRoles(*selectedPartition())); - if (dlg->exec() == QDialog::Accepted) + if (dlg->exec() == QDialog::Accepted) { operationStack().push(new NewOperation(*selectedDevice(), newPartition)); - else + if (dlg->useUnsecuredPartition()) { + // operationStac().push(new ChangePermissionOperation("777", *selectedDevice(), newPartition); + } + } else { delete newPartition; + } delete dlg; }