Browse Source

When performing a single-item atomic operation, displaying indeterminate progress status

Source commit: 7660ff1a00ed78dd9321dfe64c42108fc56db09f
Martin Prikryl 4 years ago
parent
commit
9886e9f4d6

+ 7 - 0
source/core/FileOperationProgress.cpp

@@ -982,3 +982,10 @@ void __fastcall TFileOperationProgressType::Restore(TPersistence & Persistence)
   FPersistence = Persistence;
   FRestored = true;
 }
+//---------------------------------------------------------------------------
+bool TFileOperationProgressType::IsIndeterminate() const
+{
+  return
+    IsIndeterminateOperation(FOperation) ||
+    (!TotalSizeSet && (FCount == 1));
+}

+ 1 - 0
source/core/FileOperationProgress.h

@@ -227,6 +227,7 @@ public:
   UnicodeString __fastcall GetLogStr(bool Done);
   void __fastcall Store(TPersistence & Persistence);
   void __fastcall Restore(TPersistence & Persistence);
+  bool IsIndeterminate() const;
 
   static bool IsIndeterminateOperation(TFileOperation Operation);
 };

+ 1 - 1
source/forms/CustomScpExplorer.cpp

@@ -911,7 +911,7 @@ void __fastcall TCustomScpExplorerForm::SetTaskbarListProgressValue(TFileOperati
   {
     OverallProgress = FProgressForm->SynchronizeProgress->Progress(ProgressData);
   }
-  else if (!TFileOperationProgressType::IsIndeterminateOperation(ProgressData->Operation))
+  else if (!ProgressData->IsIndeterminate())
   {
     OverallProgress = ProgressData->OverallProgress();
   }

+ 19 - 3
source/forms/Progress.cpp

@@ -28,6 +28,21 @@
 #pragma link "TBXExtItems"
 #pragma resource "*.dfm"
 //---------------------------------------------------------------------
+static IsIndeterminate(const TSynchronizeProgress * SynchronizeProgress, const TFileOperationProgressType * ProgressData)
+{
+  bool Result;
+  // TSynchronizeProgress has its own way how to take atomic operations into account
+  if (SynchronizeProgress != NULL)
+  {
+    Result = TFileOperationProgressType::IsIndeterminateOperation(ProgressData->Operation);
+  }
+  else
+  {
+    Result = ProgressData->IsIndeterminate();
+  }
+  return Result;
+}
+//---------------------------------------------------------------------
 UnicodeString __fastcall TProgressForm::ProgressStr(
   const TSynchronizeProgress * SynchronizeProgress, const TFileOperationProgressType * ProgressData)
 {
@@ -51,7 +66,7 @@ UnicodeString __fastcall TProgressForm::ProgressStr(
   {
     Result = LoadStr(SYNCHRONIZE_PROGRESS_SYNCHRONIZE2) + TitleSeparator + Result;
   }
-  if (!TFileOperationProgressType::IsIndeterminateOperation(ProgressData->Operation))
+  if (!IsIndeterminate(SynchronizeProgress, ProgressData))
   {
     int OverallProgress;
     if (SynchronizeProgress != NULL)
@@ -134,6 +149,7 @@ void __fastcall TProgressForm::UpdateControls()
 
   bool TransferOperation =
     ((FData.Operation == foCopy) || (FData.Operation == foMove));
+  bool Indeterminate = IsIndeterminate(SynchronizeProgress, &FData);
 
   CancelItem->Enabled = !FReadOnly && (FCancel < csCancel);
   SkipItem->Visible = TransferOperation && FAllowSkip;
@@ -221,7 +237,7 @@ void __fastcall TProgressForm::UpdateControls()
 
     CancelItem->Caption = CancelCaption;
 
-    OperationProgress->Style = TFileOperationProgressType::IsIndeterminateOperation(FData.Operation) ? pbstMarquee : pbstNormal;
+    OperationProgress->Style = Indeterminate ? pbstMarquee : pbstNormal;
 
     if (SynchronizeProgress != NULL)
     {
@@ -292,7 +308,7 @@ void __fastcall TProgressForm::UpdateControls()
   int OverallProgress;
   // as a side effect this prevents calling TSynchronizeProgress::Progress when we do not know total size yet
   // (what would cache wrong values forever)
-  if (TFileOperationProgressType::IsIndeterminateOperation(FData.Operation))
+  if (Indeterminate)
   {
     OverallProgress = -1;
   }