Browse Source

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

Source commit: 70affcfc8fc47532e06ec9a9fead8a4d9d73c01e
Martin Prikryl 7 years ago
parent
commit
81a279f9a7
1 changed files with 17 additions and 13 deletions
  1. 17 13
      source/windows/TerminalManager.cpp

+ 17 - 13
source/windows/TerminalManager.cpp

@@ -701,26 +701,30 @@ UnicodeString __fastcall TTerminalManager::GetAppProgressTitle()
 //---------------------------------------------------------------------------
 void __fastcall TTerminalManager::UpdateAppTitle()
 {
-  if (ScpExplorer) // We should better check for GetMainForm() here
+  if (ScpExplorer)
   {
     TForm * MainForm = GetMainForm();
-    if (MainForm->Perform(WM_MANAGES_CAPTION, 0, 0) == 0)
+    if (MainForm != ScpExplorer)
     {
-      UnicodeString NewTitle = FormatMainFormCaption(GetActiveTerminalTitle(false));
+      // triggers caption update for some forms
+      MainForm->Perform(WM_MANAGES_CAPTION, 0, 0);
+    }
 
-      UnicodeString ProgressTitle = GetAppProgressTitle();
-      if (!ProgressTitle.IsEmpty())
-      {
-        NewTitle = ProgressTitle + NewTitle;
-      }
-      else if (ActiveTerminal && (ScpExplorer != NULL))
-      {
-        AddToList(NewTitle, ScpExplorer->PathForCaption(), L" - ");
-      }
+    UnicodeString NewTitle = FormatMainFormCaption(GetActiveTerminalTitle(false));
 
-      MainForm->Caption = NewTitle;
+    UnicodeString ProgressTitle = GetAppProgressTitle();
+    if (!ProgressTitle.IsEmpty())
+    {
+      NewTitle = ProgressTitle + NewTitle;
+    }
+    else if (ActiveTerminal && (ScpExplorer != NULL))
+    {
+      AddToList(NewTitle, ScpExplorer->PathForCaption(), L" - ");
     }
 
+    // Not updating MainForm here, as for all other possible main forms, this code is actually not what we want.
+    // And they all update their title on their own (some using GetAppProgressTitle()).
+    ScpExplorer->Caption = NewTitle;
     ScpExplorer->ApplicationTitleChanged();
   }
 }