Fix selection color in locator popup

On macOS and Windows the background of the selected item in locator
would be light gray, since the popup doesn't really get focus there. We
still want it to look the same as if it had focus, so change the palette
accordingly.

Fixes: QTCREATORBUG-22118
Change-Id: Iefbbd49b4980a01de494e33ddb8e43e2d5a15716
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Eike Ziller
2019-03-12 11:24:32 +01:00
parent d7eeb0bd90
commit 1e28a66bb5

View File

@@ -252,6 +252,14 @@ void LocatorModel::addEntries(const QList<LocatorFilterEntry> &entries)
CompletionList::CompletionList(QWidget *parent)
: Utils::TreeView(parent)
{
// on macOS and Windows the popup doesn't really get focus, so fake the selection color
// which would then just be a very light gray, but should look as if it had focus
QPalette p = palette();
p.setBrush(QPalette::Inactive,
QPalette::Highlight,
p.brush(QPalette::Normal, QPalette::Highlight));
setPalette(p);
setItemDelegate(new CompletionDelegate(this));
setRootIsDecorated(false);
setUniformRowHeights(true);