Browse Source

Bug 1370: Show a command of a custom command in status bar

https://winscp.net/tracker/1370

Source commit: c43262a1cab8204dc03eacb8001bbfd1be69ca22
Martin Prikryl 10 years ago
parent
commit
e538d3ab84

+ 2 - 1
source/forms/CustomScpExplorer.cpp

@@ -4138,7 +4138,8 @@ void __fastcall TCustomScpExplorerForm::UserActionTimer(TObject * /*Sender*/)
 void __fastcall TCustomScpExplorerForm::ApplicationHint(TObject * /*Sender*/)
 {
   DebugAssert(Application);
-  UnicodeString AHint = GetLongHint(Application->Hint);
+  // Application->Hint contains long hint only
+  UnicodeString AHint = Application->Hint;
   FShowStatusBarHint = Active && !AHint.IsEmpty();
   if (FShowStatusBarHint)
   {

+ 2 - 1
source/forms/Editor.cpp

@@ -1575,7 +1575,8 @@ void __fastcall TEditorForm::Reload()
 void __fastcall TEditorForm::ApplicationHint(TObject * /*Sender*/)
 {
   DebugAssert(Application);
-  UnicodeString AHint = GetLongHint(Application->Hint);
+  // Application->Hint contains long hint only
+  UnicodeString AHint = Application->Hint;
   FShowStatusBarHint = Active && !AHint.IsEmpty();
   if (FShowStatusBarHint)
   {

+ 30 - 8
source/forms/NonVisual.cpp

@@ -1015,6 +1015,25 @@ void __fastcall TNonVisualDataModule::DoIdle()
   }
 }
 //---------------------------------------------------------------------------
+UnicodeString __fastcall TNonVisualDataModule::CustomCommandCaption(const TCustomCommandType * Command, bool Toolbar)
+{
+  UnicodeString Result = Command->Name;
+  if (Toolbar)
+  {
+    Result = EscapeHotkey(StripHotkey(Result));
+  }
+  return Result;
+}
+//---------------------------------------------------------------------------
+UnicodeString __fastcall TNonVisualDataModule::CustomCommandHint(const TCustomCommandType * Command)
+{
+  UnicodeString Name = StripHotkey(Command->Name);
+  UnicodeString ShortHint = FMTLOAD(CUSTOM_COMMAND_HINT, (Name));
+  UnicodeString LongHint = FMTLOAD(CUSTOM_COMMAND_HINT_LONG, (Name, Command->Command));
+  UnicodeString Result = FORMAT(L"%s|%s", (ShortHint, LongHint));
+  return Result;
+}
+//---------------------------------------------------------------------------
 void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
   TTBCustomItem * Menu, bool OnFocused, bool Toolbar, bool Both)
 {
@@ -1035,11 +1054,7 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
     if (State >= 0)
     {
       TTBCustomItem * Item = new TTBXItem(Owner);
-      Item->Caption = Command->Name;
-      if (Toolbar)
-      {
-        Item->Caption = EscapeHotkey(StripHotkey(Item->Caption));
-      }
+      Item->Caption = CustomCommandCaption(Command, Toolbar);
       Item->Tag = Index;
       Item->Enabled = (State > 0);
       if (OnFocused)
@@ -1050,7 +1065,10 @@ void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
       {
         Item->Tag = Item->Tag | 0x0200;
       }
-      Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Command->Name)));
+      UnicodeString Name = StripHotkey(Command->Name);
+      UnicodeString ShortHint = FMTLOAD(CUSTOM_COMMAND_HINT, (Name));
+      UnicodeString LongHint = FMTLOAD(CUSTOM_COMMAND_HINT_LONG, (Name, Command->Command));
+      Item->Hint = FORMAT(L"%s|%s", (ShortHint, LongHint));
       if (!Both)
       {
         Item->ShortCut = Command->ShortCut;
@@ -1136,9 +1154,13 @@ void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar *
     int Index = 0;
     while (!Changed && (Index < CustomCommandList->Count))
     {
+      TTBCustomItem * Item = Toolbar->Items->Items[Index];
+      const TCustomCommandType * Command = CustomCommandList->Commands[Index];
+
       Changed =
-        (Toolbar->Items->Items[Index]->Caption !=
-          EscapeHotkey(StripHotkey(CustomCommandList->Commands[Index]->Name)));
+        (Item->Caption != CustomCommandCaption(Command, true)) ||
+        (Item->Hint != CustomCommandHint(Command));
+
       Index++;
     }
   }

+ 2 - 0
source/forms/NonVisual.h

@@ -626,6 +626,8 @@ __published:    // IDE-managed Components
   void __fastcall EditMenuItemPopup(TTBCustomItem *Sender, bool FromLink);
   void __fastcall QueuePopupSpeedComboBoxItemAdjustImageIndex(TTBXComboBoxItem *Sender,
           const UnicodeString AText, int AIndex, int &ImageIndex);
+  UnicodeString __fastcall CustomCommandCaption(const TCustomCommandType * Command, bool Toolbar);
+  UnicodeString __fastcall CustomCommandHint(const TCustomCommandType * Command);
 
 private:
   TListColumn * FListColumn;

+ 1 - 0
source/resource/TextsWin.h

@@ -551,6 +551,7 @@
 #define GENERATE_URL_COMMAND    1954
 #define TIPS_MESSAGE            1955
 #define TIPS_TITLE              1956
+#define CUSTOM_COMMAND_HINT_LONG 1957
 
 // 2xxx is reserved for TextsFileZilla.h
 

+ 1 - 0
source/resource/TextsWin1.rc

@@ -555,6 +555,7 @@ BEGIN
         GENERATE_URL_COMMAND, "Your command %d"
         TIPS_MESSAGE, "Tip %d of %d"
         TIPS_TITLE, "Tips"
+        CUSTOM_COMMAND_HINT_LONG, "Execute custom command '%s' as '%s'"
 
         WIN_VARIABLE_STRINGS, "WIN_VARIABLE"
         WINSCP_COPYRIGHT, "Copyright © 2000-2015 Martin Prikryl"