diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index 742b39e43..ea0d45bb2 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -61,6 +61,7 @@ private: void showSharingUi(); Ui::ShareDialog *_ui; + QPointer _accountState; QString _sharePath; QString _localPath; diff --git a/src/gui/sharedialog.ui b/src/gui/sharedialog.ui index 94694ff23..6e8a0a5ec 100644 --- a/src/gui/sharedialog.ui +++ b/src/gui/sharedialog.ui @@ -31,25 +31,7 @@ Dialog - - - 10 - - - QLayout::SetFixedSize - - - 10 - - - 10 - - - 10 - - - 10 - + @@ -171,6 +153,97 @@ + + + + + 0 + 0 + + + + + 360 + 45 + + + + + 16777215 + 16777215 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + 0 + 0 + 340 + 45 + + + + + 0 + 0 + + + + + 340 + 45 + + + + + 16777215 + 16777215 + + + + + 0 + + + QLayout::SetFixedSize + + + 0 + + + 0 + + + 0 + + + 0 + + + + + diff --git a/src/gui/shareusergroupwidget.cpp b/src/gui/shareusergroupwidget.cpp index 6b4582c71..5f1b393ff 100644 --- a/src/gui/shareusergroupwidget.cpp +++ b/src/gui/shareusergroupwidget.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -44,6 +43,7 @@ #include #include #include +#include namespace OCC { @@ -113,16 +113,10 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, // adds permissions QMenu *menu = new QMenu(this); - QAction *canShare = new QAction(tr("can share")); - canShare->setCheckable(true); - canShare->setEnabled(true); - canShare->setData(QVariant(SharePermissionShare)); QAction *canEdit = new QAction(tr("can edit")); canEdit->setCheckable(true); canEdit->setEnabled(true); canEdit->setData(QVariant(SharePermissionUpdate)); - - menu->addAction(canShare); menu->addAction(canEdit); /* * Files can't have create or delete permissions @@ -139,9 +133,12 @@ ShareUserGroupWidget::ShareUserGroupWidget(AccountPtr account, menu->addAction(canCreate); menu->addAction(canDelete); } - _ui->permissionToolButton->setDefaultAction(canShare); + + //_ui->permissionToolButton->setDefaultAction(canEdit); _ui->permissionToolButton->setMenu(menu); _ui->permissionToolButton->setPopupMode(QToolButton::InstantPopup); + + _parentScrollArea = parentWidget()->findChild("scrollArea"); } ShareUserGroupWidget::~ShareUserGroupWidget() @@ -200,7 +197,7 @@ void ShareUserGroupWidget::searchForSharees() QSharedPointer currentUser(new Sharee(_account->credentials()->user(), "", Sharee::Type::User)); blacklist << currentUser; - foreach (auto sw, _ui->scrollArea->findChildren()) { + foreach (auto sw, _parentScrollArea->findChildren()) { blacklist << sw->share()->getShareWith(); } _ui->errorLabel->hide(); @@ -215,7 +212,7 @@ void ShareUserGroupWidget::getShares() void ShareUserGroupWidget::slotSharesFetched(const QList> &shares) { //if(shares.size() > 0){ - QScrollArea *scrollArea = _ui->scrollArea; + QScrollArea *scrollArea = _parentScrollArea; auto newViewPort = new QWidget(scrollArea); auto layout = new QVBoxLayout(newViewPort); @@ -228,7 +225,7 @@ void ShareUserGroupWidget::slotSharesFetched(const QList> continue; } - ShareUserLine *s = new ShareUserLine(share, _maxSharingPermissions, _isFile, _ui->scrollArea); + ShareUserLine *s = new ShareUserLine(share, _maxSharingPermissions, _isFile, _parentScrollArea); connect(s, &ShareUserLine::resizeRequested, this, &ShareUserGroupWidget::slotAdjustScrollWidgetSize); connect(s, &ShareUserLine::visualDeletionDone, this, &ShareUserGroupWidget::getShares); s->setBackgroundRole(layout->count() % 2 == 0 ? QPalette::Base : QPalette::AlternateBase); @@ -243,10 +240,10 @@ void ShareUserGroupWidget::slotSharesFetched(const QList> } if (!layout->isEmpty()) { - _ui->scrollArea->setVisible(true); + _parentScrollArea->setVisible(true); layout->addStretch(1); } else { - _ui->scrollArea->setVisible(false); + _parentScrollArea->setVisible(false); } minimumSize.rwidth() += layout->spacing(); @@ -264,7 +261,7 @@ void ShareUserGroupWidget::slotSharesFetched(const QList> void ShareUserGroupWidget::slotAdjustScrollWidgetSize() { - QScrollArea *scrollArea = _ui->scrollArea; + QScrollArea *scrollArea = _parentScrollArea; if (scrollArea->findChildren().count() <= 3 && scrollArea->findChildren().count() > 0) { auto minimumSize = scrollArea->widget()->sizeHint(); @@ -308,14 +305,14 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex &index) // model proxying the _completerModel auto sharee = qvariant_cast>(index.data(Qt::UserRole)); if (sharee.isNull()) { - _ui->scrollArea->setVisible(false); + _parentScrollArea->setVisible(false); return; } /* * Add spinner to the bottom of the widget list */ - auto viewPort = _ui->scrollArea->widget(); + auto viewPort = _parentScrollArea->widget(); auto layout = qobject_cast(viewPort->layout()); // auto indicator = new QProgressIndicator(viewPort); // indicator->startAnimation(); @@ -353,9 +350,9 @@ void ShareUserGroupWidget::slotCompleterActivated(const QModelIndex &index) _ui->shareeLineEdit->setText(QString()); if(layout->isEmpty()) - _ui->scrollArea->setVisible(false); + _parentScrollArea->setVisible(false); else - _ui->scrollArea->setVisible(true); + _parentScrollArea->setVisible(true); } void ShareUserGroupWidget::slotCompleterHighlighted(const QModelIndex &index) @@ -370,7 +367,7 @@ void ShareUserGroupWidget::displayError(int code, const QString &message) _pi_sharee.stopAnimation(); // Also remove the spinner in the widget list, if any - foreach (auto pi, _ui->scrollArea->findChildren()) { + foreach (auto pi, _parentScrollArea->findChildren()) { delete pi; } @@ -409,10 +406,19 @@ ShareUserLine::ShareUserLine(QSharedPointer share, { _ui->setupUi(this); - _ui->sharedWith->setText(share->getShareWith()->format()); + QString sharedWithText(share->getShareWith()->format()); + QFontMetrics metrics(_ui->sharedWith->font()); + QString elidedText = metrics.elidedText(sharedWithText, Qt::ElideRight, _ui->sharedWith->width()); + _ui->sharedWith->setText(elidedText); // Create detailed permissions menu QMenu *menu = new QMenu(this); + _permissionShare = new QAction(tr("share")); + _permissionShare->setCheckable(true); + _permissionShare->setEnabled(true); + _permissionShare->setData(QVariant(SharePermissionShare)); + menu->addAction(_permissionShare); + _permissionCreate = new QAction(tr("create"), this); _permissionCreate->setCheckable(true); _permissionCreate->setEnabled(maxSharingPermissions & SharePermissionCreate); @@ -445,14 +451,14 @@ ShareUserLine::ShareUserLine(QSharedPointer share, // Set the permissions checkboxes displayPermissions(); - _ui->permissionShare->setEnabled(maxSharingPermissions & SharePermissionShare); + _permissionShare->setEnabled(maxSharingPermissions & SharePermissionShare); _ui->permissionsEdit->setEnabled(maxSharingPermissions & (SharePermissionCreate | SharePermissionUpdate | SharePermissionDelete)); connect(_permissionUpdate, &QAction::triggered, this, &ShareUserLine::slotPermissionsChanged); connect(_permissionCreate, &QAction::triggered, this, &ShareUserLine::slotPermissionsChanged); connect(_permissionDelete, &QAction::triggered, this, &ShareUserLine::slotPermissionsChanged); - connect(_ui->permissionShare, &QAbstractButton::clicked, this, &ShareUserLine::slotPermissionsChanged); + connect(_permissionShare, &QAction::triggered, this, &ShareUserLine::slotPermissionsChanged); connect(_ui->permissionsEdit, &QAbstractButton::clicked, this, &ShareUserLine::slotEditPermissionsChanged); /* @@ -462,7 +468,7 @@ ShareUserLine::ShareUserLine(QSharedPointer share, */ if (share->getShareType() == Share::TypeRemote && share->account()->serverVersionInt() < Account::makeServerVersion(9, 1, 0)) { - _ui->permissionShare->setVisible(false); + _permissionShare->setVisible(false); _ui->permissionToolButton->setVisible(false); } @@ -473,7 +479,7 @@ ShareUserLine::ShareUserLine(QSharedPointer share, QIcon(QLatin1String(":/client/resources/delete.png")))); if (!share->account()->capabilities().shareResharing()) { - _ui->permissionShare->hide(); + _permissionShare->setVisible(false); } loadAvatar(); @@ -560,7 +566,7 @@ void ShareUserLine::slotEditPermissionsChanged() Share::Permissions permissions = SharePermissionRead; - if (_ui->permissionShare->checkState() == Qt::Checked) { + if (_permissionShare->isChecked()) { permissions |= SharePermissionShare; } @@ -600,7 +606,7 @@ void ShareUserLine::slotPermissionsChanged() permissions |= SharePermissionDelete; } - if (_ui->permissionShare->checkState() == Qt::Checked) { + if (_permissionShare->isChecked()) { permissions |= SharePermissionShare; } @@ -672,9 +678,9 @@ void ShareUserLine::displayPermissions() _ui->permissionsEdit->setCheckState(Qt::Unchecked); } - _ui->permissionShare->setCheckState(Qt::Unchecked); + _permissionShare->setChecked(Qt::Unchecked); if (_share->getPermissions() & SharePermissionShare) { - _ui->permissionShare->setCheckState(Qt::Checked); + _permissionShare->setChecked(Qt::Checked);; } } } diff --git a/src/gui/shareusergroupwidget.h b/src/gui/shareusergroupwidget.h index 68d0f47df..6fe55ee53 100644 --- a/src/gui/shareusergroupwidget.h +++ b/src/gui/shareusergroupwidget.h @@ -24,6 +24,7 @@ #include #include #include +#include class QAction; class QCompleter; @@ -88,6 +89,7 @@ private slots: private: Ui::ShareUserGroupWidget *_ui; + QScrollArea *_parentScrollArea; AccountPtr _account; QString _sharePath; QString _localPath; @@ -144,6 +146,7 @@ private: QSharedPointer _share; bool _isFile; + QAction *_permissionShare; QAction *_permissionCreate; QAction *_permissionUpdate; QAction *_permissionDelete; diff --git a/src/gui/shareusergroupwidget.ui b/src/gui/shareusergroupwidget.ui index dbf65d291..bf3cc2af3 100644 --- a/src/gui/shareusergroupwidget.ui +++ b/src/gui/shareusergroupwidget.ui @@ -7,7 +7,7 @@ 0 0 350 - 120 + 56 @@ -19,7 +19,7 @@ 350 - 120 + 54 @@ -31,7 +31,7 @@ Share NewDocument.odt - + 0 @@ -205,97 +205,6 @@ - - - - - 0 - 0 - - - - - 350 - 45 - - - - - 16777215 - 16777215 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - Qt::ScrollBarAsNeeded - - - QAbstractScrollArea::AdjustToContents - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 0 - 0 - 340 - 45 - - - - - 0 - 0 - - - - - 340 - 45 - - - - - 16777215 - 16777215 - - - - - 0 - - - QLayout::SetFixedSize - - - 0 - - - 0 - - - 0 - - - 0 - - - - - diff --git a/src/gui/shareuserline.ui b/src/gui/shareuserline.ui index 1d82f0cba..7580882ad 100644 --- a/src/gui/shareuserline.ui +++ b/src/gui/shareuserline.ui @@ -9,20 +9,20 @@ 0 0 - 330 - 40 + 340 + 45 - + 0 0 - 330 - 40 + 340 + 45 @@ -37,7 +37,7 @@ true - + 3 @@ -84,19 +84,25 @@ - + 0 0 + + + 100 + 0 + + - + User name Qt::PlainText - false + true @@ -106,7 +112,7 @@ Qt::Horizontal - QSizePolicy::Maximum + QSizePolicy::Expanding @@ -116,25 +122,6 @@ - - - - - 0 - 0 - - - - - 0 - 0 - - - - can share - - -