Browse Source

Operation status is shown on task bar button and tray icon title also for command-line operations (2nd)

Source commit: 7d680835b3b6ddcc0b74d71ef6ff508eb10682e0
Martin Prikryl 7 years ago
parent
commit
dd9b68101d

+ 4 - 0
source/forms/Progress.cpp

@@ -654,6 +654,10 @@ void __fastcall TProgressForm::Dispatch(void * AMessage)
   {
     CMDialogKey(reinterpret_cast<TCMDialogKey &>(Message));
   }
+  else if (Message.Msg == WM_MANAGES_CAPTION)
+  {
+    Message.Result = 1;
+  }
   else
   {
     TForm::Dispatch(AMessage);

+ 25 - 11
source/forms/SynchronizeChecklist.cpp

@@ -17,6 +17,7 @@
 #include <Math.hpp>
 #include <WinConfiguration.h>
 #include <GUITools.h>
+#include <TerminalManager.h>
 //---------------------------------------------------------------------
 #pragma link "IEListView"
 #pragma link "NortonLikeListView"
@@ -118,9 +119,16 @@ bool __fastcall TSynchronizeChecklistDialog::Execute(TSynchronizeChecklist * Che
   return Result;
 }
 //---------------------------------------------------------------------
+void __fastcall TSynchronizeChecklistDialog::UpdateCaption()
+{
+  TTerminalManager * Manager = TTerminalManager::Instance();
+  UnicodeString Title = Manager->GetAppProgressTitle() + LoadStr(FSynchronizing ? SYNCHRONIZE_PROGRESS_SYNCHRONIZE2 : SYNCHRONIZE_CHECKLIST_CAPTION);
+  Caption = FormatFormCaption(this, Title);
+}
+//---------------------------------------------------------------------
 void __fastcall TSynchronizeChecklistDialog::UpdateControls()
 {
-  Caption = FormatFormCaption(this, LoadStr(FSynchronizing ? SYNCHRONIZE_PROGRESS_SYNCHRONIZE2 : SYNCHRONIZE_CHECKLIST_CAPTION));
+  UpdateCaption();
 
   StatusBar->Invalidate();
 
@@ -1020,27 +1028,33 @@ void __fastcall TSynchronizeChecklistDialog::ListViewClick(TObject * /*Sender*/)
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TSynchronizeChecklistDialog::Dispatch(void * Message)
+void __fastcall TSynchronizeChecklistDialog::Dispatch(void * AMessage)
 {
-  TMessage * M = reinterpret_cast<TMessage*>(Message);
-  if (M->Msg == WM_SYSCOMMAND)
+  TMessage & Message = *reinterpret_cast<TMessage *>(AMessage);
+  if (Message.Msg == WM_SYSCOMMAND)
   {
-    if (!HandleMinimizeSysCommand(*M))
+    if (!HandleMinimizeSysCommand(Message))
     {
-      TForm::Dispatch(Message);
+      TForm::Dispatch(AMessage);
     }
   }
-  else if (M->Msg == CM_DPICHANGED)
+  else if (Message.Msg == CM_DPICHANGED)
+  {
+    CMDpiChanged(Message);
+  }
+  else if (Message.Msg == WM_WANTS_MOUSEWHEEL_INACTIVE)
   {
-    CMDpiChanged(*M);
+    Message.Result = FSynchronizing ? 1 : 0;
   }
-  else if (M->Msg == WM_WANTS_MOUSEWHEEL_INACTIVE)
+  else if (Message.Msg == WM_MANAGES_CAPTION)
   {
-    M->Result = FSynchronizing ? 1 : 0;
+    // calling UpdateControls would cause status bar flicker
+    UpdateCaption();
+    Message.Result = 1;
   }
   else
   {
-    TForm::Dispatch(Message);
+    TForm::Dispatch(AMessage);
   }
 }
 //---------------------------------------------------------------------------

+ 1 - 0
source/forms/SynchronizeChecklist.h

@@ -127,6 +127,7 @@ protected:
   std::map<const TSynchronizeChecklist::TItem *, TListItem *> FChecklistToListViewMap;
 
   void __fastcall UpdateControls();
+  void __fastcall UpdateCaption();
   virtual void __fastcall CreateParams(TCreateParams & Params);
   void __fastcall LoadItem(TListItem * Item);
   void __fastcall LoadList();

+ 41 - 20
source/windows/TerminalManager.cpp

@@ -673,33 +673,54 @@ bool __fastcall TTerminalManager::ShouldDisplayQueueStatusOnAppTitle()
   return Result;
 }
 //---------------------------------------------------------------------------
+UnicodeString __fastcall TTerminalManager::GetAppProgressTitle()
+{
+  UnicodeString Result;
+  UnicodeString QueueProgressTitle;
+  UnicodeString ProgressTitle = !FProgressTitle.IsEmpty() ? FProgressTitle : ScpExplorer->GetProgressTitle();
+  if (!FForegroundProgressTitle.IsEmpty())
+  {
+    Result = FForegroundProgressTitle;
+  }
+  else if (!ProgressTitle.IsEmpty() && !ForegroundTask())
+  {
+    Result = ProgressTitle;
+  }
+  else if (ShouldDisplayQueueStatusOnAppTitle() &&
+           !(QueueProgressTitle = ScpExplorer->GetQueueProgressTitle()).IsEmpty())
+  {
+    Result = QueueProgressTitle;
+  }
+
+  if (!Result.IsEmpty())
+  {
+    Result += L" - ";
+  }
+  return Result;
+}
+//---------------------------------------------------------------------------
 void __fastcall TTerminalManager::UpdateAppTitle()
 {
   if (ScpExplorer) // We should better check for GetMainForm() here
   {
-    UnicodeString NewTitle = FormatMainFormCaption(GetActiveTerminalTitle(false));
-
-    UnicodeString QueueProgressTitle;
-    UnicodeString ProgressTitle = !FProgressTitle.IsEmpty() ? FProgressTitle : ScpExplorer->GetProgressTitle();
-    if (!FForegroundProgressTitle.IsEmpty())
-    {
-      NewTitle = FForegroundProgressTitle + L" - " + NewTitle;
-    }
-    else if (!ProgressTitle.IsEmpty() && !ForegroundTask())
-    {
-      NewTitle = ProgressTitle + L" - " + NewTitle;
-    }
-    else if (ShouldDisplayQueueStatusOnAppTitle() &&
-             !(QueueProgressTitle = ScpExplorer->GetQueueProgressTitle()).IsEmpty())
-    {
-      NewTitle = QueueProgressTitle + L" - " + NewTitle;
-    }
-    else if (ActiveTerminal && (ScpExplorer != NULL))
+    TForm * MainForm = GetMainForm();
+    if (MainForm->Perform(WM_MANAGES_CAPTION, 0, 0) == 0)
     {
-      AddToList(NewTitle, ScpExplorer->PathForCaption(), L" - ");
+      UnicodeString NewTitle = FormatMainFormCaption(GetActiveTerminalTitle(false));
+
+      UnicodeString ProgressTitle = GetAppProgressTitle();
+      if (!ProgressTitle.IsEmpty())
+      {
+        NewTitle = ProgressTitle + NewTitle;
+      }
+      else if (ActiveTerminal && (ScpExplorer != NULL))
+      {
+        AddToList(NewTitle, ScpExplorer->PathForCaption(), L" - ");
+      }
+
+      MainForm->Caption = NewTitle;
     }
 
-    GetMainForm()->Caption = NewTitle;
     ScpExplorer->ApplicationTitleChanged();
   }
 }

+ 1 - 0
source/windows/TerminalManager.h

@@ -57,6 +57,7 @@ public:
   UnicodeString __fastcall GetTerminalShortPath(TTerminal * Terminal);
   UnicodeString __fastcall GetTerminalTitle(TTerminal * Terminal, bool Unique);
   UnicodeString __fastcall GetActiveTerminalTitle(bool Unique);
+  UnicodeString __fastcall GetAppProgressTitle();
   void __fastcall HandleException(Exception * E);
   void __fastcall SaveWorkspace(TList * DataList);
   void __fastcall QueueStatusUpdated();