Merge pull request #4133 from owncloud/sharedialog_uit_improvements

[Sharedialog] Fix UI stuff
This commit is contained in:
Roeland Douma 2015-11-16 13:36:00 +01:00
commit 786b602c26
4 changed files with 159 additions and 66 deletions

View file

@ -34,6 +34,7 @@
#include <QFileInfo>
#include <QAbstractProxyModel>
#include <QCompleter>
#include <QPropertyAnimation>
namespace OCC {
@ -63,6 +64,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 +139,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 +163,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 +194,44 @@ 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);
@ -227,13 +257,27 @@ void ShareWidget::slotPermissionsChanged()
_share->setPermissions(permissions);
}
void ShareWidget::slotShareDeleted()
void ShareWidget::slotDeleteAnimationFinished()
{
deleteLater();
}
void ShareWidget::slotShareDeleted()
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "maximumHeight", this);
animation->setDuration(500);
animation->setStartValue(height());
animation->setEndValue(0);
connect(animation, SIGNAL(finished()), SLOT(slotDeleteAnimationFinished()));
animation->start();
}
void ShareWidget::slotPermissionsSet()
{
displayPermissions();
setEnabled(true);
}
@ -242,4 +286,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);
}
}
}

View file

@ -57,13 +57,19 @@ signals:
private slots:
void on_deleteShareButton_clicked();
void slotPermissionsChanged();
void slotEditPermissionsChanged();
void on_permissionToggleButton_clicked();
void slotDeleteAnimationFinished();
void slotShareDeleted();
void slotPermissionsSet();
private:
void displayPermissions();
Ui::ShareWidget *_ui;
QSharedPointer<Share> _share;
bool _showDetailedPermissions;
};

View file

@ -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>

View file

@ -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/>