Qt: use style hints to increase menubar height result in SM_CYMENU if needed. issue #1020

git-svn-id: trunk@35649 -
This commit is contained in:
zeljko 2012-03-02 07:31:06 +00:00
parent 51219a53e0
commit 48fb810448
2 changed files with 22 additions and 4 deletions

View File

@ -97,6 +97,7 @@ type
function GetMenuHeight: Integer;
procedure ClearCachedColors;
function GetStyleName: String;
procedure SetOverrideCursor(const AValue: TObject);
procedure QtRemoveStayOnTop(const ASystemTopAlso: Boolean = False);
procedure QtRestoreStayOnTop(const ASystemTopAlso: Boolean = False);
@ -198,6 +199,7 @@ type
property IsLibraryInstance: Boolean read FIsLibraryInstance;
property OverrideCursor: TObject read FOverrideCursor write SetOverrideCursor;
property StyleName: String read GetStyleName;
{$IFDEF HASX11}
property WindowManagerName: String read FWindowManagerName;
{$ENDIF}

View File

@ -20,15 +20,12 @@
// with various styles under X11.
procedure QtX11InitializePalettes;
var
StyleName: WideString;
Palette: QPaletteH;
LineEditPalette: QPaletteH;
ComboBoxPalette: QPaletteH;
TextEditPalette: QPaletteH;
Brush: QBrushH;
begin
QObject_objectName(QApplication_style(), @StyleName);
//palette for disabled viewports and edit controls
Palette := QPalette_create();
QApplication_palette(Palette);
@ -1401,9 +1398,20 @@ begin
QMenuBar_sizeHint(AMenuBar, @Size);
QMainWindow_destroy(DummyWindow);
FCachedMenuBarHeight := Size.cy;
if QStyle_styleHint(QApplication_style(),
QStyleSH_MainWindow_SpaceBelowMenuBar) > 0 then
inc(FCachedMenuBarHeight, 4);
if QStyle_styleHint(QApplication_style(),
QStyleSH_ScrollView_FrameOnlyAroundContents) > 0 then
inc(FCachedMenuBarHeight, 4);
end;
if (FCachedMenuBarHeight <= 0) then
FCachedMenuBarHeight := 22; // default
begin
FCachedMenuBarHeight := 22;
if QStyle_styleHint(QApplication_style(), QStyleSH_MainWindow_SpaceBelowMenuBar) > 0 then
inc(FCachedMenuBarHeight, 4);
end;
Result := FCachedMenuBarHeight;
end;
@ -1419,4 +1427,12 @@ begin
end;
end;
function TQtWidgetSet.GetStyleName: String;
var
WStr: WideString;
begin
QObject_objectName(QApplication_style, @WStr);
Result := UTF8ToUTF16(WStr);
end;
//------------------------------------------------------------------------