display lock info in share dialog
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 27 Apr 2022 10:56:59 +0000 (12:56 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Mon, 2 May 2022 11:52:05 +0000 (13:52 +0200)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/owncloudgui.cpp
src/gui/sharedialog.cpp
src/gui/sharedialog.h
src/gui/sharedialog.ui

index 3941d9b0f3ecc038c5fb750654468bc2910085a2..d21a7446b079468051a30df586b8ee7cc3956b63 100644 (file)
@@ -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;
index 6e48b70bea1b78cf38a312813b6b58621faf7a55..95fca99e65be02cc82775cbd43ee2377a8a998c5 100644 (file)
@@ -59,6 +59,7 @@ ShareDialog::ShareDialog(QPointer<AccountState> 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> 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> 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<int>(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());
 
index 7b4aade18863b39a97d86e4bfcd8525e5cbd0da5..c9309775f3bf4eb9d28229fe1b06025426716e66 100644 (file)
@@ -18,6 +18,7 @@
 #include "accountstate.h"
 #include "sharepermissions.h"
 #include "owncloudgui.h"
+#include "common/syncjournalfilerecord.h"
 
 #include <QSharedPointer>
 #include <QPointer>
@@ -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;
index e90458dbceeee444c7ba34ad37680c5ea94c9e98..ea480abee17ae39965d0c9203e7cf5333028b521 100644 (file)
          </property>
         </widget>
        </item>
-       <item row="1" column="1">
+       <item row="2" column="1">
         <widget class="QLabel" name="label_sharePath">
          <property name="sizePolicy">
           <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
          </property>
         </widget>
        </item>
+       <item row="1" column="1">
+        <widget class="QLabel" name="label_lockinfo">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>315</width>
+           <height>0</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>TextLabel</string>
+         </property>
+         <property name="textFormat">
+          <enum>Qt::PlainText</enum>
+         </property>
+         <property name="wordWrap">
+          <bool>true</bool>
+         </property>
+        </widget>
+       </item>
       </layout>
      </item>
      <item>