From d6aa6679713c96299be86b35d0766261d5487e95 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 19 Nov 2015 12:32:50 +0100 Subject: [PATCH] ShareDialog: remove the "Premissions" label and adjust the size of the scrollarea (#3737) --- src/gui/shareusergroupwidget.cpp | 19 +++++++++++++++++++ src/gui/shareusergroupwidget.h | 2 ++ src/gui/sharewidget.ui | 6 +++--- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp index ffc5bfbf172..a7eaafbdd91 100644 --- a/src/gui/shareusergroupwidget.cpp +++ b/src/gui/shareusergroupwidget.cpp @@ -141,11 +141,14 @@ void ShareUserGroupWidget::slotSharesFetched(const QList> } ShareWidget *s = new ShareWidget(share, _ui->scrollArea); + connect(s, SIGNAL(resizeRequested()), this, SLOT(slotAdjustScrollWidgetSize())); layout->addWidget(s); x++; if (x <= 3) { minimumSize = newViewPort->sizeHint(); + } else { + minimumSize.rwidth() = qMax(newViewPort->sizeHint().width(), minimumSize.width()); } } @@ -156,6 +159,19 @@ void ShareUserGroupWidget::slotSharesFetched(const QList> scrollArea->setWidget(newViewPort); } +void ShareUserGroupWidget::slotAdjustScrollWidgetSize() +{ + QScrollArea *scrollArea = _ui->scrollArea; + if (scrollArea->findChildren().count() <= 3) { + auto minimumSize = scrollArea->widget()->sizeHint(); + auto spacing = scrollArea->widget()->layout()->spacing(); + minimumSize.rwidth() += spacing; + minimumSize.rheight() += spacing; + scrollArea->setMinimumSize(minimumSize); + } +} + + void ShareUserGroupWidget::slotShareesReady() { _completer->complete(); @@ -226,6 +242,7 @@ void ShareWidget::on_permissionToggleButton_clicked() } else { _ui->permissionToggleButton->setText("More"); } + emit resizeRequested(); } ShareWidget::~ShareWidget() @@ -279,6 +296,7 @@ void ShareWidget::slotPermissionsChanged() void ShareWidget::slotDeleteAnimationFinished() { + resizeRequested(); deleteLater(); } @@ -291,6 +309,7 @@ void ShareWidget::slotShareDeleted() animation->setEndValue(0); connect(animation, SIGNAL(finished()), SLOT(slotDeleteAnimationFinished())); + connect(animation, SIGNAL(valueChanged(QVariant)), this, SIGNAL(resizeRequested())); animation->start(); } diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h index 13b3ef8232e..9591f882fc2 100644 --- a/src/gui/shareusergroupwidget.h +++ b/src/gui/shareusergroupwidget.h @@ -54,6 +54,7 @@ class ShareWidget : public QWidget signals: void shareDeleted(ShareWidget *share); + void resizeRequested(); private slots: void on_deleteShareButton_clicked(); @@ -102,6 +103,7 @@ private slots: void slotCompleterActivated(const QModelIndex & index); void slotShareesReady(); + void slotAdjustScrollWidgetSize(); private: Ui::ShareUserGroupWidget *_ui; diff --git a/src/gui/sharewidget.ui b/src/gui/sharewidget.ui index 66d53d48df6..83a5841d060 100644 --- a/src/gui/sharewidget.ui +++ b/src/gui/sharewidget.ui @@ -9,8 +9,8 @@ 0 0 - 474 - 108 + 468 + 92 @@ -54,7 +54,7 @@ - Permissions +