start();
}
+void OcsShareJob::setLabel(const QString &shareId, const QString &label)
+{
+ appendPath(shareId);
+ setVerb("PUT");
+
+ addParam(QStringLiteral("label"), label);
+ _value = label;
+
+ start();
+}
+
void OcsShareJob::createLinkShare(const QString &path,
const QString &name,
const QString &password)
*/
void setPermissions(const QString &shareId,
const Share::Permissions permissions);
+
+ /**
+ * Set share link label
+ */
+ void setLabel(const QString &shareId, const QString &label);
/**
* Create a new link share
#include "guiutility.h"
#include "sharemanager.h"
#include "theme.h"
+#include "elidedlabel.h"
#include "QProgressIndicator.h"
#include <QBuffer>
connect(_linkShare.data(), &LinkShare::noteSet, this, &ShareLinkWidget::slotNoteSet);
connect(_linkShare.data(), &LinkShare::passwordSet, this, &ShareLinkWidget::slotPasswordSet);
connect(_linkShare.data(), &LinkShare::passwordSetError, this, &ShareLinkWidget::slotPasswordSetError);
+ connect(_linkShare.data(), &LinkShare::labelSet, this, &ShareLinkWidget::slotLabelSet);
// Prepare permissions check and create group action
const QDate expireDate = _linkShare.data()->getExpireDate().isValid() ? _linkShare.data()->getExpireDate() : QDate();
} else {
checked = (perm == SharePermissionRead);
- _readOnlyLinkAction = permissionsGroup->addAction(tr("Read only"));
+ _readOnlyLinkAction = permissionsGroup->addAction(tr("View only"));
_readOnlyLinkAction->setCheckable(true);
_readOnlyLinkAction->setChecked(checked);
_allowUploadLinkAction->setCheckable(true);
_allowUploadLinkAction->setChecked(checked);
}
+
+ _shareLinkElidedLabel = new OCC::ElidedLabel(this);
+ _shareLinkElidedLabel->setElideMode(Qt::ElideRight);
+ displayShareLinkLabel();
+ _ui->horizontalLayout->insertWidget(2, _shareLinkElidedLabel);
+
+ _shareLinkLayout = new QHBoxLayout(this);
+
+ _shareLinkLabel = new QLabel(this);
+ _shareLinkLabel->setPixmap(QString(":/client/theme/black/edit.svg"));
+ _shareLinkLayout->addWidget(_shareLinkLabel);
+
+ _shareLinkEdit = new QLineEdit(this);
+ connect(_shareLinkEdit, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreateLabel);
+ _shareLinkEdit->setPlaceholderText(tr("Link name"));
+ _shareLinkEdit->setText(_linkShare.data()->getLabel());
+ _shareLinkLayout->addWidget(_shareLinkEdit);
+
+ _shareLinkButton = new QToolButton(this);
+ connect(_shareLinkButton, &QToolButton::clicked, this, &ShareLinkWidget::slotCreateLabel);
+ _shareLinkButton->setIcon(QIcon(":/client/theme/confirm.svg"));
+ _shareLinkButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
+ _shareLinkLayout->addWidget(_shareLinkButton);
+
+ _shareLinkProgressIndicator = new QProgressIndicator(this);
+ _shareLinkProgressIndicator->setVisible(false);
+ _shareLinkLayout->addWidget(_shareLinkProgressIndicator);
+
+ _shareLinkDefaultWidget = new QWidget(this);
+ _shareLinkDefaultWidget->setLayout(_shareLinkLayout);
+
+ _shareLinkWidgetAction = new QWidgetAction(this);
+ _shareLinkWidgetAction->setDefaultWidget(_shareLinkDefaultWidget);
+ _linkContextMenu->addAction(_shareLinkWidgetAction);
// Adds permissions actions (radio button style)
if (_isFile) {
// Adds action to unshare widget (check box)
_unshareLinkAction = _linkContextMenu->addAction(QIcon(":/client/theme/delete.svg"),
- tr("Delete share link"));
+ tr("Delete link"));
_linkContextMenu->addSeparator();
}
}
-void ShareLinkWidget::slotCreateNote()
+void ShareLinkWidget::slotCreateNote()
{
setNote(_ui->textEdit_note->toPlainText());
}
deleteLater();
}
+void ShareLinkWidget::slotCreateLabel()
+{
+ if (_linkShare) {
+ slotToggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, true, true);
+ _ui->errorLabel->hide();
+ _linkShare->setLabel(_shareLinkEdit->text());
+ }
+}
+
+void ShareLinkWidget::slotLabelSet()
+{
+ slotToggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, true, false);
+ displayShareLinkLabel();
+}
+
void ShareLinkWidget::slotDeleteAnimationFinished()
{
// There is a painting bug where a small line of this widget isn't
_ui->passwordProgressIndicator->setColor(QGuiApplication::palette().color(QPalette::Text));
}
+void ShareLinkWidget::displayShareLinkLabel()
+{
+ _shareLinkElidedLabel->clear();
+ if(!_linkShare->getLabel().isEmpty()) {
+ _shareLinkElidedLabel->setText(QString("(%1)").arg(_linkShare->getLabel()));
+ }
+}
+
}
#include <QSharedPointer>
#include <QList>
#include <QToolButton>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QWidgetAction>
class QMenu;
class QTableWidgetItem;
class SyncResult;
class LinkShare;
class Share;
+class ElidedLabel;
/**
* @brief The ShareDialog class
void slotDeleteAnimationFinished();
void slotAnimationFinished();
+
+ void slotCreateLabel();
+ void slotLabelSet();
signals:
void createLinkShare();
void startAnimation(const int start, const int end);
void customizeStyle();
+
+ void displayShareLinkLabel();
Ui::ShareLinkWidget *_ui;
AccountPtr _account;
QAction *_unshareLinkAction;
QAction *_addAnotherLinkAction;
QAction *_noteLinkAction;
+ QHBoxLayout *_shareLinkLayout{};
+ QLabel *_shareLinkLabel{};
+ ElidedLabel *_shareLinkElidedLabel{};
+ QLineEdit *_shareLinkEdit{};
+ QToolButton *_shareLinkButton{};
+ QProgressIndicator *_shareLinkProgressIndicator{};
+ QWidget *_shareLinkDefaultWidget{};
+ QWidgetAction *_shareLinkWidgetAction{};
};
}
bool isPasswordSet,
const QUrl &url,
const QDate &expireDate,
- const QString ¬e)
+ const QString ¬e,
+ const QString &label)
: Share(account, id, uidowner, ownerDisplayName, path, Share::TypeLink, isPasswordSet, permissions)
, _name(name)
, _token(token)
, _note(note)
, _expireDate(expireDate)
, _url(url)
+ , _label(label)
{
}
return _note;
}
+QString LinkShare::getLabel() const
+{
+ return _label;
+}
+
void LinkShare::setName(const QString &name)
{
auto *job = new OcsShareJob(_account);
job->setExpireDate(getId(), date);
}
+void LinkShare::setLabel(const QString &label)
+{
+ auto *job = new OcsShareJob(_account);
+ connect(job, &OcsShareJob::shareJobFinished, this, &LinkShare::slotLabelSet);
+ connect(job, &OcsJob::ocsError, this, &LinkShare::slotOcsError);
+ job->setLabel(getId(), label);
+}
+
void LinkShare::slotExpireDateSet(const QJsonDocument &reply, const QVariant &value)
{
auto data = reply.object().value("ocs").toObject().value("data").toObject();
emit nameSet();
}
+void LinkShare::slotLabelSet(const QJsonDocument &, const QVariant &label)
+{
+ if (_label != label.toString()) {
+ _label = label.toString();
+ emit labelSet();
+ }
+}
+
UserGroupShare::UserGroupShare(AccountPtr account,
const QString &id,
const QString &owner,
data.value("share_with").isString(), // has password?
url,
expireDate,
- note));
+ note,
+ data.value("label").toString()));
}
QSharedPointer<Share> ShareManager::parseShare(const QJsonObject &data)
bool isPasswordSet,
const QUrl &url,
const QDate &expireDate,
- const QString ¬e);
+ const QString ¬e,
+ const QString &label);
/*
* Get the share link
* Returns the note of the link share.
*/
QString getNote() const;
+
+ /*
+ * Returns the label of the link share.
+ */
+ QString getLabel() const;
/*
* Set the name of the link share.
* In case of a server error the serverError signal is emitted.
*/
void setExpireDate(const QDate &expireDate);
-
+
+ /*
+ * Set the label of the share link.
+ */
+ void setLabel(const QString &label);
+
signals:
void expireDateSet();
void noteSet();
void nameSet();
+ void labelSet();
private slots:
void slotNoteSet(const QJsonDocument &, const QVariant &value);
void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
void slotNameSet(const QJsonDocument &, const QVariant &value);
+ void slotLabelSet(const QJsonDocument &, const QVariant &value);
private:
QString _name;
QString _note;
QDate _expireDate;
QUrl _url;
+ QString _label;
};
class UserGroupShare : public Share
private:
QString _note;
QDate _expireDate;
+ QString _label;
};
/**
<file>theme/colored/user-status-away.svg</file>
<file>theme/colored/user-status-dnd.svg</file>
<file>theme/black/email.svg</file>
+ <file>theme/black/edit.svg</file>
+ <file>theme/delete.svg</file>
</qresource>
</RCC>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ version="1.1"
+ id="svg2"
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ sodipodi:docname="edit.svg"
+ inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs6" />
+ <sodipodi:namedview
+ id="namedview4"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ showgrid="false"
+ inkscape:zoom="5.8388225"
+ inkscape:cx="39.99094"
+ inkscape:cy="20.466455"
+ inkscape:window-width="2560"
+ inkscape:window-height="1367"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g8"
+ inkscape:snap-bbox="true"
+ width="16px" />
+ <g
+ inkscape:groupmode="layer"
+ inkscape:label="Image"
+ id="g8">
+ <path
+ style="fill:#000000;stroke-width:0.237748"
+ d="m 8.0529525,14.60266 -5.533428,0.06384 -0.117155,-0.305305 -0.117156,-0.305304 0.06349,-6.2966204 0.06349,-6.2966201 4.281826,-0.064566 4.2818265,-0.064584 1.36947,1.3839101 1.36947,1.3839101 -0.06421,5.2187458 -0.06421,5.2187625 z m -1.95565,-1.84695 h 1.901987 v -0.475502 -0.475503 h -1.901987 -1.901988 v 0.475503 0.475502 z M 7.9992895,9.9027285 H 11.803266 V 9.4272255 8.9517225 H 7.9992895 4.1953145 v 0.475503 0.475503 z m -1.42649,-2.8529819 h 2.377485 v -0.475503 -0.475503 h -2.377485 -2.377485 v 0.475503 0.475503 z m 0.475496,-2.8529817 h 2.852983 V 3.721262 3.2457591 H 7.0482955 4.1953145 V 3.721262 4.1967649 Z"
+ id="path783" />
+ </g>
+</svg>