Qt: set proper text palette when control is disabled and regular font.color <> clDefault.issue #25922

git-svn-id: trunk@44541 -
This commit is contained in:
zeljko 2014-03-28 16:37:11 +00:00
parent b60a8b420e
commit 0b82d8141f
2 changed files with 29 additions and 4 deletions

View File

@ -422,6 +422,7 @@ var
AQColor, AOldColor: TQColor;
B: Boolean;
OldCanvasFontColor: TColor;
APalette: QPaletteH;
begin
B := False;
@ -431,10 +432,25 @@ begin
B := True;
AOldColor := TQtDeviceContext(TCanvas(ACanvas).Handle).pen.getColor;
OldCanvasFontColor := TCanvas(ACanvas).Font.Color;
if TCanvas(ACanvas).Font.Color = clDefault then
TCanvas(ACanvas).Font.Color := clBtnText;
ColorRefToTQColor(ColorToRGB(TCanvas(ACanvas).Font.Color), AQColor);
TQtDeviceContext(TCanvas(ACanvas).Handle).pen.setColor(AQColor);
// issue #25922
if IsDisabled(Details) then
begin
APalette := QPalette_create;
try
QApplication_palette(APalette,'QPushButton');
AQColor := QPalette_color(APalette, QPaletteDisabled, QPaletteButtonText)^;
TQtDeviceContext(TCanvas(ACanvas).Handle).pen.setColor(AQColor);
finally
QPalette_destroy(APalette);
end;
end else
begin
if TCanvas(ACanvas).Font.Color = clDefault then
TCanvas(ACanvas).Font.Color := clBtnText;
ColorRefToTQColor(ColorToRGB(TCanvas(ACanvas).Font.Color), AQColor);
TQtDeviceContext(TCanvas(ACanvas).Handle).pen.setColor(AQColor);
end;
end;
DrawText(TCanvas(ACanvas).Handle, Details, S, R, Flags, Flags2);

View File

@ -2388,6 +2388,15 @@ begin
if PtInRect(R, QtWidgetSet.GetWidgetAtCachePoint) then
QtWidgetSet.InvalidateWidgetAtCache;
end;
// issue #25922
if Assigned(FPalette) and Assigned(LCLObject) then
begin
// DebugLn('QEventEnabledChange: ',dbgsName(LCLObject),' enabled ',dbgs(getEnabled));
if not getEnabled then
Palette.setTextColor(@Palette.DisabledTextColor)
else
setInitialFontColor(LCLObject);
end;
end;
QEventShow:
begin