Skip to content

Commit

Permalink
Host tab: use session name as tab caption, and show host name as mous…
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarbecker committed Mar 9, 2024
1 parent b617a4f commit 56d84c3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions source/main.pas
Expand Up @@ -9575,7 +9575,6 @@ procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualN
var
DBObj, PrevDBObj, ParentDBObj: PDBObject;
MainTabToActivate: TTabSheet;
TabHostName: String;
EnteringSession: Boolean;
begin
// Set wanted main tab and call SetMainTab later, when all lists have been invalidated
Expand Down Expand Up @@ -9712,12 +9711,8 @@ procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualN
InvalidateVT(ListTables, VTREE_NOTLOADED, True);
if FActiveDbObj.NodeType = lntGroup then
InvalidateVT(ListTables, VTREE_NOTLOADED, True);
if FActiveDbObj.Connection.Parameters.IsAnySQLite then // Prefer visible filename over visible left part of path
TabHostName := StrEllipsis(FActiveDbObj.Connection.Parameters.HostName, 60, False)
else
TabHostName := FActiveDbObj.Connection.Parameters.HostName;

SetTabCaption(tabHost.PageIndex, _('Host')+': '+TabHostName);
SetTabCaption(tabHost.PageIndex, FActiveDbObj.Connection.Parameters.SessionName);
SetTabCaption(tabDatabase.PageIndex, _('Database')+': '+FActiveDbObj.Connection.Database);
ShowStatusMsg(FActiveDbObj.Connection.Parameters.NetTypeName(False)+' '+FActiveDbObj.Connection.ServerVersionStr, 3);
end else begin
Expand Down Expand Up @@ -14410,15 +14405,23 @@ procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolea
var
MainTabIndex, QueryTabIndex: integer;
pt: TPoint;
Conn: TDBConnection;
begin
// Show full filename in tab hint. See issue #3527
// Code taken from http://www.delphipraxis.net/97988-tabsheet-hint-funktioniert-nicht.html
if HintInfo.HintControl = PageControlMain then begin
pt := PageControlMain.ScreenToClient(Mouse.CursorPos);
MainTabIndex := GetMainTabAt(pt.X, pt.Y);
QueryTabIndex := MainTabIndex - tabQuery.PageIndex;
if (QueryTabIndex >= 0) and (QueryTabIndex < QueryTabs.Count) then
if (QueryTabIndex >= 0) and (QueryTabIndex < QueryTabs.Count) then begin
HintStr := QueryTabs[QueryTabIndex].MemoFilename;
end
else if MainTabIndex = tabHost.TabIndex then begin
Conn := ActiveConnection;
HintStr := Conn.Parameters.Hostname;
if Conn.Parameters.IsAnySQLite then
HintStr := StringReplace(HintStr, DELIM, SLineBreak, [rfReplaceAll]);
end;
HintInfo.ReshowTimeout := 1000;
end;
end;
Expand Down

0 comments on commit 56d84c3

Please sign in to comment.