#include <QPointer>
#include <QPushButton>
#include <QFrame>
+#include <QScrollBar>
namespace {
QString createRandomPassword()
_ui->verticalLayout->addWidget(_internalLinkWidget);
_internalLinkWidget->setupUiOptions();
connect(this, &ShareDialog::styleChanged, _internalLinkWidget, &InternalLinkWidget::slotStyleChanged);
+
+ adjustScrollWidget();
}
ShareLinkWidget *ShareDialog::addLinkShareWidget(const QSharedPointer<LinkShare> &linkShare)
_scrollAreaLayout->addWidget(linkShareWidget);
linkShareWidget->setupUiOptions();
+ adjustScrollWidget();
return linkShareWidget;
}
_linkWidgetList.removeAll(_emptyShareLinkWidget);
_emptyShareLinkWidget = nullptr;
}
+
+ adjustScrollWidget();
}
void ShareDialog::slotAddLinkShareWidget(const QSharedPointer<LinkShare> &linkShare)
emit toggleShareLinkAnimation(true);
const auto addedLinkShareWidget = addLinkShareWidget(linkShare);
initLinkShareWidget();
- adjustScrollWidgetSize();
if (linkShare->isPasswordSet()) {
addedLinkShareWidget->focusPasswordLineEdit();
}
}
initLinkShareWidget();
- adjustScrollWidgetSize();
emit toggleShareLinkAnimation(false);
}
-void ShareDialog::adjustScrollWidgetSize()
+void ShareDialog::adjustScrollWidget()
{
- 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);
+ _ui->scrollArea->setVisible(_scrollAreaLayout->count() > 0);
+
+ // Sometimes the contentRect returns a height of 0, so we need a backup plan
+ const auto scrollAreaContentHeight = _scrollAreaLayout->contentsRect().height();
+
+ auto linkWidgetHeights = 0;
+
+ if(scrollAreaContentHeight == 0 && !_linkWidgetList.empty()) {
+ for (const auto linkWidget : _linkWidgetList) {
+ linkWidgetHeights += linkWidget->height() - 10;
+ }
+ }
+
+ const auto overAvailableHeight = scrollAreaContentHeight > _ui->scrollArea->height() ||
+ linkWidgetHeights > _ui->scrollArea->height();
+
+ _ui->scrollArea->setFrameShape(overAvailableHeight ? QFrame::StyledPanel : QFrame::NoFrame);
+ _ui->verticalLayout->setSpacing(overAvailableHeight ? 10 : 0);
}
ShareDialog::~ShareDialog()
_manager->fetchShares(_sharePath);
}
}
+
+ adjustScrollWidget();
}
void ShareDialog::initShareManager()
_scrollAreaLayout->removeWidget(sharelinkWidget);
_linkWidgetList.removeAll(sharelinkWidget);
initLinkShareWidget();
- adjustScrollWidgetSize();
}
void ShareDialog::slotThumbnailFetched(const int &statusCode, const QByteArray &reply)
QDialog::changeEvent(e);
}
+void ShareDialog::resizeEvent(QResizeEvent *event)
+{
+ adjustScrollWidget();
+ QDialog::resizeEvent(event);
+}
+
} // namespace OCC
<rect>
<x>0</x>
<y>0</y>
- <width>480</width>
- <height>280</height>
+ <width>385</width>
+ <height>400</height>
</rect>
</property>
<property name="sizePolicy">
</property>
<property name="minimumSize">
<size>
- <width>480</width>
- <height>250</height>
+ <width>320</width>
+ <height>240</height>
</size>
</property>
<layout class="QVBoxLayout" name="shareDialogVerticalLayout">
<number>0</number>
</property>
<property name="sizeConstraint">
- <enum>QLayout::SetFixedSize</enum>
+ <enum>QLayout::SetMinimumSize</enum>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<number>0</number>
</property>
<property name="spacing">
- <number>2</number>
+ <number>2</number>
</property>
<item row="0" column="1">
<widget class="QLabel" name="label_name">
</property>
<property name="font">
<font>
- <weight>50</weight>
<bold>false</bold>
</font>
</property>
</property>
</widget>
</item>
- <item row="0" column="0" rowspan="3">
+ <item row="0" column="0" rowspan="4">
<widget class="QLabel" name="label_icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<property name="minimumSize">
<size>
<width>0</width>
- <height>200</height>
+ <height>0</height>
</size>
</property>
<property name="frameShape">
<rect>
<x>0</x>
<y>0</y>
- <width>460</width>
- <height>200</height>
+ <width>359</width>
+ <height>320</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
</widget>
</widget>
</item>