From: Matthieu Gallien Date: Wed, 27 Apr 2022 10:56:59 +0000 (+0200) Subject: display lock info in share dialog X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~42^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=702e9abe4b9110103557b06587836cbaa4609c75;p=nextcloud-desktop.git display lock info in share dialog Signed-off-by: Matthieu Gallien --- diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 3941d9b0f..d21a7446b 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -639,7 +639,7 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l w = _shareDialogs[localPath]; } else { qCInfo(lcApplication) << "Opening share dialog" << sharePath << localPath << maxSharingPermissions; - w = new ShareDialog(accountState, sharePath, localPath, maxSharingPermissions, fileRecord.numericFileId(), startPage); + w = new ShareDialog(accountState, sharePath, localPath, maxSharingPermissions, fileRecord.numericFileId(), fileRecord._lockstate, startPage); w->setAttribute(Qt::WA_DeleteOnClose, true); _shareDialogs[localPath] = w; diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp index 6e48b70be..95fca99e6 100644 --- a/src/gui/sharedialog.cpp +++ b/src/gui/sharedialog.cpp @@ -59,6 +59,7 @@ ShareDialog::ShareDialog(QPointer accountState, const QString &localPath, SharePermissions maxSharingPermissions, const QByteArray &numericFileId, + SyncJournalFileLockInfo filelockState, ShareDialogStartPage startPage, QWidget *parent) : QDialog(parent) @@ -67,6 +68,7 @@ ShareDialog::ShareDialog(QPointer accountState, , _sharePath(sharePath) , _localPath(localPath) , _maxSharingPermissions(maxSharingPermissions) + , _filelockState(std::move(filelockState)) , _privateLinkUrl(accountState->account()->deprecatedPrivateLinkUrl(numericFileId).toString(QUrl::FullyEncoded)) , _startPage(startPage) { @@ -95,6 +97,14 @@ ShareDialog::ShareDialog(QPointer accountState, f.setPointSize(qRound(f.pointSize() * 1.4)); _ui->label_name->setFont(f); + if (_filelockState._locked) { + static constexpr auto SECONDS_PER_MINUTE = 60; + const auto lockExpirationTime = _filelockState._lockTime + _filelockState._lockTimeout; + const auto remainingTime = QDateTime::currentDateTime().secsTo(QDateTime::fromSecsSinceEpoch(lockExpirationTime)); + const auto remainingTimeInMinute = static_cast(remainingTime > 0 ? remainingTime / SECONDS_PER_MINUTE : 0); + _ui->label_lockinfo->setText(tr("Locked by %1 - Expire in %2 minutes", "remaining time before lock expire", remainingTimeInMinute).arg(_filelockState._lockOwnerDisplayName).arg(remainingTimeInMinute)); + } + QString ocDir(_sharePath); ocDir.truncate(ocDir.length() - fileName.length()); diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index 7b4aade18..c9309775f 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -18,6 +18,7 @@ #include "accountstate.h" #include "sharepermissions.h" #include "owncloudgui.h" +#include "common/syncjournalfilerecord.h" #include #include @@ -51,6 +52,7 @@ public: const QString &localPath, SharePermissions maxSharingPermissions, const QByteArray &numericFileId, + SyncJournalFileLockInfo filelockState, ShareDialogStartPage startPage, QWidget *parent = nullptr); ~ShareDialog() override; @@ -91,6 +93,7 @@ private: QString _localPath; SharePermissions _maxSharingPermissions; QByteArray _numericFileId; + SyncJournalFileLockInfo _filelockState; QString _privateLinkUrl; ShareDialogStartPage _startPage; ShareManager *_manager = nullptr; diff --git a/src/gui/sharedialog.ui b/src/gui/sharedialog.ui index e90458dbc..ea480abee 100644 --- a/src/gui/sharedialog.ui +++ b/src/gui/sharedialog.ui @@ -101,7 +101,7 @@ - + @@ -132,6 +132,31 @@ + + + + + 0 + 0 + + + + + 315 + 0 + + + + TextLabel + + + Qt::PlainText + + + true + + +