Browse Source

Issue 2202: Optionally do not shorten tab titles

https://winscp.net/tracker/2202

Source commit: dc2184c2e1fcfb78845540877ff857ace08659ef
Martin Prikryl 1 year ago
parent
commit
605a81c973

+ 18 - 3
source/forms/CustomScpExplorer.cpp

@@ -1217,6 +1217,11 @@ void __fastcall TCustomScpExplorerForm::ConfigurationChanged()
     FFileColorsCurrent = WinConfiguration->FileColors;
     FileColorsChanged();
   }
+
+  if (GetNewTabTab()->CaptionTruncation != GetNewTabTabCaptionTruncation())
+  {
+    SessionListChanged();
+  }
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::DoFileColorsChanged(TCustomDirView * DirView)
@@ -7363,7 +7368,7 @@ void __fastcall TCustomScpExplorerForm::SessionListChanged(bool ForceTruncationU
       {
         TTerminal * Terminal = Manager->Sessions[Index];
         TabSheet->Tag = reinterpret_cast<int>(Terminal);
-        TabSheet->CaptionTruncation = tttEllipsis;
+        TabSheet->CaptionTruncation = WinConfiguration->SessionTabCaptionTruncation ? tttEllipsis : tttNone;
 
         UpdateSessionTab(TabSheet);
       }
@@ -7372,7 +7377,7 @@ void __fastcall TCustomScpExplorerForm::SessionListChanged(bool ForceTruncationU
         TabSheet->Tag = 0; // not really needed
         TabSheet->Shadowed = false;
         TabSheet->Button = SupportsLocalBrowser() ? ttbDropDown : ttbNone;
-        TabSheet->CaptionTruncation = tttNoText;
+        TabSheet->CaptionTruncation = GetNewTabTabCaptionTruncation();
         // We know that we are at the last page, otherwise we could not call this (it assumes that new session tab is the last one)
         UpdateNewTabTab();
       }
@@ -7392,14 +7397,24 @@ void __fastcall TCustomScpExplorerForm::SessionListChanged(bool ForceTruncationU
   SessionsPageControl->ActivePageIndex = ActiveSessionIndex;
 }
 //---------------------------------------------------------------------------
+TThemeTabCaptionTruncation TCustomScpExplorerForm::GetNewTabTabCaptionTruncation()
+{
+  return WinConfiguration->SessionTabCaptionTruncation ? tttNoText : tttNone;
+}
+//---------------------------------------------------------------------------
 UnicodeString TCustomScpExplorerForm::GetNewTabTabCaption()
 {
   return StripHotkey(StripTrailingPunctuation(NonVisualDataModule->NewTabAction->Caption));
 }
 //---------------------------------------------------------------------------
+TThemeTabSheet * TCustomScpExplorerForm::GetNewTabTab()
+{
+  return SessionsPageControl->Pages[SessionsPageControl->PageCount - 1];
+}
+//---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::UpdateNewTabTab()
 {
-  TThemeTabSheet * TabSheet = SessionsPageControl->Pages[SessionsPageControl->PageCount - 1];
+  TThemeTabSheet * TabSheet = GetNewTabTab();
 
   UnicodeString TabCaption;
   if (WinConfiguration->SelectiveToolbarText)

+ 2 - 0
source/forms/CustomScpExplorer.h

@@ -652,6 +652,8 @@ protected:
   int __fastcall AddSessionColor(TColor Color);
   void UpdateSessionTab(TThemeTabSheet * TabSheet);
   void __fastcall UpdateNewTabTab();
+  TThemeTabSheet * GetNewTabTab();
+  TThemeTabCaptionTruncation GetNewTabTabCaptionTruncation();
   UnicodeString GetNewTabTabCaption();
   void __fastcall AddFixedSessionImages();
   int __fastcall AddFixedSessionImage(int GlyphsSourceIndex);

+ 2 - 0
source/forms/Preferences.cpp

@@ -509,6 +509,7 @@ void __fastcall TPreferencesDialog::LoadConfiguration()
     BOOLPROP(ExternalSessionInExistingInstance);
     BOOLPROP(ShowLoginWhenNoSession);
     BOOLPROP(KeepOpenWhenNoSession);
+    BOOLPROP(SessionTabCaptionTruncation);
     BOOLPROP(ShowTips);
 
     // panels
@@ -907,6 +908,7 @@ void __fastcall TPreferencesDialog::SaveConfiguration()
     BOOLPROP(ExternalSessionInExistingInstance);
     BOOLPROP(ShowLoginWhenNoSession);
     BOOLPROP(KeepOpenWhenNoSession);
+    BOOLPROP(SessionTabCaptionTruncation);
     BOOLPROP(ShowTips);
 
     // panels

+ 14 - 4
source/forms/Preferences.dfm

@@ -2563,13 +2563,13 @@ object PreferencesDialog: TPreferencesDialog
           Left = 8
           Top = 231
           Width = 389
-          Height = 150
+          Height = 174
           Anchors = [akLeft, akTop, akRight]
           Caption = 'Miscellaneous'
           TabOrder = 2
           DesignSize = (
             389
-            150)
+            174)
           object MinimizeToTrayCheck: TCheckBox
             Left = 16
             Top = 21
@@ -2602,12 +2602,12 @@ object PreferencesDialog: TPreferencesDialog
           end
           object ShowTipsCheck: TCheckBox
             Left = 16
-            Top = 117
+            Top = 141
             Width = 361
             Height = 17
             Anchors = [akLeft, akTop, akRight]
             Caption = '&Display tips on startup'
-            TabOrder = 4
+            TabOrder = 5
             OnClick = ControlChange
           end
           object ShowLoginWhenNoSessionCheck: TCheckBox
@@ -2622,6 +2622,16 @@ object PreferencesDialog: TPreferencesDialog
             TabOrder = 2
             OnClick = ControlChange
           end
+          object SessionTabCaptionTruncationCheck: TCheckBox
+            Left = 16
+            Top = 117
+            Width = 361
+            Height = 17
+            Anchors = [akLeft, akTop, akRight]
+            Caption = '&Truncate tab titles when they do not fit to window'
+            TabOrder = 4
+            OnClick = ControlChange
+          end
         end
         object WorkspacesGroup: TGroupBox
           Left = 8

+ 1 - 0
source/forms/Preferences.h

@@ -354,6 +354,7 @@ __published:
   TButton *EditSshHostCAButton;
   TCheckBox *SshHostCAsFromPuTTYCheck;
   TButton *ConfigureSshHostCAsButton;
+  TCheckBox *SessionTabCaptionTruncationCheck;
   void __fastcall FormShow(TObject *Sender);
   void __fastcall ControlChange(TObject *Sender);
   void __fastcall EditorFontButtonClick(TObject *Sender);

+ 7 - 0
source/windows/WinConfiguration.cpp

@@ -635,6 +635,7 @@ void __fastcall TWinConfiguration::Default()
   QueueTransferLimitMax = 9;
   HiContrast = false;
   EditorCheckNotModified = false;
+  SessionTabCaptionTruncation = true;
   FirstRun = StandardDatestamp();
 
   FEditor.Font.FontName = DefaultFixedWidthFontName;
@@ -1098,6 +1099,7 @@ THierarchicalStorage * TWinConfiguration::CreateScpStorage(bool & SessionList)
     KEY(Integer,  QueueTransferLimitMax); \
     KEY(Bool,     HiContrast); \
     KEY(Bool,     EditorCheckNotModified); \
+    KEY(Bool,     SessionTabCaptionTruncation); \
     KEY(String,   FirstRun); \
   ); \
   BLOCK(L"Interface\\Editor", CANCREATE, \
@@ -2805,6 +2807,11 @@ void TWinConfiguration::SetEditorCheckNotModified(bool value)
   SET_CONFIG_PROPERTY(EditorCheckNotModified);
 }
 //---------------------------------------------------------------------------
+void TWinConfiguration::SetSessionTabCaptionTruncation(bool value)
+{
+  SET_CONFIG_PROPERTY(SessionTabCaptionTruncation);
+}
+//---------------------------------------------------------------------------
 void TWinConfiguration::SetFirstRun(const UnicodeString & value)
 {
   SET_CONFIG_PROPERTY(FirstRun);

+ 3 - 0
source/windows/WinConfiguration.h

@@ -483,6 +483,7 @@ private:
   int FQueueTransferLimitMax;
   bool FHiContrast;
   bool FEditorCheckNotModified;
+  bool FSessionTabCaptionTruncation;
   UnicodeString FFirstRun;
   int FDontDecryptPasswords;
   int FMasterPasswordSession;
@@ -605,6 +606,7 @@ private:
   void SetQueueTransferLimitMax(int value);
   void SetHiContrast(bool value);
   void SetEditorCheckNotModified(bool value);
+  void SetSessionTabCaptionTruncation(bool value);
   void SetFirstRun(const UnicodeString & value);
   int __fastcall GetLocaleCompletenessTreshold();
 
@@ -809,6 +811,7 @@ public:
   __property int QueueTransferLimitMax = { read = FQueueTransferLimitMax, write = SetQueueTransferLimitMax };
   __property bool HiContrast = { read = FHiContrast, write = SetHiContrast };
   __property bool EditorCheckNotModified = { read = FEditorCheckNotModified, write = SetEditorCheckNotModified };
+  __property bool SessionTabCaptionTruncation = { read = FSessionTabCaptionTruncation, write = SetSessionTabCaptionTruncation };
   __property UnicodeString FirstRun = { read = FFirstRun, write = SetFirstRun };
   __property LCID DefaultLocale = { read = FDefaultLocale };
   __property int LocaleCompletenessTreshold = { read = GetLocaleCompletenessTreshold };