mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
ShareUserGroupWidget: fix scroll area size management
This commit is contained in:
parent
a8cce41f35
commit
b25e15347b
@ -188,8 +188,8 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
|
||||
auto newViewPort = new QWidget(scrollArea);
|
||||
auto layout = new QVBoxLayout(newViewPort);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
QSize minimumSize = newViewPort->sizeHint();
|
||||
int x = 0;
|
||||
int height = 0;
|
||||
|
||||
foreach (const auto &share, shares) {
|
||||
// We don't handle link shares, only TypeUser or TypeGroup
|
||||
@ -205,22 +205,12 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
|
||||
|
||||
x++;
|
||||
if (x <= 3) {
|
||||
minimumSize = newViewPort->sizeHint();
|
||||
} else {
|
||||
minimumSize.rwidth() = qMax(newViewPort->sizeHint().width(), minimumSize.width());
|
||||
height = newViewPort->sizeHint().height();
|
||||
}
|
||||
}
|
||||
|
||||
if (!layout->isEmpty()) {
|
||||
_parentScrollArea->setVisible(true);
|
||||
layout->addStretch(1);
|
||||
} else {
|
||||
_parentScrollArea->setVisible(false);
|
||||
}
|
||||
|
||||
minimumSize.rwidth() += layout->spacing();
|
||||
minimumSize.rheight() += layout->spacing();
|
||||
scrollArea->setMinimumSize(minimumSize);
|
||||
scrollArea->setVisible(!shares.isEmpty());
|
||||
scrollArea->setFixedHeight(height);
|
||||
scrollArea->setWidget(newViewPort);
|
||||
|
||||
_disableCompleterActivated = false;
|
||||
@ -230,13 +220,10 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
|
||||
void ShareUserGroupWidget::slotAdjustScrollWidgetSize()
|
||||
{
|
||||
QScrollArea *scrollArea = _parentScrollArea;
|
||||
if (scrollArea->findChildren<ShareUserLine *>().count() <= 3 &&
|
||||
scrollArea->findChildren<ShareUserLine *>().count() > 0) {
|
||||
auto minimumSize = scrollArea->widget()->sizeHint();
|
||||
auto spacing = scrollArea->widget()->layout()->spacing();
|
||||
minimumSize.rwidth() += spacing;
|
||||
minimumSize.rheight() += spacing;
|
||||
scrollArea->setMinimumSize(minimumSize);
|
||||
int count = scrollArea->findChildren<ShareUserLine *>().count();
|
||||
scrollArea->setVisible(count > 0);
|
||||
if (count > 0 && count <= 3) {
|
||||
scrollArea->setFixedHeight(scrollArea->widget()->sizeHint().height());
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,16 +257,9 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex &index)
|
||||
// model proxying the _completerModel
|
||||
auto sharee = qvariant_cast<QSharedPointer<Sharee>>(index.data(Qt::UserRole));
|
||||
if (sharee.isNull()) {
|
||||
_parentScrollArea->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add spinner to the bottom of the widget list
|
||||
*/
|
||||
auto viewPort = _parentScrollArea->widget();
|
||||
auto layout = qobject_cast<QVBoxLayout *>(viewPort->layout());
|
||||
|
||||
// TODO Progress Indicator where should it go?
|
||||
// auto indicator = new QProgressIndicator(viewPort);
|
||||
// indicator->startAnimation();
|
||||
@ -313,11 +293,6 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex &index)
|
||||
|
||||
_ui->shareeLineEdit->setEnabled(false);
|
||||
_ui->shareeLineEdit->setText(QString());
|
||||
|
||||
if(layout->isEmpty())
|
||||
_parentScrollArea->setVisible(false);
|
||||
else
|
||||
_parentScrollArea->setVisible(true);
|
||||
}
|
||||
|
||||
void ShareUserGroupWidget::slotCompleterHighlighted(const QModelIndex &index)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user