Forráskód Böngészése

ShareDialog: Make "can edit" partially checked sometimes #5642

Previously the check box was checked if *any* of its sub-permissions
were granted. This can hide the fact that only a limited subset of them
are actually granted.

The new behavior is to display as "partially checked" if only some
of the sub-permissions are available. Clicking the check box itself
still toggles between granting all or none of them.
Christian Kamm 9 éve
szülő
commit
a0e88477c1
1 módosított fájl, 26 hozzáadás és 10 törlés
  1. 26 10
      src/gui/shareusergroupwidget.cpp

+ 26 - 10
src/gui/shareusergroupwidget.cpp

@@ -374,12 +374,19 @@ void ShareWidget::slotEditPermissionsChanged()
 {
     setEnabled(false);
 
+    // Can never manually be set to "partial".
+    // This works because the state cycle for clicking is
+    // unchecked -> partial -> checked -> unchecked.
+    if (_ui->permissionsEdit->checkState() == Qt::PartiallyChecked) {
+        _ui->permissionsEdit->setCheckState(Qt::Checked);
+    }
+
     Share::Permissions permissions = SharePermissionRead;
 
     if (_ui->permissionShare->checkState() == Qt::Checked) {
         permissions |= SharePermissionShare;
     }
-    
+
     if (_ui->permissionsEdit->checkState() == Qt::Checked) {
         if (_permissionUpdate->isEnabled())
             permissions |= SharePermissionUpdate;
@@ -461,24 +468,33 @@ QSharedPointer<Share> ShareWidget::share() const
 
 void ShareWidget::displayPermissions()
 {
+    auto perm = _share->getPermissions();
+
+    _permissionUpdate->setChecked(false);
     _permissionCreate->setChecked(false);
-    _ui->permissionsEdit->setCheckState(Qt::Unchecked);
     _permissionDelete->setChecked(false);
-    _ui->permissionShare->setCheckState(Qt::Unchecked);
-    _permissionUpdate->setChecked(false);
-
-    if (_share->getPermissions() & SharePermissionUpdate) {
+    if (perm & SharePermissionUpdate) {
         _permissionUpdate->setChecked(true);
-        _ui->permissionsEdit->setCheckState(Qt::Checked);
     }
-    if (!_isFile && _share->getPermissions() & SharePermissionCreate) {
+    if (!_isFile && perm & SharePermissionCreate) {
         _permissionCreate->setChecked(true);
-        _ui->permissionsEdit->setCheckState(Qt::Checked);
     }
-    if (!_isFile && _share->getPermissions() & SharePermissionDelete) {
+    if (!_isFile && perm & SharePermissionDelete) {
         _permissionDelete->setChecked(true);
+    }
+
+    if (perm & SharePermissionUpdate
+            && (_isFile
+                || (perm & SharePermissionCreate
+                    && perm & SharePermissionDelete))) {
         _ui->permissionsEdit->setCheckState(Qt::Checked);
+    } else if (perm & (SharePermissionUpdate | SharePermissionCreate | SharePermissionDelete)) {
+        _ui->permissionsEdit->setCheckState(Qt::PartiallyChecked);
+    } else {
+        _ui->permissionsEdit->setCheckState(Qt::Unchecked);
     }
+
+    _ui->permissionShare->setCheckState(Qt::Unchecked);
     if (_share->getPermissions() & SharePermissionShare) {
         _ui->permissionShare->setCheckState(Qt::Checked);
     }