From d423cf2c7f5d8b6a584db7b1464a9ac8b1f55043 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 13 Nov 2015 10:27:26 +0100 Subject: [PATCH] [Sharedialog] Fix UI stuff Implemented suggestions form https://github.com/owncloud/client/issues/3737#issuecomment-156036279 * Removed Shares text * Permissions now next to username * Simplified permissions by default * Button to get more detailed permissions --- src/gui/shareusergroupwidget.cpp | 86 +++++++++++++++++++----- src/gui/shareusergroupwidget.h | 5 ++ src/gui/shareusergroupwidget.ui | 10 --- src/gui/sharewidget.ui | 108 +++++++++++++++++++------------ 4 files changed, 144 insertions(+), 65 deletions(-) diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp index 6fe79db85..4233a4f3a 100644 --- a/src/gui/shareusergroupwidget.cpp +++ b/src/gui/shareusergroupwidget.cpp @@ -63,6 +63,7 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh connect(_manager, SIGNAL(shareCreated(QSharedPointer)), SLOT(getShares())); // connect(_ui->shareeLineEdit, SIGNAL(returnPressed()), SLOT(on_searchPushButton_clicked())); connect(_completer, SIGNAL(activated(QModelIndex)), SLOT(slotCompleterActivated(QModelIndex))); + } ShareUserGroupWidget::~ShareUserGroupWidget() @@ -137,8 +138,6 @@ void ShareUserGroupWidget::slotSharesFetched(const QList> ShareWidget *s = new ShareWidget(share, this); _ui->sharesLayout->addWidget(s); } - - _ui->labelShares->setVisible(!shares.empty()); } void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex & index) @@ -163,29 +162,26 @@ ShareWidget::ShareWidget(QSharedPointer share, QWidget *parent) : QWidget(parent), _ui(new Ui::ShareWidget), - _share(share) + _share(share), + _showDetailedPermissions(false) { _ui->setupUi(this); _ui->sharedWith->setText(share->getShareWith()->format()); - if (share->getPermissions() & Share::PermissionUpdate) { - _ui->permissionUpdate->setCheckState(Qt::Checked); - } - if (share->getPermissions() & Share::PermissionCreate) { - _ui->permissionCreate->setCheckState(Qt::Checked); - } - if (share->getPermissions() & Share::PermissionDelete) { - _ui->permissionDelete->setCheckState(Qt::Checked); - } - if (share->getPermissions() & Share::PermissionShare) { - _ui->permissionShare->setCheckState(Qt::Checked); - } + // Set the permissions checkboxes + displayPermissions(); + + // Hide "detailed permissions" by default + _ui->permissionDelete->setHidden(true); + _ui->permissionUpdate->setHidden(true); + _ui->permissionCreate->setHidden(true); connect(_ui->permissionUpdate, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionCreate, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionDelete, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); connect(_ui->permissionShare, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged())); + connect(_ui->permissionsEdit, SIGNAL(clicked(bool)), SLOT(slotEditPermissionsChanged())); connect(share.data(), SIGNAL(permissionsSet()), SLOT(slotPermissionsSet())); connect(share.data(), SIGNAL(shareDeleted()), SLOT(slotShareDeleted())); @@ -197,11 +193,45 @@ void ShareWidget::on_deleteShareButton_clicked() _share->deleteShare(); } +void ShareWidget::on_permissionToggleButton_clicked() +{ + _showDetailedPermissions = !_showDetailedPermissions; + _ui->permissionDelete->setVisible(_showDetailedPermissions); + _ui->permissionUpdate->setVisible(_showDetailedPermissions); + _ui->permissionCreate->setVisible(_showDetailedPermissions); + + if (_showDetailedPermissions) { + _ui->permissionToggleButton->setText("Hide"); + } else { + _ui->permissionToggleButton->setText("More"); + } + +} + ShareWidget::~ShareWidget() { delete _ui; } +void ShareWidget::slotEditPermissionsChanged() +{ + setEnabled(false); + + Share::Permissions permissions = Share::PermissionRead; + + if (_ui->permissionShare->checkState() == Qt::Checked) { + permissions |= Share::PermissionUpdate; + } + + if (_ui->permissionsEdit->checkState() == Qt::Checked) { + permissions |= Share::PermissionCreate; + permissions |= Share::PermissionUpdate; + permissions |= Share::PermissionDelete; + } + + _share->setPermissions(permissions); +} + void ShareWidget::slotPermissionsChanged() { setEnabled(false); @@ -234,6 +264,7 @@ void ShareWidget::slotShareDeleted() void ShareWidget::slotPermissionsSet() { + displayPermissions(); setEnabled(true); } @@ -242,4 +273,29 @@ QSharedPointer ShareWidget::share() const return _share; } +void ShareWidget::displayPermissions() +{ + _ui->permissionCreate->setCheckState(Qt::Unchecked); + _ui->permissionsEdit->setCheckState(Qt::Unchecked); + _ui->permissionDelete->setCheckState(Qt::Unchecked); + _ui->permissionShare->setCheckState(Qt::Unchecked); + _ui->permissionUpdate->setCheckState(Qt::Unchecked); + + if (_share->getPermissions() & Share::PermissionUpdate) { + _ui->permissionUpdate->setCheckState(Qt::Checked); + _ui->permissionsEdit->setCheckState(Qt::Checked); + } + if (_share->getPermissions() & Share::PermissionCreate) { + _ui->permissionCreate->setCheckState(Qt::Checked); + _ui->permissionsEdit->setCheckState(Qt::Checked); + } + if (_share->getPermissions() & Share::PermissionDelete) { + _ui->permissionDelete->setCheckState(Qt::Checked); + _ui->permissionsEdit->setCheckState(Qt::Checked); + } + if (_share->getPermissions() & Share::PermissionShare) { + _ui->permissionShare->setCheckState(Qt::Checked); + } +} + } diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h index dec6b6349..58247c3e8 100644 --- a/src/gui/shareusergroupwidget.h +++ b/src/gui/shareusergroupwidget.h @@ -57,13 +57,18 @@ signals: private slots: void on_deleteShareButton_clicked(); void slotPermissionsChanged(); + void slotEditPermissionsChanged(); + void on_permissionToggleButton_clicked(); void slotShareDeleted(); void slotPermissionsSet(); private: + void displayPermissions(); + Ui::ShareWidget *_ui; QSharedPointer _share; + bool _showDetailedPermissions; }; diff --git a/src/gui/shareusergroupwidget.ui b/src/gui/shareusergroupwidget.ui index a6b3a352c..b872fb5b0 100644 --- a/src/gui/shareusergroupwidget.ui +++ b/src/gui/shareusergroupwidget.ui @@ -38,16 +38,6 @@ - - - - true - - - Shares - - - diff --git a/src/gui/sharewidget.ui b/src/gui/sharewidget.ui index 84c3d91f7..66d53d48d 100644 --- a/src/gui/sharewidget.ui +++ b/src/gui/sharewidget.ui @@ -9,8 +9,8 @@ 0 0 - 376 - 128 + 474 + 108 @@ -38,55 +38,83 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Permissions + + + + + + Can Share + + + + + + + Can Edit + + + + + + + Create + + + + + + + Change + + + + + + + Delete + + + + + + + More + + + + + + - + + .. - - - - Permissions - - - - - - Delete - - - - - - - Create - - - - - - - Update - - - - - - - Share - - - - - -