mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Show user/group note on share if already set
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
This commit is contained in:
parent
22a3b19e08
commit
2851528595
3 changed files with 30 additions and 7 deletions
|
@ -286,9 +286,11 @@ UserGroupShare::UserGroupShare(AccountPtr account,
|
|||
const ShareType shareType,
|
||||
const Permissions permissions,
|
||||
const QSharedPointer<Sharee> shareWith,
|
||||
const QDate &expireDate)
|
||||
const QDate &expireDate,
|
||||
const QString ¬e)
|
||||
: Share(account, id, owner, ownerDisplayName, path, shareType, permissions, shareWith)
|
||||
, _expireDate(expireDate)
|
||||
, _note(note)
|
||||
{
|
||||
Q_ASSERT(shareType == TypeUser || shareType == TypeGroup);
|
||||
Q_ASSERT(shareWith);
|
||||
|
@ -302,6 +304,11 @@ void UserGroupShare::setNote(const QString ¬e)
|
|||
job->setNote(getId(), note);
|
||||
}
|
||||
|
||||
QString UserGroupShare::getNote() const
|
||||
{
|
||||
return _note;
|
||||
}
|
||||
|
||||
void UserGroupShare::slotNoteSet(const QJsonDocument &, const QVariant ¬e)
|
||||
{
|
||||
_note = note.toString();
|
||||
|
@ -473,6 +480,11 @@ QSharedPointer<UserGroupShare> ShareManager::parseUserGroupShare(const QJsonObje
|
|||
expireDate = QDate::fromString(data.value("expiration").toString(), "yyyy-MM-dd 00:00:00");
|
||||
}
|
||||
|
||||
QString note;
|
||||
if (data.value("note").isString()) {
|
||||
note = data.value("note").toString();
|
||||
}
|
||||
|
||||
return QSharedPointer<UserGroupShare>(new UserGroupShare(_account,
|
||||
data.value("id").toVariant().toString(), // "id" used to be an integer, support both
|
||||
data.value("uid_owner").toVariant().toString(),
|
||||
|
@ -481,7 +493,8 @@ QSharedPointer<UserGroupShare> ShareManager::parseUserGroupShare(const QJsonObje
|
|||
static_cast<Share::ShareType>(data.value("share_type").toInt()),
|
||||
static_cast<Share::Permissions>(data.value("permissions").toInt()),
|
||||
sharee,
|
||||
expireDate));
|
||||
expireDate,
|
||||
note));
|
||||
}
|
||||
|
||||
QSharedPointer<LinkShare> ShareManager::parseLinkShare(const QJsonObject &data)
|
||||
|
|
|
@ -271,10 +271,13 @@ public:
|
|||
const ShareType shareType,
|
||||
const Permissions permissions,
|
||||
const QSharedPointer<Sharee> shareWith,
|
||||
const QDate &expireDate);
|
||||
const QDate &expireDate,
|
||||
const QString ¬e);
|
||||
|
||||
void setNote(const QString ¬e);
|
||||
|
||||
QString getNote() const;
|
||||
|
||||
void slotNoteSet(const QJsonDocument &, const QVariant ¬e);
|
||||
|
||||
void setExpireDate(const QDate &date);
|
||||
|
|
|
@ -461,13 +461,17 @@ ShareUserLine::ShareUserLine(QSharedPointer<UserGroupShare> share,
|
|||
_noteLinkAction->setCheckable(true);
|
||||
menu->addAction(_noteLinkAction);
|
||||
connect(_noteLinkAction, &QAction::triggered, this, &ShareUserLine::toggleNoteOptions);
|
||||
if (!_share->getNote().isEmpty()) {
|
||||
_noteLinkAction->setChecked(true);
|
||||
toggleNoteOptions(true);
|
||||
}
|
||||
|
||||
toggleExpireDateOptions(false);
|
||||
_expirationDateLinkAction = new QAction(tr("Set expiration date"));
|
||||
_expirationDateLinkAction->setCheckable(true);
|
||||
menu->addAction(_expirationDateLinkAction);
|
||||
connect(_expirationDateLinkAction, &QAction::triggered, this, &ShareUserLine::toggleExpireDateOptions);
|
||||
const auto expireDate = _share.data()->getExpireDate().isValid() ? share.data()->getExpireDate() : QDate();
|
||||
const auto expireDate = _share->getExpireDate().isValid() ? share.data()->getExpireDate() : QDate();
|
||||
if (!expireDate.isNull()) {
|
||||
_ui->calendar->setDate(expireDate);
|
||||
_expirationDateLinkAction->setChecked(true);
|
||||
|
@ -758,13 +762,18 @@ void ShareUserLine::toggleNoteOptions(bool enable)
|
|||
showNoteOptions(enable);
|
||||
|
||||
if (enable) {
|
||||
const auto note = _share->getNote();
|
||||
if (!note.isEmpty()) {
|
||||
_ui->noteTextEdit->setText(note);
|
||||
}
|
||||
_ui->noteTextEdit->setFocus();
|
||||
} else {
|
||||
// 'deletes' note
|
||||
if (_share)
|
||||
if (_share) {
|
||||
_share->setNote(QString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShareUserLine::onNoteConfirmButtonClicked()
|
||||
{
|
||||
|
@ -774,8 +783,6 @@ void ShareUserLine::onNoteConfirmButtonClicked()
|
|||
void ShareUserLine::setNote(const QString ¬e)
|
||||
{
|
||||
if (_share) {
|
||||
// slotToggleAnimation(true);
|
||||
// _ui->errorLabel->hide();
|
||||
_share->setNote(note);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue