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);
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);
emit toggleShareLinkAnimation(true);
const auto addedLinkShareWidget = addLinkShareWidget(linkShare);
initLinkShareWidget();
+ slotAdjustScrollWidgetSize();
if (linkShare->isPasswordSet()) {
addedLinkShareWidget->focusPasswordLineEdit();
}
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;
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()
_ui->verticalLayout->removeWidget(sharelinkWidget);
_linkWidgetList.removeAll(sharelinkWidget);
initLinkShareWidget();
+ slotAdjustScrollWidgetSize();
}
void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &reply)
<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">
<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">
</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>
+ <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>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="widgetResizable">
<bool>true</bool>
</property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
+ <widget class="QWidget" name="scrollAreaWidgetContentsUsers">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>69</width>
- <height>69</height>
+ <width>68</width>
+ <height>68</height>
</rect>
</property>
<layout class="QVBoxLayout" name="scrollAreaVerticalLayout"/>