mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-25 23:09:13 +02:00
Qt: hide statusbar panels with width 0. issue #22362
git-svn-id: trunk@37857 -
This commit is contained in:
parent
24a032bd60
commit
b68368f585
@ -552,6 +552,7 @@ class procedure TQtWSStatusBar.RecreatePanels(const AStatusBar: TStatusBar;
|
||||
var
|
||||
Str: WideString;
|
||||
i: Integer;
|
||||
Margin: Integer;
|
||||
begin
|
||||
Str := '';
|
||||
//clean up. http://bugs.freepascal.org/view.php?id=18683
|
||||
@ -564,6 +565,9 @@ begin
|
||||
end else
|
||||
if AStatusBar.Panels.Count > 0 then
|
||||
begin
|
||||
Margin := (QStyle_pixelMetric(QApplication_style(), QStylePM_DefaultFrameWidth, nil, nil) * 2) - 1;
|
||||
if Margin <= 0 then
|
||||
Margin := 2;
|
||||
Widget.setUpdatesEnabled(False);
|
||||
SetLength(Widget.Panels, AStatusBar.Panels.Count);
|
||||
for i := 0 to AStatusBar.Panels.Count - 1 do
|
||||
@ -577,6 +581,8 @@ begin
|
||||
QLabel_setAlignment(QLabelH(Widget.Panels[i].Widget),
|
||||
AlignmentToQtAlignmentMap[AStatusBar.Panels[i].Alignment]);
|
||||
QWidget_setMinimumWidth(Widget.Panels[i].Widget, AStatusBar.Panels[i].Width);
|
||||
QWidget_setVisible(Widget.Panels[i].Widget,
|
||||
AStatusBar.Panels[i].Width >= Margin);
|
||||
Widget.Panels[i].AttachEvents;
|
||||
Widget.addWidget(Widget.Panels[i].Widget, ord(i = AStatusBar.Panels.Count - 1));
|
||||
end;
|
||||
@ -614,6 +620,7 @@ class procedure TQtWSStatusBar.PanelUpdate(const AStatusBar: TStatusBar; PanelIn
|
||||
var
|
||||
QtStatusBar: TQtStatusBar;
|
||||
Str: Widestring;
|
||||
Margin: Integer;
|
||||
begin
|
||||
QtStatusBar := TQtStatusBar(AStatusBar.Handle);
|
||||
if AStatusBar.SimplePanel then
|
||||
@ -629,12 +636,18 @@ begin
|
||||
if (PanelIndex >= Low(QtStatusBar.Panels)) and
|
||||
(PanelIndex <= High(QtStatusBar.Panels)) then
|
||||
begin
|
||||
Margin := (QStyle_pixelMetric(QApplication_style(), QStylePM_DefaultFrameWidth, nil, nil) * 2) - 1;
|
||||
if Margin <= 0 then
|
||||
Margin := 2;
|
||||
|
||||
Str := GetUtf8String(AStatusBar.Panels[PanelIndex].Text);
|
||||
QLabel_setText(QLabelH(QtStatusBar.Panels[PanelIndex].Widget), @Str);
|
||||
QLabel_setAlignment(QLabelH(QtStatusBar.Panels[PanelIndex].Widget),
|
||||
AlignmentToQtAlignmentMap[AStatusBar.Panels[PanelIndex].Alignment]);
|
||||
QWidget_setMinimumWidth(QtStatusBar.Panels[PanelIndex].Widget,
|
||||
AStatusBar.Panels[PanelIndex].Width);
|
||||
QWidget_setVisible(QtStatusBar.Panels[PanelIndex].Widget,
|
||||
AStatusBar.Panels[PanelIndex].Width >= Margin);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user