this->setWindowTitle(tr("%1 Sharing").arg(Theme::instance()->appNameGUI()));
if (!accountState->account()->capabilities().shareAPI()) {
- _ui->shareWidgetsLayout->addWidget(new QLabel(tr("The server does not allow sharing")));
+ _ui->shareWidgets->hide();
+ layout()->replaceWidget(_ui->shareWidgets, new QLabel(tr("The server does not allow sharing")));
return;
}
_progressIndicator = new QProgressIndicator(this);
_progressIndicator->startAnimation();
_progressIndicator->setToolTip(tr("Retrieving maximum possible sharing permissions from server..."));
- _ui->shareWidgetsLayout->addWidget(_progressIndicator);
+ _ui->buttonBoxLayout->insertWidget(0, _progressIndicator);
// Server versions >= 9.1 support the "share-permissions" property
// older versions will just return share-permissions: ""
if (!canReshare) {
auto label = new QLabel(this);
label->setText(tr("The file can not be shared because it was shared without sharing permission."));
- _ui->shareWidgetsLayout->addWidget(label);
+ layout()->replaceWidget(_ui->shareWidgets, label);
return;
}
if (userGroupSharing) {
_userGroupWidget = new ShareUserGroupWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, this);
- _ui->shareWidgetsLayout->addWidget(_userGroupWidget);
+ _ui->shareWidgets->addTab(_userGroupWidget, tr("Users and Groups"));
_userGroupWidget->getShares();
}
// Make the line softer:
p.setColor(QPalette::Foreground, QColor::fromRgba((p.color(QPalette::Foreground).rgba() & 0x00ffffff) | 0x50000000));
hline->setPalette(p);
- _ui->shareWidgetsLayout->addWidget(hline);
}
_linkWidget = new ShareLinkWidget(_accountState->account(), _sharePath, _localPath, _maxSharingPermissions, autoShare, this);
_linkWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- _ui->shareWidgetsLayout->addWidget(_linkWidget);
+ _ui->shareWidgets->addTab(_linkWidget, tr("Public Links"));
_linkWidget->getShares();
}
}
</layout>
</item>
<item>
- <layout class="QVBoxLayout" name="shareWidgetsLayout">
- <property name="spacing">
- <number>10</number>
- </property>
- </layout>
- </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>
+ <widget class="QTabWidget" name="shareWidgets"/>
</item>
<item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Close</set>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="buttonBoxLayout">
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
QSize minimumSize = newViewPort->sizeHint();
int x = 0;
- foreach(const auto &share, shares) {
- // We don't handle link shares
- if (share->getShareType() == Share::TypeLink) {
- continue;
- }
-
- ShareWidget *s = new ShareWidget(share, _maxSharingPermissions, _isFile, _ui->scrollArea);
- connect(s, SIGNAL(resizeRequested()), this, SLOT(slotAdjustScrollWidgetSize()));
- layout->addWidget(s);
-
- x++;
- if (x <= 3) {
- minimumSize = newViewPort->sizeHint();
- } else {
- minimumSize.rwidth() = qMax(newViewPort->sizeHint().width(), minimumSize.width());
+ if (shares.isEmpty()) {
+ layout->addWidget(new QLabel(tr("The item is not shared with any users or groups")));
+ } else {
+ foreach(const auto &share, shares) {
+ // We don't handle link shares
+ if (share->getShareType() == Share::TypeLink) {
+ continue;
+ }
+
+ ShareWidget *s = new ShareWidget(share, _maxSharingPermissions, _isFile, _ui->scrollArea);
+ connect(s, SIGNAL(resizeRequested()), this, SLOT(slotAdjustScrollWidgetSize()));
+ connect(s, SIGNAL(visualDeletionDone()), this, SLOT(getShares()));
+ layout->addWidget(s);
+
+ x++;
+ if (x <= 3) {
+ minimumSize = newViewPort->sizeHint();
+ } else {
+ minimumSize.rwidth() = qMax(newViewPort->sizeHint().width(), minimumSize.width());
+ }
}
+ layout->addStretch(1);
}
minimumSize.rwidth() += layout->spacing();
minimumSize.rheight() += layout->spacing();
scrollArea->setMinimumSize(minimumSize);
- scrollArea->setVisible(!shares.isEmpty());
scrollArea->setWidget(newViewPort);
_disableCompleterActivated = false;
* Add spinner to the bottom of the widget list
*/
auto viewPort = _ui->scrollArea->widget();
- auto layout = viewPort->layout();
+ auto layout = qobject_cast<QVBoxLayout*>(viewPort->layout());
auto indicator = new QProgressIndicator(viewPort);
indicator->startAnimation();
- layout->addWidget(indicator);
+ 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
void ShareWidget::slotDeleteAnimationFinished()
{
- resizeRequested();
+ emit resizeRequested();
+ emit visualDeletionDone();
deleteLater();
// There is a painting bug where a small line of this widget isn't
QSharedPointer<Share> share() const;
signals:
- void shareDeleted(ShareWidget *share);
+ void visualDeletionDone();
void resizeRequested();
private slots: