-/*
+/*
* Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
*
* This program is free software; you can redistribute it and/or modify
initShareManager();
- _scrollAreaLinksViewPort = new QWidget(_ui->scrollAreaLinks);
- _scrollAreaLinksLayout = new QVBoxLayout(_scrollAreaLinksViewPort);
- _scrollAreaLinksLayout->setContentsMargins(6, 6, 6, 6);
- _ui->scrollAreaLinks->setWidget(_scrollAreaLinksViewPort);
+ _scrollAreaViewPort = new QWidget(_ui->scrollArea);
+ _scrollAreaLayout = new QVBoxLayout(_scrollAreaViewPort);
+ _scrollAreaLayout->setContentsMargins(0, 0, 0, 0);
+ _ui->scrollArea->setWidget(_scrollAreaViewPort);
}
ShareLinkWidget *ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare)
{
- _linkWidgetList.append(new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollAreaLinks));
-
- const auto index = _linkWidgetList.size() - 1;
- const auto linkShareWidget = _linkWidgetList.at(index);
+ const auto linkShareWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollArea);
+ _linkWidgetList.append(linkShareWidget);
+
linkShareWidget->setLinkShare(linkShare);
connect(linkShare.data(), &Share::serverError, linkShareWidget, &ShareLinkWidget::slotServerError);
connect(this, &ShareDialog::styleChanged, linkShareWidget, &ShareLinkWidget::slotStyleChanged);
_ui->verticalLayout->insertWidget(_linkWidgetList.size() + 1, linkShareWidget);
- _scrollAreaLinksLayout->addWidget(linkShareWidget);
-
- // TO DO - the count is right but the bkg does not change
- //linkShareWidget->setBackgroundRole(_scrollAreaLinksLayout->count() % 2 == 0 ? QPalette::Base : QPalette::AlternateBase);
+ _scrollAreaLayout->addWidget(linkShareWidget);
linkShareWidget->setupUiOptions();
-
+
return linkShareWidget;
}
void ShareDialog::initLinkShareWidget()
{
if(_linkWidgetList.size() == 0) {
- _emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollAreaLinks);
+ _emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollArea);
_linkWidgetList.append(_emptyShareLinkWidget);
connect(this, &ShareDialog::toggleShareLinkAnimation, _emptyShareLinkWidget, &ShareLinkWidget::slotToggleShareLinkAnimation);
connect(_emptyShareLinkWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
connect(_emptyShareLinkWidget, &ShareLinkWidget::createPassword, this, &ShareDialog::slotCreatePasswordForLinkShare);
-
+
_ui->verticalLayout->insertWidget(_linkWidgetList.size()+1, _emptyShareLinkWidget);
- _scrollAreaLinksLayout->addWidget(_emptyShareLinkWidget);
+ _scrollAreaLayout->addWidget(_emptyShareLinkWidget);
_emptyShareLinkWidget->show();
} else if (_emptyShareLinkWidget) {
_emptyShareLinkWidget->hide();
emit toggleShareLinkAnimation(true);
const auto addedLinkShareWidget = addLinkShareWidget(linkShare);
initLinkShareWidget();
- slotAdjustScrollWidgetSize();
+ adjustScrollWidgetSize();
if (linkShare->isPasswordSet()) {
addedLinkShareWidget->focusPasswordLineEdit();
}
QSharedPointer<LinkShare> linkShare = qSharedPointerDynamicCast<LinkShare>(share);
addLinkShareWidget(linkShare);
}
-
+
initLinkShareWidget();
- slotAdjustScrollWidgetSize();
+ adjustScrollWidgetSize();
emit toggleShareLinkAnimation(false);
}
-void ShareDialog::slotAdjustScrollWidgetSize()
+void ShareDialog::adjustScrollWidgetSize()
{
- auto count = this->findChildren<ShareLinkWidget *>().count();
- count = count >= 6 ? 6 : count;
- auto height = _linkWidgetList.size() > 0 ? _linkWidgetList.at(_linkWidgetList.size() - 1)->sizeHint().height() : 0;
- _ui->scrollAreaLinks->setFixedWidth(_ui->verticalLayout->sizeHint().width());
- _ui->scrollAreaLinks->setFixedHeight(height * count);
- _ui->scrollAreaLinks->setVisible(height > 0);
- _ui->scrollAreaLinks->setFrameShape(count > 6 ? QFrame::StyledPanel : QFrame::NoFrame);
+ const auto count = _scrollAreaLayout->count();
+ const auto margin = 10;
+ const auto height = _linkWidgetList.empty() ? 0 : _linkWidgetList.last()->sizeHint().height() + margin;
+ const auto totalHeight = height * count;
+ _ui->scrollArea->setFixedWidth(_ui->verticalLayout->sizeHint().width());
+ _ui->scrollArea->setFixedHeight(totalHeight > 400 ? 400 : totalHeight);
+ _ui->scrollArea->setVisible(height > 0);
+ _ui->scrollArea->setFrameShape(count > 6 ? QFrame::StyledPanel : QFrame::NoFrame);
}
ShareDialog::~ShareDialog()
return;
}
- // We only do user/group sharing from 8.2.0
- bool userGroupSharing =
- theme->userGroupSharing()
- && _accountState->account()->serverVersionInt() >= Account::makeServerVersion(8, 2, 0);
-
- if (userGroupSharing) {
- _userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _privateLinkUrl, this);
-
+ if (theme->userGroupSharing()) {
+ _userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _privateLinkUrl, _ui->scrollArea);
+ _userGroupWidget->getShares();
+
// Connect styleChanged events to our widget, so it can adapt (Dark-/Light-Mode switching)
connect(this, &ShareDialog::styleChanged, _userGroupWidget, &ShareUserGroupWidget::slotStyleChanged);
_ui->verticalLayout->insertWidget(1, _userGroupWidget);
- _userGroupWidget->getShares();
+ _scrollAreaLayout->addLayout(_userGroupWidget->shareUserGroupLayout());
}
initShareManager();
auto sharelinkWidget = dynamic_cast<ShareLinkWidget*>(sender());
sharelinkWidget->hide();
_ui->verticalLayout->removeWidget(sharelinkWidget);
+ _scrollAreaLayout->removeWidget(sharelinkWidget);
_linkWidgetList.removeAll(sharelinkWidget);
initLinkShareWidget();
- slotAdjustScrollWidgetSize();
+ adjustScrollWidgetSize();
}
void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &reply)
void slotCreatePasswordForLinkShare(const QString &password);
void slotCreatePasswordForLinkShareProcessed();
void slotLinkShareRequiresPassword(const QString &message);
- void slotAdjustScrollWidgetSize();
signals:
void toggleShareLinkAnimation(bool start);
void initShareManager();
ShareLinkWidget *addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare);
void initLinkShareWidget();
+ void adjustScrollWidgetSize();
Ui::ShareDialog *_ui;
ShareUserGroupWidget *_userGroupWidget = nullptr;
QProgressIndicator *_progressIndicator = nullptr;
- QWidget *_scrollAreaLinksViewPort = nullptr;
- QVBoxLayout *_scrollAreaLinksLayout = nullptr;
+ QWidget *_scrollAreaViewPort = nullptr;
+ QVBoxLayout *_scrollAreaLayout = nullptr;
};
} // namespace OCC
<rect>
<x>0</x>
<y>0</y>
- <width>387</width>
- <height>222</height>
+ <width>480</width>
+ <height>280</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>480</width>
+ <height>250</height>
+ </size>
+ </property>
<layout class="QVBoxLayout" name="shareDialogVerticalLayout">
<property name="spacing">
- <number>9</number>
+ <number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
- <number>6</number>
+ <number>0</number>
</property>
<property name="sizeConstraint">
- <enum>QLayout::SetFixedSize</enum>
+ <enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0" columnstretch="0,0">
</layout>
</item>
<item>
- <layout class="QVBoxLayout" name="scrollBarsVerticalLayout">
- <property name="spacing">
- <number>12</number>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <item>
- <widget class="QScrollArea" name="scrollAreaLinks">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="styleSheet">
- <string notr="true"/>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="sizeAdjustPolicy">
- <enum>QAbstractScrollArea::AdjustIgnored</enum>
- </property>
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContentsLinks">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>365</width>
- <height>68</height>
- </rect>
- </property>
- </widget>
- </widget>
- </item>
- <item>
- <widget class="QScrollArea" name="scrollAreaUsers">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="styleSheet">
- <string notr="true"/>
- </property>
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Plain</enum>
- </property>
- <property name="lineWidth">
- <number>1</number>
- </property>
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="sizeAdjustPolicy">
- <enum>QAbstractScrollArea::AdjustIgnored</enum>
- </property>
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContentsUsers">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>365</width>
- <height>68</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/>
- </widget>
- </widget>
- </item>
- </layout>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>200</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="sizeAdjustPolicy">
+ <enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>460</width>
+ <height>200</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
</item>
</layout>
</item>
<number>0</number>
</property>
<property name="leftMargin">
- <number>6</number>
+ <number>12</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
</property>
<property name="rightMargin">
- <number>6</number>
+ <number>20</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
_completionTimer.setInterval(600);
_ui->errorLabel->hide();
-
- // TODO Progress Indicator where should it go?
- // Setup the sharee search progress indicator
- //_ui->shareeHorizontalLayout->addWidget(&_pi_sharee);
-
- _parentScrollArea = parentWidget()->findChild<QScrollArea*>("scrollAreaUsers");
-
+
+ _parentScrollArea = parentWidget()->findChild<QScrollArea*>("scrollArea");
+ _shareUserGroup = new QVBoxLayout(_parentScrollArea);
+ _shareUserGroup->setContentsMargins(0, 0, 0, 0);
customizeStyle();
}
+QVBoxLayout *ShareUserGroupWidget::shareUserGroupLayout()
+{
+ return _shareUserGroup;
+}
+
ShareUserGroupWidget::~ShareUserGroupWidget()
{
delete _ui;
void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
{
- QScrollArea *scrollArea = _parentScrollArea;
-
- auto newViewPort = new QWidget(scrollArea);
- auto layout = new QVBoxLayout(newViewPort);
- layout->setContentsMargins(0, 0, 0, 0);
int x = 0;
- int height = 0;
QList<QString> linkOwners({});
ShareUserLine *justCreatedShareThatNeedsPassword = nullptr;
-
+
+ while (QLayoutItem *shareUserLine = _shareUserGroup->takeAt(0)) {
+ delete shareUserLine->widget();
+ delete shareUserLine;
+ }
+
foreach (const auto &share, shares) {
// We don't handle link shares, only TypeUser or TypeGroup
if (share->getShareType() == Share::TypeLink) {
Q_ASSERT(Share::isShareTypeUserGroupEmailRoomOrRemote(share->getShareType()));
auto userGroupShare = qSharedPointerDynamicCast<UserGroupShare>(share);
auto *s = new ShareUserLine(_account, userGroupShare, _maxSharingPermissions, _isFile, _parentScrollArea);
- connect(s, &ShareUserLine::resizeRequested, this, &ShareUserGroupWidget::slotAdjustScrollWidgetSize);
connect(s, &ShareUserLine::visualDeletionDone, this, &ShareUserGroupWidget::getShares);
- s->setBackgroundRole(layout->count() % 2 == 0 ? QPalette::Base : QPalette::AlternateBase);
+ s->setBackgroundRole(_shareUserGroup->count() % 2 == 0 ? QPalette::Base : QPalette::AlternateBase);
// Connect styleChanged events to our widget, so it can adapt (Dark-/Light-Mode switching)
connect(this, &ShareUserGroupWidget::styleChanged, s, &ShareUserLine::slotStyleChanged);
-
- layout->addWidget(s);
+ _shareUserGroup->addWidget(s);
if (!_lastCreatedShareId.isEmpty() && share->getId() == _lastCreatedShareId) {
_lastCreatedShareId = QString();
}
x++;
- if (x <= 3) {
- height = newViewPort->sizeHint().height();
- }
}
foreach (const QString &owner, linkOwners) {
auto ownerLabel = new QLabel(QString(owner + " shared via link"));
- layout->addWidget(ownerLabel);
+ _shareUserGroup->addWidget(ownerLabel);
ownerLabel->setVisible(true);
-
- x++;
- if (x <= 6) {
- height = newViewPort->sizeHint().height();
- }
}
-
- scrollArea->setFrameShape(x > 6 ? QFrame::StyledPanel : QFrame::NoFrame);
- scrollArea->setVisible(!shares.isEmpty());
- scrollArea->setFixedHeight(height);
- scrollArea->setWidget(newViewPort);
-
+
_disableCompleterActivated = false;
activateShareeLineEdit();
}
}
-void ShareUserGroupWidget::slotAdjustScrollWidgetSize()
-{
- QScrollArea *scrollArea = _parentScrollArea;
- const auto shareUserLineChilds = scrollArea->findChildren<ShareUserLine *>();
-
- // Ask the child widgets to calculate their size
- for (const auto shareUserLineChild : shareUserLineChilds) {
- shareUserLineChild->adjustSize();
- }
-
- const auto shareUserLineChildsCount = shareUserLineChilds.count();
- scrollArea->setVisible(shareUserLineChildsCount > 0);
- if (shareUserLineChildsCount > 0 && shareUserLineChildsCount <= 3) {
- scrollArea->setFixedHeight(scrollArea->widget()->sizeHint().height());
- }
- scrollArea->setFrameShape(shareUserLineChildsCount > 3 ? QFrame::StyledPanel : QFrame::NoFrame);
-}
-
void ShareUserGroupWidget::slotPrivateLinkShare()
{
auto menu = new QMenu(this);
return;
}
-// TODO Progress Indicator where should it go?
-// auto indicator = new QProgressIndicator(viewPort);
-// indicator->startAnimation();
-// if (layout->count() == 1) {
-// // No shares yet! Remove the label, add some stretch.
-// delete layout->itemAt(0)->widget();
-// layout->addStretch(1);
-// }
-// layout->insertWidget(layout->count() - 1, indicator);
-
/*
* Don't send the reshare permissions for federated shares for servers <9.1
* https://github.com/owncloud/core/issues/22122#issuecomment-185637344
* https://github.com/owncloud/client/issues/4996
*/
-
_lastCreatedShareId = QString();
QString password;
const QString &privateLinkUrl,
QWidget *parent = nullptr);
~ShareUserGroupWidget() override;
+
+ QVBoxLayout *shareUserGroupLayout();
signals:
void togglePublicLinkShare(bool);
void slotCompleterActivated(const QModelIndex &index);
void slotCompleterHighlighted(const QModelIndex &index);
void slotShareesReady();
- void slotAdjustScrollWidgetSize();
void slotPrivateLinkShare();
void displayError(int code, const QString &message);
Ui::ShareUserGroupWidget *_ui;
QScrollArea *_parentScrollArea;
+ QVBoxLayout *_shareUserGroup;
AccountPtr _account;
QString _sharePath;
QString _localPath;
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>6</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <property name="bottomMargin">
+ <number>6</number>
+ </property>
<item>
<widget class="QLabel" name="mainOwnerLabel">
<property name="sizePolicy">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>12</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>20</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<property name="rightMargin">
- <number>22</number>
+ <number>0</number>
</property>
<item>
<widget class="QLabel" name="avatar">