Skip to content

Commit e1ad5c3

Browse files
committed
feat: show connection details as a hint over status bar
This moves code from (dead) StatusBarMouseMove to ApplicationShowHint, and removes the no longer needed code in the tabsetQuery.OnMouseLeave event
1 parent 95df174 commit e1ad5c3

File tree

2 files changed

+19
-72
lines changed

2 files changed

+19
-72
lines changed

source/main.lfm

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3492,7 +3492,6 @@ object MainForm: TMainForm
34923492
OnGetImageIndex = tabsetQueryGetImageIndex
34933493
Align = alTop
34943494
TabOrder = 2
3495-
OnMouseLeave = tabsetQueryMouseLeave
34963495
OnMouseMove = tabsetQueryMouseMove
34973496
end
34983497
object QueryGrid: TLazVirtualStringTree

source/main.pas

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,10 +1043,7 @@ TMainForm = class(TExtForm)
10431043
procedure tabsetQueryClick(Sender: TObject);
10441044
procedure tabsetQueryGetImageIndex(Sender: TObject; TabIndex: Integer; var ImageIndex: Integer);
10451045
procedure tabsetQueryMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
1046-
procedure tabsetQueryMouseLeave(Sender: TObject);
10471046
procedure StatusBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);
1048-
//procedure StatusBarMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
1049-
//procedure StatusBarMouseLeave(Sender: TObject);
10501047
procedure AnyGridStartOperation(Sender: TBaseVirtualTree; OperationKind: TVTOperationKind);
10511048
procedure AnyGridEndOperation(Sender: TBaseVirtualTree; OperationKind: TVTOperationKind);
10521049
procedure actDataPreviewUpdate(Sender: TObject);
@@ -1205,7 +1202,6 @@ TMainForm = class(TExtForm)
12051202
FAppVersion: String;
12061203

12071204
FLastHintMousepos: TPoint;
1208-
FLastHintControlIndex: Integer;
12091205
FDelimiter: String;
12101206
FLogToFile: Boolean;
12111207
FFileNameSessionLog: String;
@@ -1513,58 +1509,6 @@ procedure TMainForm.StatusBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPane
15131509
end;
15141510

15151511

1516-
{procedure TMainForm.StatusBarMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
1517-
var
1518-
MouseP: TPoint;
1519-
Bar: TStatusBar;
1520-
PanelRect: TRect;
1521-
i: Integer;
1522-
Infos: TStringList;
1523-
HintText: String;
1524-
Conn: TDBConnection;
1525-
begin
1526-
// Display various server, client and connection related details in a hint
1527-
if IsWine then
1528-
Exit;
1529-
if (FLastHintMousepos.X = X) and (FLastHintMousepos.Y = Y) then
1530-
Exit;
1531-
FLastHintMousepos := Point(X, Y);
1532-
MouseP := StatusBar.ClientOrigin;
1533-
Inc(MouseP.X, X);
1534-
Inc(MouseP.Y, Y);
1535-
Bar := Sender as TStatusBar;
1536-
for i:=0 to Bar.Panels.Count-1 do begin
1537-
SendMessage(Bar.Handle, SB_GETRECT, i, Integer(@PanelRect));
1538-
if PtInRect(PanelRect, FLastHintMousepos) then
1539-
break;
1540-
end;
1541-
if i = FLastHintControlIndex then
1542-
Exit;
1543-
FLastHintControlIndex := i;
1544-
if FLastHintControlIndex = 3 then begin
1545-
Conn := ActiveConnection;
1546-
if (Conn <> nil) and (not Conn.IsLockedByThread) then begin
1547-
Infos := Conn.ConnectionInfo;
1548-
HintText := '';
1549-
for i:=0 to Infos.Count-1 do begin
1550-
HintText := HintText + Infos.Names[i] + ': ' + StrEllipsis(Infos.ValueFromIndex[i], 200) + CRLF;
1551-
end;
1552-
BalloonHint1.Description := Trim(HintText);
1553-
OffsetRect(PanelRect, Bar.ClientOrigin.X, Bar.ClientOrigin.Y);
1554-
BalloonHint1.ShowHint(PanelRect);
1555-
end;
1556-
end else
1557-
Bar.OnMouseLeave(Sender);
1558-
end;}
1559-
1560-
1561-
{procedure TMainForm.StatusBarMouseLeave(Sender: TObject);
1562-
begin
1563-
BalloonHint1.HideHint;
1564-
FLastHintControlIndex := -1;
1565-
end;}
1566-
1567-
15681512
procedure TMainForm.actExitApplicationExecute(Sender: TObject);
15691513
begin
15701514
Close;
@@ -8508,9 +8452,8 @@ procedure TMainForm.tabsetQueryMouseMove(Sender: TObject; Shift: TShiftState; X,
85088452
FLastHintMousepos := Point(X, Y);
85098453
Tabs := Sender as TTabControl;
85108454
idx := Tabs.IndexOfTabAt(X, Y);
8511-
if (idx = -1) or (idx = FLastHintControlIndex) then
8455+
if idx = -1 then
85128456
Exit;
8513-
FLastHintControlIndex := idx;
85148457
// Check if user wants these balloon hints
85158458
if not AppSettings.ReadBool(asHintsOnResultTabs) then
85168459
Exit;
@@ -8539,14 +8482,6 @@ procedure TMainForm.tabsetQueryMouseMove(Sender: TObject; Shift: TShiftState; X,
85398482
end;
85408483

85418484

8542-
procedure TMainForm.tabsetQueryMouseLeave(Sender: TObject);
8543-
begin
8544-
// BalloonHint.HideAfter is -1, so it will stay forever if we wouldn't hide it at some point
8545-
//BalloonHint1.HideHint;
8546-
FLastHintControlIndex := -1;
8547-
end;
8548-
8549-
85508485
{**
85518486
Insert function name from popupmenu to query memo
85528487
}
@@ -12408,7 +12343,6 @@ procedure TMainForm.actNewQueryTabExecute(Sender: TObject);
1240812343
QueryTab.tabsetQuery.OnChange := tabsetQuery.OnChange;
1240912344
QueryTab.tabsetQuery.OnGetImageIndex := tabsetQuery.OnGetImageIndex;
1241012345
QueryTab.tabsetQuery.OnMouseMove := tabsetQuery.OnMouseMove;
12411-
QueryTab.tabsetQuery.OnMouseLeave := tabsetQuery.OnMouseLeave;
1241212346

1241312347
SetupSynEditor(QueryTab.Memo);
1241412348

@@ -14669,18 +14603,17 @@ procedure TMainForm.ApplicationDeActivate(Sender: TObject);
1466914603
LogSQL(E.Message, lcError);
1467014604
end;
1467114605
// Gets activated again in SynCompletionProposalExecute
14672-
14673-
// Force result tab balloon hint to disappear. Does not do so when mouse was moved too fast.
14674-
tabsetQueryMouseLeave(Sender);
1467514606
end;
1467614607

1467714608

1467814609
procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo);
1467914610
var
14680-
MainTabIndex, QueryTabIndex, NewHideTimeout: integer;
14611+
MainTabIndex, QueryTabIndex, NewHideTimeout, PanelIndex: Integer;
1468114612
pt: TPoint;
1468214613
Conn: TDBConnection;
1468314614
Editor: TSynMemo;
14615+
Infos: TStringList;
14616+
i: Integer;
1468414617
begin
1468514618
if HintInfo.HintControl = PageControlMain then begin
1468614619
// Show full filename in tab hint. See issue #3527
@@ -14708,6 +14641,21 @@ procedure TMainForm.ApplicationShowHint(var HintStr: string; var CanShow: Boolea
1470814641
if NewHideTimeout > HintInfo.HideTimeout then
1470914642
HintInfo.HideTimeout := NewHideTimeout;
1471014643
end
14644+
else if HintInfo.HintControl = StatusBar then begin
14645+
pt := StatusBar.ScreenToClient(Mouse.CursorPos);
14646+
PanelIndex := StatusBar.GetPanelIndexAt(pt.X, pt.Y);
14647+
if PanelIndex = 3 then begin
14648+
Conn := ActiveConnection;
14649+
if (Conn <> nil) and (not Conn.IsLockedByThread) then begin
14650+
Infos := Conn.ConnectionInfo;
14651+
HintStr := '';
14652+
for i:=0 to Infos.Count-1 do begin
14653+
HintStr := HintStr + Infos.Names[i] + ': ' + StrEllipsis(Infos.ValueFromIndex[i], 200) + LineEnding;
14654+
end;
14655+
HintStr := Trim(HintStr);
14656+
end;
14657+
end;
14658+
end
1471114659
else begin
1471214660
// Probably reset hint font
1471314661
SetHintFontByControl;

0 commit comments

Comments
 (0)