[Pkg-owncloud-commits] [owncloud-client] 333/484: ShareDialog: add a QScrollArea (issue #4125 )
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:38:01 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 459e200ac0118081bae44d714414ef431d39b6d8
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Mon Nov 16 17:59:24 2015 +0100
ShareDialog: add a QScrollArea (issue #4125 )
---
src/gui/sharedialog.cpp | 1 +
src/gui/sharedialog.ui | 13 -------------
src/gui/shareusergroupwidget.cpp | 41 ++++++++++++++++++++++++++--------------
src/gui/shareusergroupwidget.ui | 29 +++++++++++++++++++++++++++-
4 files changed, 56 insertions(+), 28 deletions(-)
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp
index 7be123e..0177e8e 100644
--- a/src/gui/sharedialog.cpp
+++ b/src/gui/sharedialog.cpp
@@ -89,6 +89,7 @@ ShareDialog::ShareDialog(AccountPtr account, const QString &sharePath, const QSt
}
_linkWidget = new ShareLinkWidget(account, sharePath, localPath, resharingAllowed, autoShare, this);
+ _linkWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
_ui->shareWidgetsLayout->addWidget(_linkWidget);
}
diff --git a/src/gui/sharedialog.ui b/src/gui/sharedialog.ui
index 75359d4..6f82913 100644
--- a/src/gui/sharedialog.ui
+++ b/src/gui/sharedialog.ui
@@ -67,19 +67,6 @@
<layout class="QVBoxLayout" name="shareWidgetsLayout"/>
</item>
<item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp
index aa75b03..92357b8 100644
--- a/src/gui/shareusergroupwidget.cpp
+++ b/src/gui/shareusergroupwidget.cpp
@@ -34,6 +34,8 @@
#include <QFileInfo>
#include <QAbstractProxyModel>
#include <QCompleter>
+#include <qscrollarea.h>
+#include <qlayout.h>
#include <QPropertyAnimation>
namespace OCC {
@@ -77,6 +79,8 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, const QString &sh
connect(&_completionTimer, SIGNAL(timeout()), this, SLOT(on_searchPushButton_clicked()));
_completionTimer.setSingleShot(true);
_completionTimer.setInterval(600);
+
+ setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
}
ShareUserGroupWidget::~ShareUserGroupWidget()
@@ -113,11 +117,8 @@ void ShareUserGroupWidget::on_searchPushButton_clicked()
QSharedPointer<Sharee> currentUser(new Sharee(_account->credentials()->user(), "", Sharee::Type::User));
blacklist << currentUser;
- for(int i = 0; i < _ui->sharesLayout->count(); i++) {
- QWidget *w = _ui->sharesLayout->itemAt(i)->widget();
- if (auto sw = qobject_cast<ShareWidget *>(w)) {
- blacklist << sw->share()->getShareWith();
- }
+ foreach (auto sw, _ui->scrollArea->findChildren<ShareWidget*>()) {
+ blacklist << sw->share()->getShareWith();
}
_completerModel->fetch(_ui->shareeLineEdit->text(), blacklist);
@@ -131,13 +132,14 @@ void ShareUserGroupWidget::getShares()
void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shares)
{
- /*
- * Delete all current widgets
- */
- QLayoutItem *child;
- while ((child = _ui->sharesLayout->takeAt(0)) != 0) {
- delete child->widget();
- }
+ QScrollArea *scrollArea = _ui->scrollArea;
+
+
+ auto newViewPort = new QWidget(scrollArea);
+ auto layout = new QVBoxLayout(newViewPort);
+
+ QSize minimumSize = newViewPort->sizeHint();
+ int x = 0;
foreach(const auto &share, shares) {
// We don't handle link shares
@@ -145,9 +147,20 @@ void ShareUserGroupWidget::slotSharesFetched(const QList<QSharedPointer<Share>>
continue;
}
- ShareWidget *s = new ShareWidget(share, this);
- _ui->sharesLayout->addWidget(s);
+ ShareWidget *s = new ShareWidget(share, _ui->scrollArea);
+ layout->addWidget(s);
+
+ x++;
+ if (x <= 3) {
+ minimumSize = newViewPort->sizeHint();
+ }
}
+
+ minimumSize.rwidth() += layout->spacing();
+ minimumSize.rheight() += layout->spacing();
+ scrollArea->setMinimumSize(minimumSize);
+ scrollArea->setVisible(!shares.isEmpty());
+ scrollArea->setWidget(newViewPort);
}
void ShareUserGroupWidget::slotShareesReady()
diff --git a/src/gui/shareusergroupwidget.ui b/src/gui/shareusergroupwidget.ui
index b872fb5..5b8e0f0 100644
--- a/src/gui/shareusergroupwidget.ui
+++ b/src/gui/shareusergroupwidget.ui
@@ -39,7 +39,34 @@
</layout>
</item>
<item>
- <layout class="QVBoxLayout" name="sharesLayout"/>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="sizeAdjustPolicy">
+ <enum>QAbstractScrollArea::AdjustToContents</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>441</width>
+ <height>124</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3"/>
+ </widget>
+ </widget>
</item>
</layout>
</widget>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list