fix: the header completion window's text color not correctly set when the scheme's color doesn't have good contrast with background

This commit is contained in:
royqh1979 2021-10-31 08:31:46 +08:00
parent 4eec185ac4
commit 7b0b7c1413
1 changed files with 3 additions and 1 deletions

View File

@ -428,7 +428,7 @@ void MainWindow::updateCompileActions()
static bool haveGoodContrast(const QColor& c1, const QColor &c2) {
int lightness1 = c1.lightness();
int lightness2 = c2.lightness();
return std::abs(lightness1 - lightness2)>=150;
return std::abs(lightness1 - lightness2)>=100;
}
void MainWindow::updateEditorColorSchemes()
@ -478,6 +478,8 @@ void MainWindow::updateEditorColorSchemes()
mStatementColors->insert(StatementKind::skPreprocessor,item);
mStatementColors->insert(StatementKind::skEnum,item);
mHeaderCompletionPopup->setSuggestionColor(item->foreground());
} else {
mHeaderCompletionPopup->setSuggestionColor(palette().color(QPalette::Text));
}
item = pColorManager->getItem(schemeName, SYNS_AttrReservedWord);
if (item && haveGoodContrast(item->foreground(), baseColor)) {