mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Add scroll area for share links.
Signed-off-by: Camila <hello@camila.codes>
This commit is contained in:
parent
40d8434c8e
commit
a10f84b5c1
6 changed files with 115 additions and 70 deletions
|
@ -137,13 +137,19 @@ ShareDialog::ShareDialog(QPointer<AccountState> accountState,
|
|||
job->start();
|
||||
|
||||
initShareManager();
|
||||
|
||||
_scrollAreaLinksViewPort = new QWidget(_ui->scrollAreaLinks);
|
||||
_scrollAreaLinksLayout = new QVBoxLayout(_scrollAreaLinksViewPort);
|
||||
_scrollAreaLinksLayout->setContentsMargins(6, 6, 6, 6);
|
||||
_ui->scrollAreaLinks->setWidget(_scrollAreaLinksViewPort);
|
||||
}
|
||||
|
||||
ShareLinkWidget *ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare)
|
||||
{
|
||||
_linkWidgetList.append(new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this));
|
||||
|
||||
const auto linkShareWidget = _linkWidgetList.at(_linkWidgetList.size() - 1);
|
||||
_linkWidgetList.append(new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollAreaLinks));
|
||||
|
||||
const auto index = _linkWidgetList.size() - 1;
|
||||
const auto linkShareWidget = _linkWidgetList.at(index);
|
||||
linkShareWidget->setLinkShare(linkShare);
|
||||
|
||||
connect(linkShare.data(), &Share::serverError, linkShareWidget, &ShareLinkWidget::slotServerError);
|
||||
|
@ -158,33 +164,35 @@ ShareLinkWidget *ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare>
|
|||
connect(linkShareWidget, &ShareLinkWidget::createLinkShare, this, &ShareDialog::slotCreateLinkShare);
|
||||
connect(linkShareWidget, &ShareLinkWidget::deleteLinkShare, this, &ShareDialog::slotDeleteShare);
|
||||
connect(linkShareWidget, &ShareLinkWidget::createPassword, this, &ShareDialog::slotCreatePasswordForLinkShare);
|
||||
|
||||
//connect(_linkWidgetList.at(index), &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize);
|
||||
|
||||
|
||||
// Connect styleChanged events to our widget, so it can adapt (Dark-/Light-Mode switching)
|
||||
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);
|
||||
|
||||
linkShareWidget->setupUiOptions();
|
||||
|
||||
|
||||
return linkShareWidget;
|
||||
}
|
||||
|
||||
void ShareDialog::initLinkShareWidget()
|
||||
{
|
||||
if(_linkWidgetList.size() == 0) {
|
||||
_emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this);
|
||||
_emptyShareLinkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, _ui->scrollAreaLinks);
|
||||
_linkWidgetList.append(_emptyShareLinkWidget);
|
||||
|
||||
connect(_emptyShareLinkWidget, &ShareLinkWidget::resizeRequested, this, &ShareDialog::slotAdjustScrollWidgetSize);
|
||||
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);
|
||||
_emptyShareLinkWidget->show();
|
||||
} else if(_emptyShareLinkWidget) {
|
||||
} else if (_emptyShareLinkWidget) {
|
||||
_emptyShareLinkWidget->hide();
|
||||
_ui->verticalLayout->removeWidget(_emptyShareLinkWidget);
|
||||
_linkWidgetList.removeAll(_emptyShareLinkWidget);
|
||||
|
@ -197,6 +205,7 @@ void ShareDialog::slotAddLinkShareWidget(const QSharedPointer<LinkShare> &linkSh
|
|||
emit toggleShareLinkAnimation(true);
|
||||
const auto addedLinkShareWidget = addLinkShareWidget(linkShare);
|
||||
initLinkShareWidget();
|
||||
slotAdjustScrollWidgetSize();
|
||||
if (linkShare->isPasswordSet()) {
|
||||
addedLinkShareWidget->focusPasswordLineEdit();
|
||||
}
|
||||
|
@ -209,6 +218,7 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
|||
|
||||
const QString versionString = _accountState->account()->serverVersion();
|
||||
qCInfo(lcSharing) << versionString << "Fetched" << shares.count() << "shares";
|
||||
|
||||
foreach (auto share, shares) {
|
||||
if (share->getShareType() != Share::TypeLink || share->getUidOwner() != share->account()->davUser()) {
|
||||
continue;
|
||||
|
@ -217,19 +227,21 @@ void ShareDialog::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
|
|||
QSharedPointer<LinkShare> linkShare = qSharedPointerDynamicCast<LinkShare>(share);
|
||||
addLinkShareWidget(linkShare);
|
||||
}
|
||||
|
||||
|
||||
initLinkShareWidget();
|
||||
slotAdjustScrollWidgetSize();
|
||||
emit toggleShareLinkAnimation(false);
|
||||
}
|
||||
|
||||
void ShareDialog::slotAdjustScrollWidgetSize()
|
||||
{
|
||||
int count = this->findChildren<ShareLinkWidget *>().count();
|
||||
_ui->scrollArea->setVisible(count > 0);
|
||||
if (count > 0 && count <= 3) {
|
||||
_ui->scrollArea->setFixedHeight(_ui->scrollArea->widget()->sizeHint().height());
|
||||
}
|
||||
_ui->scrollArea->setFrameShape(count > 3 ? QFrame::StyledPanel : QFrame::NoFrame);
|
||||
auto count = this->findChildren<ShareLinkWidget *>().count();
|
||||
count = count > 3 ? 3 : 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 > 3 ? QFrame::StyledPanel : QFrame::NoFrame);
|
||||
}
|
||||
|
||||
ShareDialog::~ShareDialog()
|
||||
|
@ -391,6 +403,7 @@ void ShareDialog::slotDeleteShare()
|
|||
_ui->verticalLayout->removeWidget(sharelinkWidget);
|
||||
_linkWidgetList.removeAll(sharelinkWidget);
|
||||
initLinkShareWidget();
|
||||
slotAdjustScrollWidgetSize();
|
||||
}
|
||||
|
||||
void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &reply)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <QWidget>
|
||||
|
||||
class QProgressIndicator;
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
@ -97,6 +98,9 @@ private:
|
|||
ShareLinkWidget* _emptyShareLinkWidget = nullptr;
|
||||
ShareUserGroupWidget *_userGroupWidget = nullptr;
|
||||
QProgressIndicator *_progressIndicator = nullptr;
|
||||
|
||||
QWidget *_scrollAreaLinksViewPort = nullptr;
|
||||
QVBoxLayout *_scrollAreaLinksLayout = nullptr;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>385</width>
|
||||
<height>150</height>
|
||||
<width>400</width>
|
||||
<height>222</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="shareDialogVerticalLayout">
|
||||
|
@ -33,6 +33,31 @@
|
|||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="sizePolicy">
|
||||
|
@ -89,44 +114,25 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="label_icon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<widget class="QScrollArea" name="scrollAreaLinks">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" 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>
|
||||
|
@ -136,13 +142,54 @@
|
|||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<widget class="QWidget" name="scrollAreaWidgetContentsLinks">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>69</width>
|
||||
<height>69</height>
|
||||
<width>68</width>
|
||||
<height>68</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollAreaUsers">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" 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>68</width>
|
||||
<height>68</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/>
|
||||
|
|
|
@ -411,22 +411,6 @@ void ShareLinkWidget::slotPasswordSetError(const int code, const QString &messag
|
|||
emit createPasswordProcessed();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::startAnimation(const int start, const int end)
|
||||
{
|
||||
auto *animation = new QPropertyAnimation(this, "maximumHeight", this);
|
||||
|
||||
animation->setDuration(500);
|
||||
animation->setStartValue(start);
|
||||
animation->setEndValue(end);
|
||||
|
||||
connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotAnimationFinished);
|
||||
if (end < start) // that is to remove the widget, not to show it
|
||||
connect(animation, &QAbstractAnimation::finished, this, &ShareLinkWidget::slotDeleteAnimationFinished);
|
||||
connect(animation, &QVariantAnimation::valueChanged, this, &ShareLinkWidget::resizeRequested);
|
||||
|
||||
animation->start();
|
||||
}
|
||||
|
||||
void ShareLinkWidget::slotDeleteShareFetched()
|
||||
{
|
||||
slotToggleShareLinkAnimation(false);
|
||||
|
|
|
@ -100,7 +100,6 @@ private slots:
|
|||
signals:
|
||||
void createLinkShare();
|
||||
void deleteLinkShare();
|
||||
void resizeRequested();
|
||||
void visualDeletionDone();
|
||||
void createPassword(const QString &password);
|
||||
void createPasswordProcessed();
|
||||
|
@ -119,8 +118,6 @@ private:
|
|||
/** Retrieve a share's name, accounting for _namesSupported */
|
||||
QString shareName() const;
|
||||
|
||||
void startAnimation(const int start, const int end);
|
||||
|
||||
void customizeStyle();
|
||||
|
||||
void displayShareLinkLabel();
|
||||
|
|
|
@ -159,7 +159,7 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account,
|
|||
// Setup the sharee search progress indicator
|
||||
//_ui->shareeHorizontalLayout->addWidget(&_pi_sharee);
|
||||
|
||||
_parentScrollArea = parentWidget()->findChild<QScrollArea*>("scrollArea");
|
||||
_parentScrollArea = parentWidget()->findChild<QScrollArea*>("scrollAreaUsers");
|
||||
|
||||
customizeStyle();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue