Display both files and some metadata in the case clash conflict resolution dialog
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 14 Dec 2022 19:17:24 +0000 (20:17 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 25 Jan 2023 15:37:36 +0000 (16:37 +0100)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/caseclashfilenamedialog.cpp
src/gui/caseclashfilenamedialog.ui

index ba4eedeab4922f01ce04b337035f30af41f93e0f..827e537e2cf7b5fdbc2567a35b3052645ce98563 100644 (file)
@@ -76,17 +76,19 @@ CaseClashFilenameDialog::CaseClashFilenameDialog(AccountPtr account,
     , _conflictSolver(conflictFilePath, conflictTaggedPath, folder->remotePath(), folder->path(), account, folder->journalDb())
     , _account(account)
     , _folder(folder)
-    , _filePath(std::move(filePath))
+    , _filePath(std::move(conflictFilePath))
 {
     Q_ASSERT(_account);
     Q_ASSERT(_folder);
 
     const auto filePathFileInfo = QFileInfo(_filePath);
+    const auto conflictFileName = filePathFileInfo.fileName();
+
     _relativeFilePath = filePathFileInfo.path() + QStringLiteral("/");
     _relativeFilePath = _relativeFilePath.replace(folder->path(), QLatin1String());
     _relativeFilePath = _relativeFilePath.isEmpty() ? QString() : _relativeFilePath + QStringLiteral("/");
 
-    _originalFileName = _relativeFilePath + filePathFileInfo.fileName();
+    _originalFileName = _relativeFilePath + conflictFileName;
 
     _ui->setupUi(this);
     _ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
@@ -94,11 +96,37 @@ CaseClashFilenameDialog::CaseClashFilenameDialog(AccountPtr account,
 
     _ui->descriptionLabel->setText(tr("The file \"%1\" could not be synced because of a case clash conflict with an existing file on this system.").arg(_originalFileName));
     _ui->explanationLabel->setText(tr("%1 does not support equal file names with only letter casing differences.").arg(QSysInfo::prettyProductName()));
-    _ui->filenameLineEdit->setText(filePathFileInfo.fileName());
+    _ui->filenameLineEdit->setText(conflictFileName);
+
+    const auto preexistingConflictingFile = caseClashConflictFile(_filePath);
+    updateFileWidgetGroup(preexistingConflictingFile,
+                          tr("Open local version"),
+                          _ui->localVersionFilename,
+                          _ui->localVersionLink,
+                          _ui->localVersionMtime,
+                          _ui->localVersionSize,
+                          _ui->localVersionButton);
+
+    updateFileWidgetGroup(conflictTaggedPath,
+                          tr("Open server version"),
+                          _ui->remoteVersionFilename,
+                          _ui->remoteVersionLink,
+                          _ui->remoteVersionMtime,
+                          _ui->remoteVersionSize,
+                          _ui->remoteVersionButton);
+    // Display incoming conflict filename, not conflict-tagged filename
+    _ui->remoteVersionFilename->setText(filePathFileInfo.fileName());
+
     adjustSize();
 
     connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
     connect(_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
+    connect(_ui->localVersionButton, &QToolButton::clicked, this, [preexistingConflictingFile] {
+        QDesktopServices::openUrl(QUrl::fromLocalFile(preexistingConflictingFile));
+    });
+    connect(_ui->remoteVersionButton, &QToolButton::clicked, this, [conflictTaggedPath] {
+        QDesktopServices::openUrl(QUrl::fromLocalFile(conflictTaggedPath));
+    });
 
     _ui->errorLabel->setText({}/*
         tr("Checking rename permissions …")*/);
index 07accfeb63d2da877845ed73eb9f941d87df050c..17eb96d7499cea13d85331b877f93aa42fc14f62 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>658</width>
-    <height>192</height>
+    <width>553</width>
+    <height>349</height>
    </rect>
   </property>
   <property name="windowTitle">
      </property>
     </widget>
    </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>Local case clash file</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="localVersionFilename">
+         <property name="text">
+          <string>fileA</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_3">
+         <item>
+          <layout class="QVBoxLayout" name="verticalLayout_4">
+           <property name="sizeConstraint">
+            <enum>QLayout::SetDefaultConstraint</enum>
+           </property>
+           <item>
+            <widget class="QToolButton" name="localVersionButton">
+             <property name="text">
+              <string/>
+             </property>
+             <property name="iconSize">
+              <size>
+               <width>64</width>
+               <height>64</height>
+              </size>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <spacer name="verticalSpacer">
+             <property name="orientation">
+              <enum>Qt::Vertical</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>20</width>
+               <height>40</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <layout class="QVBoxLayout" name="verticalLayout_5" stretch="0,0,0,1">
+           <property name="sizeConstraint">
+            <enum>QLayout::SetDefaultConstraint</enum>
+           </property>
+           <item>
+            <widget class="QLabel" name="localVersionMtime">
+             <property name="text">
+              <string>today</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="localVersionSize">
+             <property name="text">
+              <string>0 byte</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="localVersionLink">
+             <property name="text">
+              <string>Open original version</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <spacer name="verticalSpacer_2">
+             <property name="orientation">
+              <enum>Qt::Vertical</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>20</width>
+               <height>40</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType">
+            <enum>QSizePolicy::Expanding</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_6">
+       <item>
+        <widget class="QLabel" name="label_5">
+         <property name="text">
+          <string>Server case clash file</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="remoteVersionFilename">
+         <property name="text">
+          <string>fileB</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout_4">
+         <item>
+          <layout class="QVBoxLayout" name="verticalLayout_7">
+           <item>
+            <widget class="QToolButton" name="remoteVersionButton">
+             <property name="text">
+              <string/>
+             </property>
+             <property name="iconSize">
+              <size>
+               <width>64</width>
+               <height>64</height>
+              </size>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <spacer name="verticalSpacer_3">
+             <property name="orientation">
+              <enum>Qt::Vertical</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>20</width>
+               <height>40</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <layout class="QVBoxLayout" name="verticalLayout_8" stretch="0,0,0,1">
+           <item>
+            <widget class="QLabel" name="remoteVersionMtime">
+             <property name="text">
+              <string>today</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="remoteVersionSize">
+             <property name="text">
+              <string>0 byte</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="remoteVersionLink">
+             <property name="text">
+              <string>Open incoming conflict version</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <spacer name="verticalSpacer_4">
+             <property name="orientation">
+              <enum>Qt::Vertical</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>20</width>
+               <height>40</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer_2">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
    <item>
     <widget class="QLabel" name="label">
      <property name="text">