Skip to content

Commit

Permalink
ShareDialog: remove the "Premissions" label and adjust the size of th…
Browse files Browse the repository at this point in the history
…e scrollarea (#3737)
  • Loading branch information
ogoffart committed Nov 19, 2015
1 parent 575fc9a commit d6aa667
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
19 changes: 19 additions & 0 deletions src/gui/shareusergroupwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,14 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
}

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());
}
}

Expand All @@ -156,6 +159,19 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
scrollArea->setWidget(newViewPort);
}

void ShareUserGroupWidget::slotAdjustScrollWidgetSize()
{
QScrollArea *scrollArea = _ui->scrollArea;
if (scrollArea->findChildren<ShareWidget*>().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();
Expand Down Expand Up @@ -226,6 +242,7 @@ void ShareWidget::on_permissionToggleButton_clicked()
} else {
_ui->permissionToggleButton->setText("More");
}
emit resizeRequested();
}

ShareWidget::~ShareWidget()
Expand Down Expand Up @@ -279,6 +296,7 @@ void ShareWidget::slotPermissionsChanged()

void ShareWidget::slotDeleteAnimationFinished()
{
resizeRequested();
deleteLater();
}

Expand All @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/shareusergroupwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ShareWidget : public QWidget

signals:
void shareDeleted(ShareWidget *share);
void resizeRequested();

private slots:
void on_deleteShareButton_clicked();
Expand Down Expand Up @@ -102,6 +103,7 @@ private slots:

void slotCompleterActivated(const QModelIndex & index);
void slotShareesReady();
void slotAdjustScrollWidgetSize();

private:
Ui::ShareUserGroupWidget *_ui;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/sharewidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>108</height>
<width>468</width>
<height>92</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -54,7 +54,7 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Permissions</string>
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
Expand Down

0 comments on commit d6aa667

Please sign in to comment.