Dark windows: use background/foreground colors for tooltips

That follows what File Explorer on Windows 11, or the system UI does for
tooltips in modern UI elements (the tooltip for the "minimize" button in
a titlebar still shows the yellow-colored tooltip). Using the accent
color makes the tooltip pop a lot more, but doesn't look native.

Also make the toolTipPalette helper function do something useful in dark
mode.

Change-Id: I2b07abd72eee50508f19f46aaec3408183c27100
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
(cherry picked from commit eac9e74d9271f793f2a49af6ba776dd444875844)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Volker Hilsheimer 2023-01-05 16:01:35 +01:00 committed by Qt Cherry-pick Bot
parent a505baf4a5
commit a8e6733dd2

View File

@ -298,8 +298,8 @@ static void populateDarkSystemBasePalette(QPalette &result)
result.setColor(QPalette::All, QPalette::Link, linkColor);
result.setColor(QPalette::All, QPalette::LinkVisited, accentDarkest);
result.setColor(QPalette::All, QPalette::AlternateBase, accentDarkest);
result.setColor(QPalette::All, QPalette::ToolTipBase, accentDarkest);
result.setColor(QPalette::All, QPalette::ToolTipText, accentLightest);
result.setColor(QPalette::All, QPalette::ToolTipBase, buttonColor);
result.setColor(QPalette::All, QPalette::ToolTipText, foreground.darker(120));
result.setColor(QPalette::All, QPalette::PlaceholderText, placeHolderColor(foreground));
}
@ -335,12 +335,11 @@ static QPalette systemPalette(bool light)
static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
{
if (!light)
return systemPalette;
QPalette result(systemPalette);
const QColor tipBgColor = getSysColor(COLOR_INFOBK);
const QColor tipTextColor = getSysColor(COLOR_INFOTEXT);
const QColor tipBgColor = light ? getSysColor(COLOR_INFOBK)
: systemPalette.button().color();
const QColor tipTextColor = light ? getSysColor(COLOR_INFOTEXT)
: systemPalette.buttonText().color().darker(120);
result.setColor(QPalette::All, QPalette::Button, tipBgColor);
result.setColor(QPalette::All, QPalette::Window, tipBgColor);