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
This commit is contained in:
Roeland Jago Douma 2015-11-13 10:27:26 +01:00
Родитель 3d847b50cf
Коммит d423cf2c7f
4 изменённых файлов: 144 добавлений и 65 удалений

Просмотреть файл

@ -63,6 +63,7 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
connect(_manager, SIGNAL(shareCreated(QSharedPointer<Share>)), 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<QSharedPointer<Share>>
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> 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<Share> 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);
}
}
}

Просмотреть файл

@ -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> _share;
bool _showDetailedPermissions;
};

Просмотреть файл

@ -38,16 +38,6 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelShares">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Shares</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="sharesLayout"/>
</item>

Просмотреть файл

@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>128</height>
<width>474</width>
<height>108</height>
</rect>
</property>
<property name="windowTitle">
@ -38,55 +38,83 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Permissions</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="permissionShare">
<property name="text">
<string>Can Share</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="permissionsEdit">
<property name="text">
<string>Can Edit</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="permissionCreate">
<property name="text">
<string>Create</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="permissionUpdate">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="permissionDelete">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="permissionToggleButton">
<property name="text">
<string>More</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QToolButton" name="deleteShareButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="user-trash"/>
<iconset theme="user-trash">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Permissions</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="permissionDelete">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="permissionCreate">
<property name="text">
<string>Create</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="permissionUpdate">
<property name="text">
<string>Update</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="permissionShare">
<property name="text">
<string>Share</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>